Use the api_get_users_json function to get a list of all Proxima Cloud CRM users, or only the users you need, in JSON format.
Note: The API doesn't return the list right away. The first request only starts a job on the server and returns its number (job_id). To get the list, you send two more requests: one to check that the job is finished, and one to download the result.
How it works
| Step | Request | What you get |
|---|---|---|
| 1 | POST /crm-api/db-function/run |
The job number: {"job_id": 115667}
|
| 2 | GET /crm-api/db-function/status/{job_id} |
The job status and the number of batches. Wait for "status": 3 (finished). |
| 3 | GET /crm-api/db-function/result/{job_id}?batch=1 |
The list of users as a JSON array. Repeat for each batch. |
Before you start
- Get a token. See Authentication (Login).
- Add the token to every request in this article:
Authorization: Bearer <token>. - Replace
yourdomainin the URLs with your company's Proxima Cloud CRM domain.
Step 1. Start the job
POST https://yourdomain.pharmahrm.com/crm-api/db-function/run
Headers
| Header | Value |
|---|---|
Authorization |
Bearer <token> |
Content-Type |
application/json |
Body: all users
{
"function": "api_get_users_json",
"format": "json"
}Body: only some users
To get only specific users, add their IDs in arguments:
{
"function": "api_get_users_json",
"format": "json",
"arguments": {
"ids": "3,4,12"
}
}Note: ids is a filter. If you copy an example with ids, you get only those users. To get all users, leave out arguments.
| Field | Type | Required | Description |
|---|---|---|---|
function |
string | Yes | Always api_get_users_json. |
format |
string | Yes | Always json. To get the list as a CSV table, see Get a list of users (CSV). |
arguments |
object | No | Filters. Leave it out to get all users. |
arguments.ids |
string | No | User IDs, separated by commas, for example "3,4,12". |
Response
{
"job_id": 115667
}Save the job_id. You need it in steps 2 and 3.
Step 2. Check the job status
GET https://yourdomain.pharmahrm.com/crm-api/db-function/status/115667
Replace 115667 with your job_id. The request has no body.
Response
{
"id": 115667,
"status": 3,
"batch_count": 1
}| Field | Description |
|---|---|
id |
The job number. |
status |
1: Pending. 2: Running. Wait a few seconds and check again.3: Finished. Go to step 3.4: Error. Start a new job. If it fails again, contact technical support. |
batch_count |
How many batches the result has. One batch holds up to 500 users. |
For details, see Get Data Generation Job Status.
Step 3. Get the list of users
GET https://yourdomain.pharmahrm.com/crm-api/db-function/result/115667?batch=1
Replace 115667 with your job_id. The request has no body.
| Parameter | Type | Required | Description |
|---|---|---|---|
batch |
integer | Yes | The batch number, from 1 to batch_count. |
Batches
The server splits a JSON result into batches of up to 500 users. To get the whole list, request each batch:
- If
batch_countis1, send one request withbatch=1. - If
batch_countis3, send three requests:batch=1,batch=2andbatch=3. Then join the three arrays.
Response
The result is a JSON array. Each object is one user:
[
{
"name": "Ivan Petrov",
"role": "USER_UA",
"active": 0,
"region": ["Київська", "Житомирська"],
"country": "Україна",
"manager": "Olena Kovalenko",
"user_id": 12,
"position": "Medical Representative",
"direction": ["OTC_UA", "RX_UA"],
"workenddate": null,
"workstartdate": "2022-05-01"
},
{
"name": "rtc-user",
"role": "ROLE_RTC_USER",
"active": 0,
"region": null,
"country": null,
"manager": null,
"user_id": 3,
"position": null,
"direction": null,
"workenddate": null,
"workstartdate": "2022-03-11"
}
]Note: Postman may show the result as HTML on one long line. To make it readable, above the response, change HTML to JSON.
For details, see Get Data Generation Job Result.
Fields
| Field | Type | Description |
|---|---|---|
name |
string | The user's full name. |
role |
string | The user's system role, for example USER_UA or ROLE_ADMIN. |
active |
integer |
0: active. 1: inactive. |
region |
array of strings or null | The regions where the user works. |
country |
string or null | The country where the user works. |
manager |
string or null | The name of the user's direct manager. |
user_id |
integer | The user's ID in Proxima Cloud CRM. Use it in the ids filter. |
position |
string or null | The user's job title. |
direction |
array of strings or null | The user's product directions. |
workenddate |
string or null | The date the user's work ends (YYYY-MM-DD). |
workstartdate |
string or null | The date the user started work (YYYY-MM-DD). |
null means the field has no value. Some values, such as country and region, are in the CRM language.
Errors
If a request fails, the server returns a 4xx or 5xx status code with a message:
{
"message": "Error message"
}| Problem | What to do |
|---|---|
| 401 Unauthorized | The token is missing or expired. Get a new token. See Authentication (Login). |
| Fewer users than expected | Check whether the request body has an ids filter. Also check batch_count: you may need to request more batches. |
| Step 3 returns an error | The job may not be finished yet, or the batch number is larger than batch_count. Check the status (step 2). |
| 5xx | A server error. Try again later. If it repeats, contact technical support. |