Change a job's status
developers-change-job-statusOn this page
Send the status name to PATCH /jobs/{id}/status. Take valid names from /job-lookups.
Your app needs write:jobs (and read:jobs to look up the names). In the examples, $SKEDULER_API is your Skeduler API address. Contact Skeduler support if you don't have it. In the JavaScript and PHP tabs, the same names in capitals (SKEDULER_API, ACCESS_TOKEN and so on) are variables you set.
Who can do this: Owners and Admins with the Manage Developer Tools permission.
1. Find the status names
curl
curl -s "$SKEDULER_API/api/v1/job-lookups" -H "Authorization: Bearer $ACCESS_TOKEN"
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/job-lookups`, {
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', "$SKEDULER_API/api/v1/job-lookups", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
],
]);
$data = json_decode((string) $res->getBody(), true);
job_statuses lists the organisation's active statuses in its own order. Archived ones are left out. Use the status's name, for example Completed.
2. Change the status
curl
curl -s -X PATCH "$SKEDULER_API/api/v1/jobs/$JOB_ID/status" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" \
-d '{"status":"Completed"}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/jobs/${JOB_ID}/status`, {
method: "PATCH",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Idempotency-Key": crypto.randomUUID(),
"Content-Type": "application/json",
},
body: JSON.stringify({"status": "Completed"}),
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('PATCH', "$SKEDULER_API/api/v1/jobs/$JOB_ID/status", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
'Idempotency-Key' => bin2hex(random_bytes(16)),
],
'json' => ['status' => 'Completed'],
]);
$data = json_decode((string) $res->getBody(), true);
The answer is the updated job, with status showing the new name, for example Completed.
If it fails
422 validation_failed: the name isn't one of the organisation's active statuses. Check the spelling againstjob_statuses.404 not_found: no such job in your organisation (an archived job looks the same).403 insufficient_scope: your app lackswrite:jobs. See The API says insufficient_scope.
Statuses are the organisation's own, so names can differ between businesses. Look them up rather than hard-coding them.
Related
In this section
- Create a job and book a visit from your own system
- Push leads from your website into Skeduler
- Read a job's notes
- Read technicians' leave and time blocks
- Record a payment on an invoice
- API reference
- Authentication API
- Contacts API
- Credit Notes API
- Customers API
- Estimates API
- Invoices API
- Jobs API
- Payments API
- Schedule blocks API
- Technicians API
- Visits API
- Webhooks API
- Customers or contacts, which endpoint do I use?