Create Client (v1)
Method + Path
POST /v1/workspace/:workspaceId/clients
Actual backend path: /v1/workspace/:workspaceId/clients
Description
Create a new client (customer) in a workspace.
Authentication
Required - JWT token in Authorization header
Required Permissions:
clients.create
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer token: Bearer <token> |
Content-Type | string | Yes | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string | Yes | Workspace identifier |
Request Body
{
"name": "John Doe",
"avatarUrl": "https://example.com/avatar.jpg",
"contactMethods": [
{
"type": "phone",
"value": "+1234567890",
"isPreferred": true
},
{
"type": "email",
"value": "john@example.com",
"isPreferred": false
}
],
"customFields": [
{
"fieldKey": "notes",
"value": "Preferred contact time: 9am-5pm"
}
]
}
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Client name (minimum 1 character) |
avatarUrl | string | No | URL to client avatar image (must be valid URL if provided) |
contactMethods | array | Yes | Array of contact methods (minimum 1, exactly one must be preferred) |
contactMethods[].type | string | Yes | Contact type. Valid values: whatsapp, phone, email, fax, other |
contactMethods[].value | string | Yes | Contact value (minimum 1 character) |
contactMethods[].isPreferred | boolean | Yes | Whether this is the preferred contact method |
customFields | array | No | Array of custom field values |
Response (201)
{
"client": {
"id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"avatarUrl": "https://example.com/avatar.jpg",
"contactMethods": [
{
"type": "phone",
"value": "+1234567890",
"isPreferred": true
}
],
"customFields": [],
"createdAt": "2024-01-15T10:00:00Z"
}
}
Common Errors
- 400 Bad Request: Invalid request body or validation errors
- 401 Unauthorized: Missing or invalid authentication token
- 403 Forbidden: Insufficient permissions (requires
clients.create) - 404 Not Found: Workspace not found
- 422 Unprocessable Entity: Validation errors (e.g., no preferred contact method, invalid contact type)
- 500 Internal Server Error: Server error