List Clients
Get a list of clients with filtering and pagination.
Request
Method: GET
URL: /api/clients
Headers: Authorization: Bearer {token}
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
search |
string | No | Search term |
status |
string | No | Status filter |
page |
integer | No | Page number (default: 1) |
limit |
integer | No | Records per page (default: 20) |
Example Request
curl -X GET "https://example.com/api/clients?page=1&limit=10" \
-H "Authorization: Bearer {token}"
Success Response (200)
{
"records": [
{
"id": 1,
"company_name": "Sample Company",
"type": "organization",
"phone": "021-12345678",
"city": "Tehran",
"country": "Iran",
"created_date": "1403-01-15",
"status": "active"
}
],
"meta": {
"total": 50,
"current_page": 1,
"per_page": 10
}
}
Errors
| Code | Description |
|---|---|
| 401 | Invalid token |
| 403 | Access denied |
Client Details
Get complete information for a specific client by ID.
Request
Method: GET
URL: /api/clients/{id}
Headers: Authorization: Bearer {token}
| Parameter | Type | Description |
|---|---|---|
id |
integer | Client ID |
Example Request
curl -X GET "https://example.com/api/clients/1" \
-H "Authorization: Bearer {token}"
Success Response (200)
{
"record": {
"id": 1,
"company_name": "Sample Company",
"type": "organization",
"address": "Tehran, Valiasr Street",
"city": "Tehran",
"state": "Tehran",
"zip": "1234567890",
"country": "Iran",
"phone": "021-12345678",
"website": "https://example.com",
"created_date": "1403-01-15",
"currency_symbol": "IRR",
"group_ids": "1,2",
"labels": ["Important", "Special"],
"owner_id": 1,
"created_by": 1
},
"custom_fields": {
"field_1": "Custom field value"
}
}
Errors
| Code | Description |
|---|---|
| 401 | Invalid token |
| 403 | Access denied |
| 404 | Client not found |
Create Client
Create a new client in the system.
Request
Method: POST
URL: /api/clients
Headers: Authorization: Bearer {token}
Content-Type: application/json
Request Body:
| Parameter | Type | Required | Description |
|---|---|---|---|
company_name |
string | Yes | Company/organization name |
type |
string | Yes | Type (organization or person) |
address |
string | No | Address |
city |
string | No | City |
state |
string | No | State |
zip |
string | No | Zip code |
country |
string | No | Country |
phone |
string | No | Phone number |
website |
string | No | Website |
Example Request
curl -X POST "https://example.com/api/clients" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"company_name": "New Company",
"type": "organization",
"phone": "021-87654321",
"city": "Isfahan"
}'
Success Response (201)
{
"record": {
"id": 2,
"company_name": "New Company",
"type": "organization",
"phone": "021-87654321",
"city": "Isfahan",
"created_date": "1403-06-15"
}
}
Errors
| Code | Description |
|---|---|
| 401 | Invalid token |
| 403 | Access denied |
| 422 | Validation error |
Update Client
Update an existing client's information. Supports both PUT and PATCH methods.
Request
Method: PUT / PATCH
URL: /api/clients/{id}
Headers: Authorization: Bearer {token}
Content-Type: application/json
Request Body: (Fields required for update)
| Parameter | Type | Description |
|---|---|---|
company_name |
string | Company name |
type |
string | Type |
address |
string | Address |
phone |
string | Phone |
Example Request
curl -X PUT "https://example.com/api/clients/1" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{"company_name": "Sample Company (Edited)", "phone": "021-11111111"}'
Success Response (200)
{
"success": true,
"message": "Client updated successfully"
}
Errors
| Code | Description |
|---|---|
| 401 | Invalid token |
| 403 | Access denied |
| 404 | Client not found |
| 422 | Validation error |
Delete Client
Delete a client from the system.
Request
Method: DELETE
URL: /api/clients/{id}
Headers: Authorization: Bearer {token}
Example Request
curl -X DELETE "https://example.com/api/clients/1" \
-H "Authorization: Bearer {token}"
Success Response (200)
{
"success": true,
"message": "Client deleted successfully"
}
Errors
| Code | Description |
|---|---|
| 401 | Invalid token |
| 403 | Access denied |
| 404 | Client not found |