Documentation menu

Developer API

Quickstart

Five calls from a fresh token to a lead you created through the API. Every other resource works the same way.

1. Create a token

In the app open AI and Automation → API Tokens, press Create token, tick Leads · Read & write, and copy the token. Put it in an environment variable:

export DJC_TOKEN="djc_…"

Details: Authentication & tokens.

2. Check it with /me

curl https://api2.djcsystem.com/v1/me -H "Authorization: Bearer $DJC_TOKEN"
Response
{ "success": true, "data": { "email": "jane@example.com", "tokenKind": "token",
  "scopes": ["leads:write"], "resources": { "leads": "write", "chatrooms": null, "…": null } } }

A 401 here means the token is wrong, revoked or expired. resources tells you what this token may do — for a lead-writing token, leads must say write.

3. Discover the resources

curl https://api2.djcsystem.com/v1/resources -H "Authorization: Bearer $DJC_TOKEN"

The response describes every resource: fields with types and required flags, which fields you can filter and sort by, and short guidance notes. It is the same information as the Resources reference, in a form a program can read.

4. Your first read

curl "https://api2.djcsystem.com/v1/leads?limit=5&sort=created:desc" -H "Authorization: Bearer $DJC_TOKEN"
Response
{ "success": true, "limit": 5, "nextCursor": "eyJ…",
  "data": [ { "id": "k3Jd…", "name": "Aisha Rahman", "phone": "60123456789", "status": "new", "created": "2026-09-04T02:15:31.000Z", "…": "…" } ] }

Pass cursor=<nextCursor> to get the next page. See Requests, filters & paging.

5. Your first write

curl -X POST https://api2.djcsystem.com/v1/leads \
  -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "name": "Ben Tan", "phone": "60198765432", "source": "API", "tags": ["partner-referral"] }'
Response
201 { "success": true, "data": { "id": "p9Qa…", "name": "Ben Tan", "phone": "60198765432", "source": "API",
  "tags": ["partner-referral"], "ownerEmail": "jane@example.com", "created": "2026-09-04T03:20:05.000Z", "…": "…" } }

Notice the fields you did not send: ownerEmail and created were set by the API. Ownership fields are always server-owned — sending them is rejected with 400.

Change it with a partial update:

curl -X PATCH https://api2.djcsystem.com/v1/leads/p9Qa… \
  -H "Authorization: Bearer $DJC_TOKEN" -H "Content-Type: application/json" \
  -d '{ "status": "contacted" }'

Look before you create

Most integrations should check for an existing record first, for example GET /leads?filter[phone]=60198765432, to avoid duplicates. The catalog's notes say what to check for each resource.

The same in JavaScript

Node 18+ / any modern runtime
const BASE = "https://api2.djcsystem.com/v1";
const headers = { Authorization: `Bearer ${process.env.DJC_TOKEN}`, "Content-Type": "application/json" };

const me = await fetch(`${BASE}/me`, { headers }).then((r) => r.json());
if (me.data.resources.leads !== "write") throw new Error("Token needs leads:write");

const created = await fetch(`${BASE}/leads`, {
  method: "POST",
  headers,
  body: JSON.stringify({ name: "Ben Tan", phone: "60198765432", source: "API" }),
}).then((r) => r.json());

if (!created.success) throw new Error(`${created.code}: ${created.error}`);
console.log("created lead", created.data.id);

Next steps