D2D² Schedulerhelp

D² Scheduling — Purchase Order API

End-user integration guide · v1.2 · October 8, 2026 · Aigent Solutions

This guide covers the D² Purchase Order endpoints: reads, the promise-edit endpoint that writes OrderTime in the same action, and the PO Tracker notes fields. Everything here is live in production today.

v1.2 adds what integrators asked for: the line fields, paging, token lifetimes, rate limits, and when the tenant header is needed.

1. Basics

ItemValue
Base URLhttps://api.d2scheduling.com (no /api prefix)
FormatJSON over HTTPS
AuthenticationBearer token from POST /auth/login
Tenant headerx-tenant-id is optional. Your login already names your tenant (user.tenantId in the login response). If you send the header, it must match, or the call returns 403.
RolesReads: admin, planner, operator or viewer (not the vendor role). Promise edits and Notes writes: admin or planner.
Rate limitsPer calling IP address: 60 requests a minute overall, 5 logins a minute, 10 token refreshes a minute. Over a limit → 429.
CallersServer-side callers are fine (scripts, Google Apps Script, scheduled jobs). There is no IP allowlist.

2. Authentication

POST /auth/login
{ "email": "you@company.com", "password": "••••••" }

No tenant header is needed to log in. The response:

{
  "access_token": "...",
  "refresh_token": "...",
  "user": { "id": "...", "email": "...", "name": "...", "role": "planner",
            "tenantId": "...", "vendorName": null, "timezone": "America/Los_Angeles" }
}

Send the access token on every other request:

Authorization: Bearer <access_token>

Lifetimes. The access token lasts 15 minutes. The refresh token lasts 12 hours and works once:

POST /auth/refresh
{ "refresh_token": "..." }

returns a new access_token and a new refresh_token; keep the new one. A session that keeps refreshing ends 7 days after its login (30 for the viewer role). A scheduled job can simply log in at the start of each run, and refresh only if one run lasts longer than 15 minutes.

No/expired token → 401. Insufficient role → 403.

3. Read endpoints

3.1 List purchase orders

GET /purchase-orders?limit=500&offset=0

Highest PO number first, each PO with its line items. limit defaults to 500 and offset to 0. The response is a plain JSON array with no total count: page until a page comes back shorter than limit.

PO fields include id, poNo, vendorNo, vendorName (OrderTime's vendor number and name), orderDate, expectedDate (Promise Date), poNotes (Vendor Promise text), isClosed, status, statusName, dateSent, totalAmount, currency, lastSyncedAt, and lines.

Line fields:

FieldWhat it holds
idThe line's D² UUID (the polId that §5 needs)
poNoThe PO number
lineNoOrderTime's line number
partNoThe part number (OrderTime's item name)
descriptionThe line description
vendorPartNoThe vendor's part number, when OrderTime has one
quantity, receivedQty, qtyRemainingOrdered, received, still open
unitCostUnit cost
isClosedWhether OrderTime has closed the line
externalIdOrderTime's line Id, as a string: the most reliable key for matching a line back to OrderTime
plannerNotesNotes: yours to write (§5)
vendorNotesVendor Notes: read-only for this integration
lastSyncedAtWhen D² last read the line from OrderTime

Dates (orderDate, expectedDate, dateSent) are YYYY-MM-DD. Quantities and amounts arrive as strings, for example "10.0000".

3.2 Open purchase orders only

GET /purchase-orders/open

Every PO OrderTime has not closed, in one response: not paged, no total count. Soonest expectedDate first, each PO with all its lines, closed lines included (check each line's isClosed). Same fields as §3.1.

3.3 Incoming material for a part

GET /purchase-orders/incoming/{partNo}

4. Edit promise fields — writes OrderTime in the same action

PATCH /purchase-orders/{poNo}/promise        (admin or planner)
{ "promiseDate": "2026-10-15", "vendorPromise": "Confirmed w/ vendor 9/1" }

promiseDate: YYYY-MM-DD exactly. vendorPromise: text, max 500 chars (OrderTime custom field POCust1). OrderTime is updated first; only after it accepts does D² update its record and every scheduling dependency — both systems read consistent immediately. On OT rejection you get 502 with OrderTime's own words and D² unchanged.

5. Notes — read and write (PO Tracker "Notes" column)

Notes (plannerNotes) are D²-native planner annotations — they never touch OrderTime. Read them on the line objects (§3.1). Write them per line:

PATCH /wo-components/pol/{polId}/planner-notes        (admin or planner)
{ "plannerNotes": "Called vendor; expedite confirmed" }

polId is the line's id UUID from the §3.1 read. Lines anchored to a work order component instead use the sibling:

PATCH /wo-components/{id}/notes        (admin or planner)
{ "notes": "..." }

Vendor Notes (vendorNotes) are read-only for this integration — write endpoints exist but are role-gated to admin and the vendor-portal role; a planner-credentialed client receives 403 on any write attempt. Treat the field as the vendor's channel, not yours.

6. Errors

CodeMeaningWhat to do
400Malformed request (the message states the exact problem)Fix and retry
401Missing/expired tokenRefresh, or log in again
403Role not allowed (writes need admin/planner), or an x-tenant-id that does not match your loginUse an authorized account, or drop the header
404PO / line not found in D²Check the id
429Rate limit reached (§1)Wait a minute and retry
502OrderTime rejected a promise edit — D² unchangedMessage carries OT's words

7. Good citizenship


Questions: support@d2scheduling.com