Batch
The batch API enables you to process several API requests in a row, along one single authentication.
POST https://api.agendize.com/api/2.0/batch
For instance, you can create three services at one location:
{
"requests": [
{
"path": "/api/2.1/scheduling/companies/000000/services",
"method": "POST",
"body": {
"name":"Service 1"
}
},
{
"path": "/api/2.1/scheduling/companies/000000/services",
"method": "POST",
"body": {
"name":"Service 2"
}
},
{
"path": "/api/2.1/scheduling/companies/000000/services",
"method": "POST",
"body": {
"name":"Service 3"
}
}
]
}
You can of course use distinct types of API requests in one single batch ; for instance, you can create a new service and retrieve a list of appointments:
{
"requests": [
{
"path": "/api/2.1/scheduling/companies/000000/services",
"method": "POST",
"body": {
"name":"service 1"
}
},
{
"path": "/api/2.1/scheduling/companies/000000/appointments",
"method": "GET"
}
]
}
It is also possible to use the resulting ID of an API request previously used in the same batch, so that you can refer to it:
{
"requests": [
{
"path": "/api/2.1/scheduling/companies",
"method": "POST",
"body": {
"name": "My Location"
}
},
{
"path": "/api/2.1/scheduling/companies/{id}/services",
"method": "POST",
"body": {
"name": "My Service"
}
},
{
"path": "/api/2.1/scheduling/companies/{company.id}/staff",
"method": "POST",
"body": {
"firstName": "John",
"lastName": "Doe",
"services": [
{
"id": "{id}"
}
]
}
}
]
}
The first API request creates a location, and its ID is used in the second API request to populate the newly created location with a new service. Finally, the third API request creates a new staff and assigns it to the new service at that location.
You can also use nest batches to reflect the sequence of requests:
{
"requests": [
{
"path": "/api/2.1/scheduling/companies",
"method": "POST",
"body": {
"name": "My Location"
},
"requests" : [
{
"path": "/api/2.1/scheduling/companies/{id}/services",
"method": "POST",
"body": {
"name": "My Service"
}
},
{
"path": "/api/2.1/scheduling/companies/{id}/staff",
"method": "POST",
"body": {
"lastName": "Smith"
}
}
]
}
]
}