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
| Item | Value |
|---|---|
| Base URL | https://api.d2scheduling.com (no /api prefix) |
| Format | JSON over HTTPS |
| Authentication | Bearer token from POST /auth/login |
| Tenant header | x-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. |
| Roles | Reads: admin, planner, operator or viewer (not the vendor role). Promise edits and Notes writes: admin or planner. |
| Rate limits | Per calling IP address: 60 requests a minute overall, 5 logins a minute, 10 token refreshes a minute. Over a limit → 429. |
| Callers | Server-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:
| Field | What it holds |
|---|---|
id | The line's D² UUID (the polId that §5 needs) |
poNo | The PO number |
lineNo | OrderTime's line number |
partNo | The part number (OrderTime's item name) |
description | The line description |
vendorPartNo | The vendor's part number, when OrderTime has one |
quantity, receivedQty, qtyRemaining | Ordered, received, still open |
unitCost | Unit cost |
isClosed | Whether OrderTime has closed the line |
externalId | OrderTime's line Id, as a string: the most reliable key for matching a line back to OrderTime |
plannerNotes | Notes: yours to write (§5) |
vendorNotes | Vendor Notes: read-only for this integration |
lastSyncedAt | When 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
| Code | Meaning | What to do |
|---|---|---|
| 400 | Malformed request (the message states the exact problem) | Fix and retry |
| 401 | Missing/expired token | Refresh, or log in again |
| 403 | Role not allowed (writes need admin/planner), or an x-tenant-id that does not match your login | Use an authorized account, or drop the header |
| 404 | PO / line not found in D² | Check the id |
| 429 | Rate limit reached (§1) | Wait a minute and retry |
| 502 | OrderTime rejected a promise edit — D² unchanged | Message carries OT's words |
7. Good citizenship
- Writes are audited (who, what, when) — individual accounts, not shared logins.
- A read-only integration should make only GET calls; an admin or planner login can also change promise dates, which writes OrderTime.
- Keep credentials out of code and sheets (in Google Apps Script, Script Properties).
- OrderTime remains the record for OT-fed fields; sync echoes win, drift indicators flag material movements.
- The promise endpoint accepts only its two fields; notes endpoints only theirs — anything else is rejected.
Questions: support@d2scheduling.com