Skip to main content

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

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token: Bearer <token>
Content-TypestringYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
workspaceIdstringYesWorkspace 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

ParameterTypeRequiredDescription
namestringYesClient name (minimum 1 character)
avatarUrlstringNoURL to client avatar image (must be valid URL if provided)
contactMethodsarrayYesArray of contact methods (minimum 1, exactly one must be preferred)
contactMethods[].typestringYesContact type. Valid values: whatsapp, phone, email, fax, other
contactMethods[].valuestringYesContact value (minimum 1 character)
contactMethods[].isPreferredbooleanYesWhether this is the preferred contact method
customFieldsarrayNoArray 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