CRM Contacts Read¶
API CRM Contacts is used to read the contact list in CRM
API URL¶
https://[YOUR-PBX-URL]/api/crm-contacts
The data is transmitted by POST or GET and must be of the form:¶
Array
(
[action] => read
[page] => 1
[filters] => Array
(
[project_id] =>
[crm_type_id] =>
[search] =>
[status] =>
)
[api_hash] => 07112231a9c89f5b108af08608a97b07
)
The action parameter must be read. The page parameter defaults to 1 and is incremented up to pagination.max_page (a page greater than max_page still returns the last page). Contacts are returned 100 per page, ordered by ID, each with its custom fields (custom_fields, the key is the field ID).
HTTP Headers:¶
Content-Type: application/json Authorization: Bearer <token>
Filters:¶
- project_id: project ID in PBX or array of IDs; -1 in the list also includes the contacts without a project
- crm_type_id: CRM Type ID in PBX or array of IDs
- search: Search by phone number, ID, name, title, email, comments or remote_id
- status: Contact status: active, pending, confirmed, invalid, suspended, deleted; valid = all except invalid, suspended and deleted; default (or -1) = all except deleted
Any other filter returns the error Invalid filter: ...
Example of parameter generation:
$params = array(
'action' => 'read',
'page' => 1,
'filters' => array(
'project_id' => null,
'crm_type_id' => null,
'search' => null,
'status' => 'valid', // -1 = All
)
);
Example of hash generation:
$params['api_hash'] = md5(json_encode($params) . 'your_api_key'); // make hash
Example for sending data:
$url = 'https://[YOUR-PBX-URL]/api/crm-contacts';
$token = 'your_api_token';
echo curlPost($url, json_encode($params), array("Authorization: Bearer {$token}", "Content-Type: application/json"));
Response¶
If successful:
{
"has_error": false,
"messages": [ ],
"pagination": {
"row_count": 1,
"page_size": 100,
"current_page": 1,
"max_page": 1,
"first_displayed_page": 1,
"last_displayed_page": 1
},
"results": [
{
"id": 3,
"project_id": 1,
"name": "John Doe",
"crm_type_id": 1,
"title": null,
"company": null,
"avatar": null,
"email": null,
"website": null,
"address": null,
"queue_position": null,
"direct_line": null,
"skip_welcome": null,
"skip_enter_queue": null,
"monitor_option": null,
"language": "ro",
"we_are_recording_message": "asdasda",
"assigned_user_id": null,
"comments": null,
"created": "2018-01-04 13:39:26",
"last_updated": "2024-07-03 12:25:02",
"start_date": null,
"end_date": null,
"call_parameters": null,
"source": null,
"source_uniqueid": null,
"source_inbound_route_id": null,
"added_by": null,
"parser_id": null,
"parser_md5": null,
"remote_id": null,
"purge_date": null,
"lock_flag": null,
"status": "active",
"telephones": [
"0712345678"
],
"added_by_name": null,
"assigned_user_name": null,
"assigned_user_email": null,
"parser_name": null,
"project_name": "Test project",
"custom_fields": {
"8": {
"id": 8,
"crm_type_id": 1,
"name": "Company",
"description": "Company name",
"type": "string",
"value": "Acme SRL"
}
}
}
]
}
Or in case of error:
{
"has_error": true,
"messages": [
"Invalid filter: project_idxx"
],
"pagination": [ ],
"results": [ ]
}
Available in other languages: RO