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
Below is a sample request for the cURL command-line utility.
curl -X POST "https://courier.yandex.com/vrs/api/v1/calendar_planning/tasks?apikey=<my-api-key>" -d @task.json
where my-api-key is the API key.
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 |
Stop a planning task
To stop a planning task before its completion, send a request to the cancel resource.
Specify in the request:
id— task ID;apikey— API key that is specified in the company settings. For more about API keys, see the section API key.
Request:
curl -X POST https://courier.yandex.com/vrs/api/v1/calendar_planning/tasks/<task-id>/cancel?apikey=<API-key-company> -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.
Was the article helpful?
Previous