Skip to main content

Examples

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", 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

A task must belong to a job - 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);

Need many 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

await client.messages.send({
text: "Heads up - planning board reload in 5 minutes.",
severity: "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,
});

More examples live alongside the source in the dime-scheduler/sdk repo.