API recipes: ten common tasks in curl, JavaScript and PHP
developers-api-recipesOn this page
Copy-paste curl, JavaScript and PHP for the ten most common API tasks: a token, jobs, contacts, visits, sync, payments, statuses and webhooks.
Ten requests you'll use most, ready to copy, each in three tabs: curl, JavaScript (fetch) and PHP (Guzzle). $SKEDULER_API is your Skeduler API address (ask Skeduler support if you don't have it), $CLIENT_ID and $CLIENT_SECRET are your app's, and $ACCESS_TOKEN comes from recipe 1.
In the JavaScript and PHP tabs, the same names in capitals are variables you set. Replace the other capitals, such as JOB_ID, with your own values. Nothing here is a real key. Each recipe names the scope your app needs.
1. Get an access token
Swap your app's client id and secret for a token that lasts an hour. No scope needed.
curl
curl -s -X POST "$SKEDULER_API/api/v1/oauth/token" \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-d grant_type=client_credentials
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/oauth/token`, {
method: "POST",
headers: {
Authorization: `Basic ${btoa(`${CLIENT_ID}:${CLIENT_SECRET}`)}`,
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({ grant_type: "client_credentials" }),
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "$SKEDULER_API/api/v1/oauth/token", [
'auth' => [$CLIENT_ID, $CLIENT_SECRET],
'form_params' => ['grant_type' => 'client_credentials'],
]);
$data = json_decode((string) $res->getBody(), true);
Use the access_token from the answer as ACCESS_TOKEN. See Get and use an access token.
2. List jobs
Scope: read:jobs.
curl
curl -s "$SKEDULER_API/api/v1/jobs?per_page=25&page=1" \
-H "Authorization: Bearer $ACCESS_TOKEN"
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/jobs?per_page=25&page=1`, {
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', "$SKEDULER_API/api/v1/jobs?per_page=25&page=1", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
],
]);
$data = json_decode((string) $res->getBody(), true);
3. Find a contact by email
Scope: read:contacts. Do this before you create one, so you don't make a duplicate.
curl
curl -s "$SKEDULER_API/api/v1/contacts?email=sam@example.com" \
-H "Authorization: Bearer $ACCESS_TOKEN"
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/contacts?email=sam@example.com`, {
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', "$SKEDULER_API/api/v1/contacts?email=sam@example.com", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
],
]);
$data = json_decode((string) $res->getBody(), true);
4. Create a contact (a customer)
Scope: write:contacts. A contact's id is the customer_id a job takes.
curl
curl -s -X POST "$SKEDULER_API/api/v1/contacts" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: A_NEW_UNIQUE_KEY" \
-d '{"first_name":"Sam","last_name":"Taylor","email":"sam@example.com","mobile_phone":"0400 000 000"}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/contacts`, {
method: "POST",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": "A_NEW_UNIQUE_KEY",
},
body: JSON.stringify({ first_name: "Sam", last_name: "Taylor", email: "sam@example.com", mobile_phone: "0400 000 000" }),
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "$SKEDULER_API/api/v1/contacts", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
'Idempotency-Key' => 'A_NEW_UNIQUE_KEY',
],
'json' => ['first_name' => 'Sam', 'last_name' => 'Taylor', 'email' => 'sam@example.com', 'mobile_phone' => '0400 000 000'],
]);
$data = json_decode((string) $res->getBody(), true);
See Customers or contacts, which endpoint do I use?.
5. Create a job
Scope: write:jobs. Only title is required.
curl
curl -s -X POST "$SKEDULER_API/api/v1/jobs" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: A_NEW_UNIQUE_KEY" \
-d '{"title":"Hot water system repair","customer_id":"CONTACT_ID","address_line_1":"12 Example Street","city":"Brisbane","state":"QLD","postal_code":"4000"}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/jobs`, {
method: "POST",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": "A_NEW_UNIQUE_KEY",
},
body: JSON.stringify({ title: "Hot water system repair", customer_id: "CONTACT_ID", address_line_1: "12 Example Street", city: "Brisbane", state: "QLD", postal_code: "4000" }),
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "$SKEDULER_API/api/v1/jobs", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
'Idempotency-Key' => 'A_NEW_UNIQUE_KEY',
],
'json' => ['title' => 'Hot water system repair', 'customer_id' => 'CONTACT_ID', 'address_line_1' => '12 Example Street', 'city' => 'Brisbane', 'state' => 'QLD', 'postal_code' => '4000'],
]);
$data = json_decode((string) $res->getBody(), true);
6. Book a visit on a job
Scope: write:visits. job_id, start_at and end_at are required. Find a technician_id with GET /technicians. Send "dispatch": true when the technician should see the visit now: it defaults to false, and a visit that isn't dispatched stays off their phone. See My technician can't see a visit I booked.
curl
curl -s -X POST "$SKEDULER_API/api/v1/visits" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: A_NEW_UNIQUE_KEY" \
-d '{"job_id":"JOB_ID","technician_id":"TECHNICIAN_ID","start_at":"2026-11-03T01:00:00+00:00","end_at":"2026-11-03T03:00:00+00:00","dispatch":true}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/visits`, {
method: "POST",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": "A_NEW_UNIQUE_KEY",
},
body: JSON.stringify({ job_id: "JOB_ID", technician_id: "TECHNICIAN_ID", start_at: "2026-11-03T01:00:00+00:00", end_at: "2026-11-03T03:00:00+00:00", dispatch: true }),
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "$SKEDULER_API/api/v1/visits", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
'Idempotency-Key' => 'A_NEW_UNIQUE_KEY',
],
'json' => ['job_id' => 'JOB_ID', 'technician_id' => 'TECHNICIAN_ID', 'start_at' => '2026-11-03T01:00:00+00:00', 'end_at' => '2026-11-03T03:00:00+00:00', 'dispatch' => true],
]);
$data = json_decode((string) $res->getBody(), true);
See Create a job and book a visit from your own system.
7. Sync what changed since a date
Scope: read:jobs (the same works on the other lists). The first call takes updated_since. Each answer has a meta.next_cursor: send it as cursor next time.
curl
curl -s "$SKEDULER_API/api/v1/jobs?updated_since=2026-11-01T00:00:00Z" \
-H "Authorization: Bearer $ACCESS_TOKEN"
curl -s "$SKEDULER_API/api/v1/jobs?cursor=NEXT_CURSOR" \
-H "Authorization: Bearer $ACCESS_TOKEN"
JavaScript (fetch)
const headers = { Authorization: `Bearer ${ACCESS_TOKEN}` };
const first = await fetch(`${SKEDULER_API}/api/v1/jobs?updated_since=2026-11-01T00:00:00Z`, { headers });
const firstPage = await first.json();
// Next time, send the cursor you kept: firstPage.meta.next_cursor
const next = await fetch(`${SKEDULER_API}/api/v1/jobs?cursor=NEXT_CURSOR`, { headers });
const nextPage = await next.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$headers = ['Authorization' => "Bearer $ACCESS_TOKEN"];
$res = $client->request('GET', "$SKEDULER_API/api/v1/jobs?updated_since=2026-11-01T00:00:00Z", ['headers' => $headers]);
$firstPage = json_decode((string) $res->getBody(), true);
// Next time, send the cursor you kept: $firstPage['meta']['next_cursor']
$res = $client->request('GET', "$SKEDULER_API/api/v1/jobs?cursor=NEXT_CURSOR", ['headers' => $headers]);
$nextPage = json_decode((string) $res->getBody(), true);
See Keep your system in sync with sync mode and cursors.
8. Record a payment on an invoice
Scope: write:payments. The Idempotency-Key header is required here. Money is in cents.
curl
curl -s -X POST "$SKEDULER_API/api/v1/invoices/INVOICE_ID/payments" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: A_NEW_UNIQUE_KEY" \
-d '{"amount_cents":15000,"method":"bank_transfer","paid_on":"2026-11-03"}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/invoices/INVOICE_ID/payments`, {
method: "POST",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": "A_NEW_UNIQUE_KEY",
},
body: JSON.stringify({ amount_cents: 15000, method: "bank_transfer", paid_on: "2026-11-03" }),
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "$SKEDULER_API/api/v1/invoices/INVOICE_ID/payments", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
'Idempotency-Key' => 'A_NEW_UNIQUE_KEY',
],
'json' => ['amount_cents' => 15000, 'method' => 'bank_transfer', 'paid_on' => '2026-11-03'],
]);
$data = json_decode((string) $res->getBody(), true);
See Record a payment on an invoice.
9. Change a job's status
Scope: write:jobs. Send the name of one of your business's job statuses.
curl
curl -s -X PATCH "$SKEDULER_API/api/v1/jobs/JOB_ID/status" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: A_NEW_UNIQUE_KEY" \
-d '{"status":"Completed"}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/jobs/JOB_ID/status`, {
method: "PATCH",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": "A_NEW_UNIQUE_KEY",
},
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' => 'A_NEW_UNIQUE_KEY',
],
'json' => ['status' => 'Completed'],
]);
$data = json_decode((string) $res->getBody(), true);
10. Subscribe to a webhook
Scope: the event's read scope, such as read:jobs for job.created; without it the call answers 403 insufficient_scope. Skeduler posts to your target_url each time the event happens. Keep the signing_secret from the answer to check each delivery.
curl
curl -s -X POST "$SKEDULER_API/api/v1/webhooks/subscriptions" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: A_NEW_UNIQUE_KEY" \
-d '{"event":"job.created","target_url":"https://example.com/skeduler/webhook"}'
JavaScript (fetch)
const res = await fetch(`${SKEDULER_API}/api/v1/webhooks/subscriptions`, {
method: "POST",
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": "A_NEW_UNIQUE_KEY",
},
body: JSON.stringify({ event: "job.created", target_url: "https://example.com/skeduler/webhook" }),
});
const data = await res.json();
PHP (Guzzle)
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "$SKEDULER_API/api/v1/webhooks/subscriptions", [
'headers' => [
'Authorization' => "Bearer $ACCESS_TOKEN",
'Idempotency-Key' => 'A_NEW_UNIQUE_KEY',
],
'json' => ['event' => 'job.created', 'target_url' => 'https://example.com/skeduler/webhook'],
]);
$data = json_decode((string) $res->getBody(), true);
To handle a delivery, check its signature first. See Verify webhook signatures.
Use a new key for each write
A_NEW_UNIQUE_KEY stands for a fresh value, such as a random UUID, for each write. Send the same one again only when you retry that same request. See Safe retries with idempotency keys.