Creating jobs

Last updated 8 months ago

post
Job creation endpoint

https://prod-api.spatula.io
/v2/graph/role/jobs?access_token=AUTH_TOKEN
This endpoint will create a new job in Spatula
Request
Response
Query Parameters
access_token
required
string
API access token
Body Parameters
name
required
string
A short string describing the job
tasks
required
array
Job tasks. Tasks represents stages of progress associated with the job e.g. arrived at restaurant, depart restaurant, arrive at customer location
contact
required
object
Customer information
attr
optional
array
Custom job attributes. Displayed to drivers and dispatchers but hidden in tracking links by default
200: OK
If the request is successful the response body will contain an itemsarray with the newly created objects. The idfield on newly created jobs can be used to update jobs and request their status.
{
"items": [
{
"id": 5788549471,
"created": 1531739884663,
"tracking": "https://example.org/not-a-real-tracking-link",
"contact": {
"phone": "+61234567890",
"name": "Some Customer",
"email": ""
},
"name": "A New Job",
"tasks": {
"items": [
{
"zone": {
"address": "Example Cafe",
"created": 1531739884663,
"name": "Broadway",
"id": 5788549468,
"radius": 50.0,
"coords": {
"lon": 115.814155,
"lat": -31.977832
}
},
"created": 1531739884663,
"id": 5788549470,
"ix": 0
}
]
},
}
]
}

Example POST body

[
{
"name": "My Job",
"contact": {
"name": "Andrew Walker",
"phone": "+61123456789",
"email": "andrew@spatula.io"
},
"tasks": [
{
"zone": {
"name": "Arrive at Cafe Example",
"address": "35 Example Hwy",
"coords": {
"lat": -31.977559,
"lon": 115.816393
}
}
},
{
"zone": {
"name": "Depart Cafe Example",
"address": "35 Example Hwy",
"coords": {
"lat": -31.977559,
"lon": 115.816393
}
}
},
{
"zone": {
"name": "Deliver to Customer",
"address": "123 Fake St",
"coords": {
"lat": -32.977559,
"lon": 114.816393
}
}
}
],
"attr": [
{ "key": "My Metadata Key", "value": "My Metadata Value" }
]
}
]

Example

shell
curl -X POST -d '[{"name":"My Job","contact":{"name":"Andrew Walker","phone":"+61123456789","email":"andrew@spatula.io"},"tasks":[{"zone":{"name":"Arrive at Example","address":"35 Example Hwy","coords":{"lat":-31.977559,"lon":115.816393}}},{"zone":{"name":"Depart Example","address":"35 Example Hwy","coords":{"lat":-31.977559,"lon":115.816393}}},{"zone":{"name":"Deliver to Customer","address":"123 Fake St","coords":{"lat":-32.977559,"lon":114.816393}}}],"attr":[{"key":"My Metadata Key","value":"My Metadata Value"}]}]' 'https://prod-api.spatula.io/v2/graph/role/jobs?access_token=AUTH_TOKEN'