API request
Preparing source data
Prepare source data in JSON format, taking into account its features and restrictions.
Use the parameters described in the Parameter list section. Make sure that the required parameters are included in the request: to learn which parameters are mandatory, see the list.
| Object/array | Description | Required |
|---|---|---|
locations |
Location parameters | Yes |
employees |
Employees and vehicles | Yes |
options |
Global options | Yes |
zones |
Geofences | No |
JSON structure
{
"locations": [
// Describes locations.
],
"employees": [
// Describes mobile employees.
],
"options": {
// Describes planning options.
},
"zones": [
// Describes geofences (optional object).
]
}
API request
Sample request for the cURL command line utility with authorization via an API key:
curl -H "Content-Type: application/json" -X POST -d <request_body> https://courier.yandex.com/vrs/api/v1/calendar_planning/tasks?apikey=<your_API_key>
In the request string parameters, replace <your_API_key> with the actual API key you obtained.
Replace <request body> with your source data in JSON format. For files, use the @ prefix. For example, @task.json.
The response should be:
202 Accepted
{
"id": "task_id",
"status": "queued",
"message": "Task queued"
}
Request parameters
| Parameter name | Type | Description |
|---|---|---|
apikey |
string | API access key |
lang |
string | Request language |
Response parameters
| Parameter name | Type | Description |
|---|---|---|
id |
string | Unique task ID |
status |
object | Object containing the task status history |
message |
string | Text message about the task status |
Response codes
| Code | Description |
|---|---|
202 |
The request is being processed |
400 |
The API key doesn't match the key specified in the task |
401 |
Missing API key |
402 |
The API key is blocked |
422 |
Invalid request body structure |
429 |
Too many requests |
500 |
Server error during request processing |
Stopping a planning task
To stop a planning task that's still in progress, send a request to the cancel resource.
In the request, specify:
id: Task ID.apikey: The API key specified in the company settings. For more information about API keys, see API key.
Request:
curl -X POST https://courier.yandex.com/vrs/api/v1/calendar_planning/tasks/<task-id>/cancel?apikey=<company-API-key> -H "Content-Type: application/json" -H "Authorization: OAuth <your-OAuth-token>"
Analyzing the resulting solution
Typical errors returned by the API request are described in the Error handling section.