Use the api_get_users function to get a list of all Proxima Cloud CRM users, or only the users you need, as a CSV table.
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": 115665}
|
| 2 | GET /crm-api/db-function/status/{job_id} |
The job status. Wait for "status": 3 (finished). |
| 3 | GET /crm-api/db-function/result/{job_id} |
The list of users as CSV text. |
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",
"format": "csv"
}Body: only some users
To get only specific users, add their IDs in arguments:
{
"function": "api_get_users",
"format": "csv",
"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. |
format |
string | Yes | Always csv. To get the list as JSON, see api_get_users_json. |
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": 115665
}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/115665
Replace 115665 with your job_id. The request has no body.
Response
{
"id": 115665,
"status": 3,
"batch_count": null
}| status | Meaning | What to do |
|---|---|---|
1 |
Pending | The job is in the queue. Wait a few seconds and check again. |
2 |
Running | The job is in progress. Wait a few seconds and check again. |
3 |
Finished | Go to step 3. |
4 |
Error | The job failed. Start a new job (step 1). If it fails again, contact technical support. |
For CSV jobs, batch_count is always null. The whole list comes in one response. 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/115665
Replace 115665 with your job_id. The request has no body.
Response
The list comes as plain CSV text. The first line has the column names. Each next line is one user.
name,manager,country,region,direction,position,active,user_id,workstartdate,workenddate,role Ivan Petrov,Olena Kovalenko,Україна,"Київська,Житомирська","Rx,OTC",Medical Rep,0,12,2022-05-01,,ROLE_USER rtc-user,,,,,,0,3,2022-03-11,,ROLE_RTC_USER
How to read it:
- Values are separated by commas.
- Two commas in a row (
,,) mean an empty field. For example,rtc-userhas no manager, country or region. - Values in quotes can contain commas. For example,
"Київська,Житомирська"is one field with two regions. - Some values, such as country and region, are in the CRM language.
For details, see Get Data Generation Job Result.
Open the list as a table
CSV text is hard to read in Postman. To view it as a table:
- In Postman, above the response, click Save Response and then Save to a file.
- Save the file with the
.csvextension, for exampleusers.csv. - In Excel, go to Data > From Text/CSV, select the file, set File Origin to 65001: Unicode (UTF-8) and Delimiter to Comma, and then click Load.
Note: If you open the file with a double-click, Excel may show Cyrillic text as unreadable characters. Use From Text/CSV with UTF-8 instead.
Fields
| Field | Description |
|---|---|
name |
The user's full name. |
manager |
The user's direct manager. |
country |
The country where the user works. |
region |
The regions where the user works. Several regions are in one quoted field. |
direction |
The user's product directions. Several directions are in one quoted field. |
position |
The user's job title. |
active |
0: active. 1: inactive. |
user_id |
The user's ID in Proxima Cloud CRM. Use it in the ids filter. |
workstartdate |
The date the user started work (YYYY-MM-DD). |
workenddate |
The date the user's work ends (YYYY-MM-DD). Empty if not set. |
role |
The user's system role, for example ROLE_USER or ROLE_ADMIN. |
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. Remove arguments to get all users. |
| Step 3 returns an error | The job may not be finished yet. Check the status (step 2) and wait for "status": 3. |
| 5xx | A server error. Try again later. If it repeats, contact technical support. |