0
# Account Management
1
2
Customer account management functionality for companies and organizations in the CRM system. Accounts represent business entities that can have multiple contacts, opportunities, cases, and other CRM activities associated with them.
3
4
## Capabilities
5
6
### Account Listing and Search
7
8
List accounts with comprehensive filtering and search capabilities.
9
10
```python { .api }
11
def list_accounts(name: str = None, city: str = None, industry: str = None,
12
tags: str = None, limit: int = 10, offset: int = 0) -> dict:
13
"""
14
List accounts with filtering and search.
15
16
Args:
17
name (str, optional): Filter by account name (partial match)
18
city (str, optional): Filter by city
19
industry (str, optional): Filter by industry
20
tags (str, optional): Filter by tags
21
limit (int): Number of results per page (default: 10)
22
offset (int): Number of results to skip (default: 0)
23
24
Returns:
25
dict: Paginated accounts with metadata
26
27
Headers Required:
28
Authorization: Bearer <access_token>
29
organization-id: <org_uuid>
30
31
Example:
32
GET /api/accounts/?name=acme&city=new%20york&limit=5
33
34
Response:
35
{
36
"open_accounts": [
37
{
38
"id": "account-uuid",
39
"name": "ACME Corporation",
40
"email": "contact@acme.com",
41
"phone": "+1234567890",
42
"industry": "Technology",
43
"billing_address_line": "123 Business St",
44
"billing_city": "New York",
45
"billing_state": "NY",
46
"billing_postcode": "10001",
47
"billing_country": "USA",
48
"website": "https://acme.com",
49
"status": "open",
50
"created_on": "2023-01-15T10:30:00Z",
51
"created_by": "user-uuid",
52
"assigned_to": ["user1-uuid"],
53
"teams": ["team1-uuid"],
54
"tags": ["enterprise", "technology"]
55
}
56
],
57
"closed_accounts": [],
58
"accounts_count": 1,
59
"open_accounts_count": 1,
60
"closed_accounts_count": 0,
61
"contacts": [...],
62
"users": [...],
63
"teams": [...]
64
}
65
"""
66
```
67
68
### Account Creation
69
70
Create new accounts with full business information and associations.
71
72
```python { .api }
73
def create_account(account_data: dict) -> dict:
74
"""
75
Create a new account.
76
77
Args:
78
account_data (dict): Account information and associations
79
80
Returns:
81
dict: Created account details
82
83
Headers Required:
84
Authorization: Bearer <access_token>
85
organization-id: <org_uuid>
86
Content-Type: multipart/form-data (if including attachments)
87
88
Example:
89
POST /api/accounts/
90
{
91
"name": "New Company Inc",
92
"email": "info@newcompany.com",
93
"phone": "+1555123456",
94
"industry": "Manufacturing",
95
"description": "Leading manufacturer of widgets",
96
"website": "https://newcompany.com",
97
"billing_address_line": "456 Industrial Blvd",
98
"billing_street": "Suite 100",
99
"billing_city": "Chicago",
100
"billing_state": "IL",
101
"billing_postcode": "60601",
102
"billing_country": "USA",
103
"contacts": ["contact1-uuid", "contact2-uuid"],
104
"assigned_to": ["user1-uuid"],
105
"teams": ["team1-uuid"],
106
"tags": ["manufacturing", "enterprise"]
107
}
108
109
Response:
110
{
111
"id": "new-account-uuid",
112
"name": "New Company Inc",
113
...account details...
114
}
115
"""
116
```
117
118
### Account Details and Operations
119
120
Get comprehensive account information including all related entities.
121
122
```python { .api }
123
def get_account(pk: str) -> dict:
124
"""
125
Get detailed account information.
126
127
Args:
128
pk (str): Account UUID
129
130
Returns:
131
dict: Complete account details with related entities
132
133
Headers Required:
134
Authorization: Bearer <access_token>
135
organization-id: <org_uuid>
136
137
Example:
138
GET /api/accounts/account-uuid/
139
140
Response:
141
{
142
"account_obj": {
143
"id": "account-uuid",
144
"name": "ACME Corporation",
145
"email": "contact@acme.com",
146
"phone": "+1234567890",
147
"industry": "Technology",
148
"description": "Leading technology company",
149
"website": "https://acme.com",
150
"status": "open",
151
"billing_address_line": "123 Business St",
152
"billing_city": "New York",
153
"billing_state": "NY",
154
"billing_postcode": "10001",
155
"billing_country": "USA",
156
"created_on": "2023-01-15T10:30:00Z",
157
"created_by": "user-uuid"
158
},
159
"contacts": [...list of associated contacts...],
160
"opportunities": [...list of opportunities...],
161
"cases": [...list of cases...],
162
"tasks": [...list of tasks...],
163
"invoices": [...list of invoices...],
164
"assigned_to": [...list of assigned users...],
165
"teams": [...list of assigned teams...],
166
"comments": [...list of comments...],
167
"attachments": [...list of attachments...],
168
"users_mention": [...users for @mentions...],
169
"tags": ["enterprise", "technology"]
170
}
171
"""
172
173
def update_account(pk: str, account_data: dict) -> dict:
174
"""
175
Update account information.
176
177
Args:
178
pk (str): Account UUID
179
account_data (dict): Updated account information
180
181
Returns:
182
dict: Updated account details
183
184
Headers Required:
185
Authorization: Bearer <access_token>
186
organization-id: <org_uuid>
187
188
Example:
189
PUT /api/accounts/account-uuid/
190
{
191
"name": "ACME Corporation Ltd",
192
"phone": "+1234567891",
193
"website": "https://acme.com"
194
}
195
"""
196
197
def delete_account(pk: str) -> None:
198
"""
199
Delete an account.
200
201
Args:
202
pk (str): Account UUID
203
204
Returns:
205
None: 204 No Content on success
206
207
Headers Required:
208
Authorization: Bearer <access_token>
209
organization-id: <org_uuid>
210
211
Example:
212
DELETE /api/accounts/account-uuid/
213
"""
214
```
215
216
### Account Comments and Attachments
217
218
Add comments and file attachments to accounts.
219
220
```python { .api }
221
def add_account_comment_or_attachment(pk: str, comment: str = None,
222
attachment: file = None) -> dict:
223
"""
224
Add comment or attachment to account.
225
226
Args:
227
pk (str): Account UUID
228
comment (str, optional): Comment text
229
attachment (file, optional): File to attach
230
231
Returns:
232
dict: Success response with added comment/attachment
233
234
Headers Required:
235
Authorization: Bearer <access_token>
236
organization-id: <org_uuid>
237
Content-Type: multipart/form-data (for attachments)
238
239
Example:
240
POST /api/accounts/account-uuid/
241
{
242
"comment": "Follow-up meeting scheduled for next week"
243
}
244
245
# Or with file attachment
246
FormData:
247
comment: "Contract document attached"
248
attachment: <file_object>
249
"""
250
251
def edit_account_comment(pk: str, comment: str) -> dict:
252
"""
253
Edit an account comment.
254
255
Args:
256
pk (str): Comment UUID
257
comment (str): Updated comment text
258
259
Returns:
260
dict: Updated comment
261
262
Headers Required:
263
Authorization: Bearer <access_token>
264
265
Example:
266
PUT /api/accounts/comment/comment-uuid/
267
{
268
"comment": "Updated comment text"
269
}
270
"""
271
272
def delete_account_comment(pk: str) -> None:
273
"""
274
Delete an account comment.
275
276
Args:
277
pk (str): Comment UUID
278
279
Returns:
280
None: 204 No Content on success
281
282
Headers Required:
283
Authorization: Bearer <access_token>
284
285
Example:
286
DELETE /api/accounts/comment/comment-uuid/
287
"""
288
289
def delete_account_attachment(pk: str) -> None:
290
"""
291
Delete an account attachment.
292
293
Args:
294
pk (str): Attachment UUID
295
296
Returns:
297
None: 204 No Content on success
298
299
Headers Required:
300
Authorization: Bearer <access_token>
301
302
Example:
303
DELETE /api/accounts/attachment/attachment-uuid/
304
"""
305
```
306
307
### Account Email Management
308
309
Send emails from accounts with scheduling and tracking capabilities.
310
311
```python { .api }
312
def create_account_email(pk: str, email_data: dict) -> dict:
313
"""
314
Send email from account.
315
316
Args:
317
pk (str): Account UUID
318
email_data (dict): Email details including recipients, subject, body
319
320
Returns:
321
dict: Email sent confirmation
322
323
Headers Required:
324
Authorization: Bearer <access_token>
325
organization-id: <org_uuid>
326
327
Example:
328
POST /api/accounts/account-uuid/create_mail/
329
{
330
"recipients": ["contact@client.com", "manager@client.com"],
331
"subject": "Quarterly Business Review",
332
"html": "<p>Dear valued client...</p>",
333
"scheduled_later": false,
334
"scheduled_date_time": null,
335
"from_account": "sender@yourcompany.com"
336
}
337
338
Response:
339
{
340
"status": "success",
341
"message": "Email sent successfully",
342
"email_id": "email-uuid"
343
}
344
"""
345
```
346
347
## Account Data Types
348
349
```python { .api }
350
class Account:
351
"""Account model representing a customer company/organization"""
352
id: str # UUID
353
name: str # Company name (required)
354
email: str # Primary email
355
phone: str # Primary phone
356
industry: str # Industry type
357
description: str # Company description
358
website: str # Company website URL
359
status: str # 'open' or 'closed'
360
361
# Billing address
362
billing_address_line: str
363
billing_street: str
364
billing_city: str
365
billing_state: str
366
billing_postcode: str
367
billing_country: str
368
369
# Metadata
370
created_on: datetime
371
created_by: str # User UUID
372
org: str # Organization UUID
373
374
# Associations
375
contacts: list[str] # Contact UUIDs
376
assigned_to: list[str] # User UUIDs
377
teams: list[str] # Team UUIDs
378
tags: list[str] # Tag names
379
380
class AccountStatus:
381
"""Account status options"""
382
OPEN: str = "open"
383
CLOSED: str = "closed"
384
385
class AccountComment:
386
"""Comments on accounts"""
387
id: str # UUID
388
comment: str
389
account: str # Account UUID
390
commented_on: datetime
391
commented_by: str # User UUID
392
393
class AccountAttachment:
394
"""File attachments on accounts"""
395
id: str # UUID
396
attachment: str # File path/URL
397
account: str # Account UUID
398
created_on: datetime
399
created_by: str # User UUID
400
```
401
402
## Search and Filtering
403
404
Accounts support extensive filtering options:
405
406
- **Text Search**: `name` (partial matching)
407
- **Location**: `city` filtering
408
- **Classification**: `industry` filtering
409
- **Tags**: `tags` filtering for custom categorization
410
- **Status**: Automatically separated into open and closed accounts
411
- **Associations**: Filter by assigned users, teams, or related contacts
412
413
All filters can be combined and are case-insensitive where applicable.
414
415
## Related Entities
416
417
Accounts serve as central hubs connecting to:
418
- **Contacts**: Individual people within the account
419
- **Opportunities**: Sales deals with the account
420
- **Cases**: Support issues for the account
421
- **Tasks**: Work items related to the account
422
- **Invoices**: Billing documents for the account
423
- **Comments**: Activity and communication history
424
- **Attachments**: Documents and files related to the account
425
426
These relationships provide comprehensive account management and activity tracking across all CRM functions.