Training
For clients
Загружается...
The resource enables user to get data on existing agency clients and create new ones.
Available only to the users with agency accounts.
Used object: AgencyClient
The request returns a list of all agency clients.
Request example:
GET /api/v2/agency/clients.json
Additional GET parameters:
The following GET parameters enable you to filter data:
Example of a request with additional parameters:
GET /api/v2/agency/clients.json?limit=50&offset=100&_user__username=Vasily Ivanov
Response example:
{ "count": 1, "items": [ { "access_type": "full_access", "status": "active", "user": { "account": { "id": 17668, "balance": 3000, "a_balance": 0, "type": "physical", "currency_balance_hold": 300, }, "additional_emails": ["test@mail.ru"], "additional_info": { "name": "Vasily Ivanov", "email": "test@example.com", "phone": "89153724330", "address": "", "client_info": "Note", "client_name": "Vasily Ivanov", }, "id": 17668, "status": "active", "username": "Vasily Ivanov", }, }, ... ], "limit": 20, "offset": 0 }
The request creates a new client or adds an existing one to the list of agency clients. To add an existing client, their account must meet the following requirements:
Example of a request for creating a new client:
POST /api/v2/agency/clients.json { "access_type":"full_access", "user": { "additional_emails": ["test@mail.ru"], "additional_info": { "client_info": "Note", "client_name": "Vasily Ivanov", } } }
Example of a request for adding an existing client to a client list:
POST /api/v2/agency/clients.json { "access_type":"full_access", "user": { "id":17668, "additional_emails": ["test@mail.ru"], "additional_info": { "client_info": "Note", "client_name": "Vasily Ivanov", } } }
POST /api/v2/agency/clients.json { "access_type":"full_access", "user": { "username":"client_username", "additional_emails": ["test@mail.ru"], "additional_info": { "client_info": "Note", "client_name": "Vasily Ivanov", } } }
Response example:
{ "user": { "id":17668, "username":"client_username" } }
Response status codes:
200 - The client was successfully added to the client list.
400 - One of the following errors occurred:
404 - The client with the specified ID does not exist.
Error example(s):
{"error": {"code": "validation_failed", "fields": { <fields with errors\> }}} - Data error. {"error": {"fields": {"user": {"code": "invalid_user", "message": "Cant join agency"}}}} - An attempt to add a client that is already assigned to an agency. {"error": {"fields": {"user": {"code": "invalid_user", "message": "Different currency for agency and client"}}}} - At attempt to add a client whose currency differs from the agency's. {"error": {"fields": {"additional_emails": {"code": "duplicate_value", "message": "Additional emails contain the main user email"}}, "message": "Validation failed", "code": "validation_failed"}} - At attempt to add the same additional email as the main user email.