Skip to main content

Examples

These examples show how to handle common tasks with the JavaScript and TypeScript SDK. The flow is the same as in the .NET and Python SDKs:

  1. Build the typed entity (or array of entities).
  2. Call the matching accessor on the client.
  3. Branch on response.ok / error.

Create a category​

import DimeSchedulerClient, { Environment } from "@dimescheduler/sdk";
import type { Category } from "@dimescheduler/sdk/models";

const client = new DimeSchedulerClient({
apiKey: "MY_API_KEY",
environment: Environment.Sandbox,
});

const category: Category = { name: "VIP", displayName: "VIP customer", color: "#22d3ee" };
const { data, error } = await client.categories.create(category);
if (error) throw new Error(JSON.stringify(error));

Create a job and its first task​

Every taskTaskA unit of work that belongs to a job. It appears in the open task list until it is scheduled to a resource. belongs to a jobJobA high-level container, comparable to a project, that bundles related tasks together with common information such as customer, billing, and address., so send the job first, then the task:

import type { Job, Task } from "@dimescheduler/sdk/models";

const sourceApp = "BC_CRONUS";
const sourceType = "SERVICE";
const jobNo = "SO001";

const job: Job = {
sourceApp,
sourceType,
jobNo,
shortDescription: "Repair HVAC at HQ London",
};
await client.jobs.create(job);

const task: Task = {
sourceApp,
sourceType,
jobNo,
taskNo: "SO001_LINE10",
shortDescription: "Replace compressor",
};
await client.tasks.create(task);

To create several at once, pass an array:

await client.tasks.create([task1, task2, task3]);

Update the live location of a resource​

await client.resourceGpsTrackings.create({
resourceNo: "GEOFFREY",
latitude: 52.372746,
longitude: 4.893086,
});

Read appointments for a date range​

const { data } = await client.appointments.get(
new Date("2026-05-01T00:00:00Z"),
new Date("2026-05-31T23:59:59Z"),
["GEOFFREY", "JOHNNY"],
);

for (const a of data ?? []) {
console.log(a.appointmentNo, a.startDate);
}

Send a fly-in message to online users​

Severity is numeric: 0 Verbose, 1 Debug, 2 Info, 3 Warning, 4 Error, 5 Fatal.

await client.messages.send({
text: "Heads up - planning board reload in 5 minutes.",
severity: 3, // Warning
});

Lock an appointment​

The narrow appointmentLocked accessor changes only the lock state:

await client.appointmentLocked.create({
sourceApp: "BC_CRONUS",
sourceType: "SERVICE",
appointmentGuid: "2a77f6c6-c502-4ad2-9ee2-6fba0f9361a1",
locked: true,
});

You'll find complete, runnable demos in the samples/ directory of the dime-scheduler/sdk repo: live-board (a drag-and-drop board that syncs every drop), ai-scheduler (an LLM that calls the SDK to find slots and book work), slack-and-csv (a Slack command and a CSV bulk importer), update-resource-location (push GPS positions from a map), pingpong (move appointments back and forth) and express (a minimal webhook that creates a job and task). Each runs without an API key in mock mode.