ChoiceLink Developers

Order Intake API

Submit orders into ChoiceLink for review and sending to First Choice Metals. Version 1.6.0.

Download OpenAPI 3.1 spec

Overview

The Order Intake API is a server-to-server JSON API for partners to submit orders into ChoiceLink. A submitted order is staged as a normal order with status Pending in the shop bound to your API key. A person at that shop then reviews it and clicks Send to FCM inside ChoiceLink to finalize it.

This API never sends to First Choice Metals on its own. Submitting an order only stages it for human review. Sending always stays a deliberate action taken by a person in the shop.

  • One API key is bound to exactly one shop. Orders you submit land in that shop’s queue.
  • An order holds buildings, item lines, or both, like an order made in ChoiceLink. A building is a package order: you name the shop’s line, package and variation, the colors, serial number and add-ons, and ChoiceLink copies the package’s items in exactly as its order form does (ids from /api/v1/packages). Item lines are custom packages: our item codes and color codes (from /api/v1/catalog).
  • Or send a building in your own words: your model name, size, options and color names. ChoiceLink reads them with the shop’s answers, and a word it doesn’t know yet waits for the shop to answer once (see Buildings in your words).
  • All endpoints live under /api/v1. Base URL: https://v2.choice-link.net.

Quick start

Three steps: confirm your key, pull what you can order, submit an order.

1 — confirm the key and shop readiness
curl -s https://v2.choice-link.net/api/v1/preflight \
  -H "Authorization: Bearer ck_live_…"
2 — pull the lines, packages and add-ons you can order as buildings (or /catalog for item codes)
curl -s https://v2.choice-link.net/api/v1/packages \
  -H "Authorization: Bearer ck_live_…"
3 — submit an order (POST /orders/preview first to check it without staging)
curl -s -X POST https://v2.choice-link.net/api/v1/orders \
  -H "Authorization: Bearer ck_live_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7b1c0e2a-…(unique per order)" \
  -d '{
    "externalRef": "PO-10433",
    "buildings": [
      { "serialNumber": "SMF-Z1-MU-0812-100826-373012",
        "packageId": "66b2c3d4e5f60718293a4b5c",
        "roofColor": "BS", "sidingColor": "LS", "trimColor": "LS" }
    ]
  }'

Authentication

Every request must carry your API key. Send it either as a Bearer token (preferred) or an x-api-key header:

Authorization: Bearer ck_live_ab12cd34ef56_…
# or
x-api-key: ck_live_ab12cd34ef56_…

Keys look like ck_live_<id>_<secret>. ChoiceLink stores only a SHA-256 hash of the key — the full token is shown once when it is created and cannot be recovered, so store it securely. Keys can be scoped, revoked, and given an expiry. A missing, malformed, invalid, revoked, or expired key returns 401; a valid key that lacks the scope an endpoint needs returns 403.

Scopes

Each key carries one or more scopes. Endpoints require a specific scope:

ScopeGrants
catalog:readGET /api/v1/catalog, GET /api/v1/packages, GET /api/v1/mappings and GET /api/v1/preflight
orders:writePOST /api/v1/orders and POST /api/v1/orders/preview
orders:readGET /api/v1/orders/:id and GET /api/v1/orders
mappings:writePUT /api/v1/mappings
orders:sendPOST /api/v1/orders/:id/review-link: ChoiceLink’s review and Send to FCM inside your app. Only a ChoiceLink admin gives it, per key; no key has it by default.

Most partner keys are issued with every scope. A key can also carry a partner name (e.g. shedpro): the shop’s answers to what your words mean are kept per partner, so every key for the same software should share it.

Setup & onboarding

Done once, by a ChoiceLink administrator, before a partner can submit:

  1. The shop belongs to a company that has its First Choice Metals API key configured.
  2. The shop has its FCM customer id set, and its warehouse has the FCM warehouse/department ids (warehouse ids are optional but recommended).
  3. At least one person belongs to that shop to review and click Send to FCM.
  4. An API key is minted for the shop and handed to the partner (shown once).

The partner then maps its products to ours once: its buildings to our lines, packages and variations (from /api/v1/packages), any loose pieces to our item codes (from /api/v1/catalog), and its colors to our color codes, and submits ours on every order. You can verify readiness at any time with /api/v1/preflight — its missing array tells you exactly what is not yet configured.

How product matching works

Each order line is our item code + color code + quantity + optional length. At send time, the First Choice Metals product id is derived from the item code and color code by this rule (the API runs it up front so any unmatched line is rejected immediately, not days later at send):

base = itemCode               (e.g. "RC9-10")
if   base contains "ST9-"  ->  replace the first "-" with the color code
elif base contains "POLY"  ->  use base as-is (the color is ignored)
elif base contains "-"     ->  replace the first "-" with the color code
else                       ->  base + color code

# Special-trim items — codes containing "ST9-" or "ST6-" — additionally carry a
# required, user-supplied "description" to FCM (see Submit an order).
itemCodecolorResulting FCM product id
ST9-BRST9BR
POLY100CLPOLY100 (color ignored)
RIDGE-WHRIDGEWH
GUTTERALGUTTERAL

A color is required on every line. POLY codes ignore the color’s value, but one must still be present — without it the order would stage and then fail when a human tries to send it, so the API rejects it up front.

Conventions

  • All requests and responses are JSON. Send Content-Type: application/json on requests with a body.
  • The API is versioned in the path (/api/v1). Breaking changes ship under a new version.
  • Timestamps are ISO-8601 UTC strings. Order ids are 24-character hex strings.
  • Errors always return a JSON body with an error string (see Errors).

Check readiness

GET/api/v1/preflightany valid key

Confirms your key works and reports whether the bound shop can stage orders and have them sent to FCM. Any valid key works.

200 — response
{
  "ok": true,
  "keyName": "Acme ERP",
  "scopes": ["orders:write", "orders:read", "catalog:read"],
  "expiresAt": null,
  "shop": { "id": "665f0a1b2c3d4e5f60718293", "name": "North Shop" },
  "company": "First Choice Metals",
  "canStageOrders": true,    // shop is linked to a company
  "canBeSentToFcm": true,    // company API key + shop customer id are set
  "missing": [],             // blocking gaps to fix if canBeSentToFcm is false
  "warnings": [],            // non-blocking (e.g. optional warehouse ids)
  "mappings": {              // how far the shop has mapped your words
    "partner": "shedpro", "ready": false, "needed": 2, "suggested": 5, "confirmed": 31,
    "byKind": { "line": { … }, "color": { … }, "option": { … } } }
}

Pull the catalog

GET/api/v1/catalogscope: catalog:read

The authoritative list of item codes and color codes your shop may order. Pull this to build your crosswalk and re-sync when it changes.

200 — response
{
  "company": "First Choice Metals",
  "shop": "North Shop",
  "updatedAt": "2026-06-03T15:00:00.000Z",
  "itemCodes": [
    { "code": "AG9",    "description": "29ga AG Panel" },
    { "code": "RC9-10", "description": "RIDGE CAP (29ga) 10'6\"" },
    { "code": "ST9-LF", "description": "SPECIAL TRIM (29ga) Custom-Length" }
  ],
  "colors": [
    { "code": "BR", "name": "Brown" },
    { "code": "WH", "name": "White" }
  ]
}

Pull your packages

GET/api/v1/packagesscope: catalog:read

What your shop can order as buildings: its lines (archived ones left out), each line's packages (sizes) and variations, plus your add-ons and the colors. These ids are what buildings[] takes.

Query: lineId=… for one line; includeItems=true adds each variation’s and add-on’s items (name, item code, type, quantity, length), as an order would copy them.

200 — response
{
  "company": "First Choice Metals",
  "shop": "North Shop",
  "updatedAt": "2026-10-14T15:00:00.000Z",
  "lines": [
    { "id": "66a1b2c3d4e5f60718293a4b", "name": "Metal Utility", "metalBuilding": false,
      "packages": [
        { "id": "66b2c3d4e5f60718293a4b5c", "name": "8x12", "size": { "width": 8, "length": 12 },
          "variations": [ { "id": "66c3d4e5f60718293a4b5c6d", "name": "Standard" },
                          { "id": "66c4d5e6f70818293a4b5c6e", "name": "Standard/Eaves" } ] } ] }
  ],
  "addOns": [ { "id": "66d4e5f60718293a4b5c6d7e", "name": "8' - 15L Dormer" } ],
  "colors":  [ { "code": "BS", "name": "Burnished Slate" } ]
}

A package’s size is read from its name (WxL), or null when the name isn’t a size. Variations are listed by name; the first is the one an order gets when you don’t name one.

Submit an order

POST/api/v1/ordersscope: orders:write

Stages an order as Pending in your shop, holding buildings, item lines, or both. Validation is strict and up front: a building that doesn't resolve or that Send to FCM couldn't send, unknown or cross-account references, special-trim lines missing a description, and lines that can't be matched to an FCM product are rejected with 422 and no order is created.

Buildings

FieldRequiredNotes
externalRefnoYour PO / reference, up to 30 characters. Becomes the order number and the FCM customer PO.
buildings[].serialNumberyesThe building's serial number, up to 30 characters.
buildings[].packageIdyesA package from /packages. It must be your shop's.
buildings[].lineIdnoThe package's line. When sent, it must match; an archived line can't be ordered.
buildings[].variationIdnoOne of the package's variations. Omitted: its first by name, as in the order form.
buildings[].roofColoryesA color code.
buildings[].sidingColor, trimColorconditionalColor codes. Needed when the package has siding or trim items (a metal-sided building): every item takes the color of its type.
buildings[].addOns[]no{ "addOnId", "quantity" }: an add-on from /packages; quantity is a whole number that multiplies its items (default 1).

ChoiceLink copies the chosen variation’s items, and each add-on’s items, into the order: the same rows its own order form makes, so the order looks the same as one typed in. The building is then run through the same transform Send to FCM uses, so a building that couldn’t be sent is refused now with the reason. Buildings, and their items, are saved in the order you send them, which is the order Send to FCM sends them in.

request — buildings
{
  "externalRef": "PO-10433",
  "buildings": [
    { "serialNumber": "SMF-Z1-MU-0812-100826-373012",
      "packageId": "66b2c3d4e5f60718293a4b5c",
      "variationId": "66c4d5e6f70818293a4b5c6e",
      "roofColor": "BS", "sidingColor": "LS", "trimColor": "LS",
      "addOns": [ { "addOnId": "66d4e5f60718293a4b5c6d7e", "quantity": 1 } ] }
  ]
}
201 — each building echoes what it became
{
  "id": "665f0a1b2c3d4e5f60718293",
  "orderNumber": "PO-10433",
  "status": "Pending",
  "sentToFCM": false,
  "externalRef": "PO-10433",
  "buildings": [
    { "serialNumber": "SMF-Z1-MU-0812-100826-373012",
      "line": { "id": "66a1…", "name": "Metal Utility" },
      "package": { "id": "66b2…", "name": "8x12" },
      "variation": { "id": "66c4…", "name": "Standard/Eaves" },
      "colors": { "roof": { "code": "BS", "name": "Burnished Slate" },
                  "siding": { "code": "LS", "name": "Light Stone" },
                  "trim": { "code": "LS", "name": "Light Stone" } },
      "items": [ { "itemId": "…", "name": "29 GAUGE PANEL @ 12'3\"", "type": "Roof",
                   "itemCode": "AG9", "quantity": 6, "feet": 12, "inches": 3 }, … ],
      "addOns": [ { "addOnId": "66d4…", "name": "8' - 15L Dormer", "quantity": 1, "items": [ … ] } ] }
  ],
  "lines": []
}

Item lines

FieldRequiredNotes
linessee noteFlat array of line items — the standard form.
groupssee noteLabeled groups for multi-building orders: [{ "reference": "Building A", "lines": [ … ] }]. customPackages is an alias. If lines is present it takes precedence.
lines[].itemCodeyesAn item code from /catalog.
lines[].coloryesA color code from /catalog. Required on every line.
lines[].quantityyesPositive integer.
lines[].feet, lines[].inchesconditionalLength (decimals). Required for custom-length items; for fixed-length items the catalog length is used and any value you send is normalized to it. Default 0.
lines[].descriptionconditionalRequired for special-trim items (codes containing ST9- or ST6-); ignored for everything else. Sent to FCM as "<description> - <COLOR>".

Lengths: fixed-length items (e.g. RC9-10 = RIDGE CAP 10’6") take their length from the catalog — you may omit feet/inches, and any value you send is normalized to match. Custom-/linear-length items (e.g. …-LF, panels) use the length you send. Special trim: any item code containing ST9- or ST6- must include a non-empty description; omitting it returns 422.

request — flat (standard)
{
  "externalRef": "PO-10432",
  "lines": [
    { "itemCode": "RC9-10", "color": "BR", "quantity": 12 },
    { "itemCode": "AG9",    "color": "BR", "quantity": 8, "feet": 12, "inches": 0 }
  ]
}
request — special trim (ST9-/ST6- needs a description)
{
  "externalRef": "PO-10433",
  "lines": [
    { "itemCode": "ST9-LF", "color": "BR", "quantity": 4, "feet": 10, "inches": 6,
      "description": "L-trim 3.5x1.5 bent 90" }
  ]
}
request — labeled groups (multi-building)
{
  "externalRef": "PO-10432",
  "groups": [
    { "reference": "Building A", "lines": [ { "itemCode": "RC9-10", "color": "BR", "quantity": 12 } ] },
    { "reference": "Building B", "lines": [ { "itemCode": "GUTTER", "color": "WH", "quantity": 8 } ] }
  ]
}
201 — order staged
{
  "id": "665f0a1b2c3d4e5f60718293",
  "orderNumber": "PO-10432",
  "status": "Pending",
  "sentToFCM": false,
  "externalRef": "PO-10432",
  "buildings": [],
  "lines": [
    { "itemCode": "RC9-10", "color": "BR", "resolvedProductId": "RC9BR10" },
    { "itemCode": "ST9-LF", "color": "BR", "resolvedProductId": "ST9BRLF",
      "description": "L-trim 3.5x1.5 bent 90" }
  ]
}

resolvedProductId is the FCM product id each line will send as. Send an Idempotency-Key header to make retries safe — see Idempotency. When externalRef is omitted, the order number is an API-generated value (API-<timestamp>).

Buildings in your own words

Instead of our ids, a building can be sent the way your software names it. A building with a line and no packageId is read this way; one order can mix both.

a building in words
{ "serialNumber": "SMF-Z1-MU-0812-100826-373012",
  "line": "Metal Utility (SMF-Z1)",        // your model name
  "size": "8x12",                           // or { "width": 8, "length": 12 } (feet)
  "options": [ "Eaves (Any Size Building)",
               { "name": "15-Lite Transom Dormer", "quantity": 1 } ],
  "roofColor": "Black", "sidingColor": "Light Gray", "trimColor": "White" }
  • line → one of the shop’s lines, then that line’s package of that size.
  • Each option → a variation part (Eaves, Steeper Pitch), an add-on (with its quantity), or nothing for the metal (a window, a door). An answer can hold for one building width only: a dormer add-on differs by width.
  • The variation is the package’s one whose parts are exactly the options’ parts (Standard when there are none); send variation to name it instead.
  • Each color → one of the colors.

ChoiceLink reads each word with the shop’s answers for your partner name. With none, an exact name still works (a line or add-on with that name, a variation part, a color’s name or code). Anything else stops the building with needs_mapping and an answerUrl: the word waits on the shop’s Partner Mappings page in ChoiceLink, the shop answers it once, and every order after uses the answer. A preview finds (and saves) every unanswered word up front. The building is then checked exactly like one sent by ids, and its result says how each word was read:

in the building's result
"translatedFrom": {
  "line": { "word": "Metal Utility (SMF-Z1)", "id": "66a1…", "name": "Metal Utility", "by": "mapping" },
  "size": "8x12",
  "options": [ { "word": "Eaves (Any Size Building)", "means": { "variationPart": "Eaves" }, "by": "mapping" } ],
  "colors": { "roofColor": { "word": "Black", "code": "BL", "name": "Black", "by": "name" } } }

Check an order first

POST/api/v1/orders/previewscope: orders:write

The same body and the same checks as POST /orders, without staging anything. Answers 200 once your key and body are good; ok says whether POST /orders would accept the order.

200 — response
{
  "ok": false,
  "shop": { "id": "665f0a1b2c3d4e5f60718293", "name": "North Shop" },
  "externalRef": "PO-10433",
  "buildings": [
    { "ok": true, "serialNumber": "SMF-Z1-MU-0812-100826-373012",
      "line": { … }, "package": { … }, "variation": { … }, "colors": { … },
      "items": [ … ], "addOns": [ … ],
      "salesOrderDetails": [
        { "strProductID2": "BARNP", "membaseDescription": "SMF-Z1-MU-0812-100826-373012 " },
        { "strProductID2": "AG9BS", "decPcsOrdered": 6, "decLinearAmount1": 12, "decLinearAmount2": 3 } ] },
    { "ok": false, "serialNumber": "SMF-Z1-LB-1016-100826-373013",
      "problems": [ { "building": "buildings[1]", "code": "fcm_unresolvable",
                      "problem": "Package item \"SIDE PANEL @ 7'\" requires a siding color to be selected." } ] }
  ],
  "lines": [],
  "problems": [ … every problem above … ],
  "salesOrderDetails": null
}

Each building’s salesOrderDetails are the lines Send to FCM would build for it. When ok is true, the top-level salesOrderDetails is everything Send would send for the order, in order: the buildings, then the item-line groups.

Get an order

GET/api/v1/orders/:idscope: orders:read

One order, scoped to your shop: its status through Pending → sent → Confirmed → Shipped, its buildings as saved (edits made in ChoiceLink after staging show here), and its item-line groups.

200 — response
{
  "id": "665f0a1b2c3d4e5f60718293",
  "orderNumber": "PO-10432",
  "fcmOrderNumber": "48213",     // FCM's number once sent
  "status": "Shipped",
  "sentToFCM": true,
  "source": "api",
  "externalRef": "PO-10432",
  "createdAt": "2026-06-03T15:01:00.000Z",
  "sentAt": "2026-06-03T16:20:00.000Z",
  "confirmedAt": "2026-06-04T09:00:00.000Z",
  "shippedAt": "2026-06-08T13:00:00.000Z",
  "received": false,
  "fcmChangedItems": false,      // FCM changed items on its side after the order was sent
  "buildings": [
    { "id": "…", "serialNumber": "SMF-Z1-MU-0812-100826-373012",
      "line": { … }, "package": { … }, "variation": { … }, "colors": { … },
      "items": [ … ], "addOns": [ … ] }
  ],
  "groups": [
    { "reference": "PO-10432",
      "lines": [
        { "itemCode": "RC9-10", "color": "BR", "quantity": 12, "feet": 10, "inches": 6 },
        { "itemCode": "ST9-LF", "color": "BR", "quantity": 4, "feet": 10, "inches": 6,
          "description": "L-trim 3.5x1.5 bent 90" }
      ] }
  ]
}

An unknown id (or one in another shop, or a malformed id) returns 404.

GET/api/v1/orders?ids=… or ?externalRef=…scope: orders:read

Several of your shop's orders at once, in the same shape, as { orders: [ … ] }: up to 50 comma-separated ids, or every order with that externalRef, newest first. Not to be combined with since (below).

List your shop's orders

GET/api/v1/orders?since=…scope: orders:read

Every order of your shop created at or after since, however it was made (sent through this API or typed into ChoiceLink's own order form), oldest first, a page at a time, each in the same shape as GET /orders/:id. It only reads. Use it to bring a shop's history in, then to keep up with its new orders.

QueryRequiredNotes
sinceyesAn ISO 8601 date or date and time: 2026-10-28, 2026-10-28T14:30:00Z, 2026-10-28T09:30:00-05:00. A time with no offset is UTC. An order created at exactly since is included.
limitnoOrders per page, 1 to 100 (default 50). A whole number outside that range is moved to the nearest end; anything that isn't a whole number is a 400.
cursornoThe nextCursor of the previous page, unchanged. Leave it out for the first page, and send the same since and limit with every page. A cursor this API didn't give out is a 400.
200 — response
{
  "orders": [
    { "id": "665f0a1b2c3d4e5f60718293", "orderNumber": "7731", "fcmOrderNumber": "48213",
      "status": "Shipped", "sentToFCM": true,
      "source": null, "externalRef": null,          // typed into ChoiceLink's form
      "createdAt": "2025-10-28T15:12:40.113Z", "sentAt": "…", "confirmedAt": "…", "shippedAt": "…",
      "received": false, "fcmChangedItems": false,
      "buildings": [ { "id": "…", "serialNumber": "SMF-Z1-MU-0812-100825-373001",
                       "line": { … }, "package": { … }, "variation": { … }, "colors": { … },
                       "items": [ … ], "addOns": [ … ] } ],
      "groups": [] },
    { "id": "66607a1b2c3d4e5f60718294", "orderNumber": "PO-10433", "fcmOrderNumber": null,
      "status": "Pending", "sentToFCM": false,
      "source": "api", "externalRef": "PO-10433",   // sent through the API
      "createdAt": "2025-10-29T09:30:12.480Z", /* … the rest as above … */ }
  ],
  "nextCursor": "WzE3NjE3MzAyMTI0ODAsIjY2NjA3YTFiMmMzZDRlNWY2MDcxODI5NCJd"   // null on the last page
}
  • Paging. When nextCursor is a string there may be more orders: send it back as cursor. It is null on the last page. Treat the cursor as opaque text. Orders are listed by when they were created and then by id, so a page never skips or repeats an order, even for orders created in the same instant.
  • Every order of the shop, whatever its status: an order that has not been sent to FCM (Pending, sentToFCM: false) is listed too.
  • Orders typed into ChoiceLink look like API orders with two differences: source and externalRef are null (only the API fills them in), and orderNumber is whatever the person typed in the order form rather than your externalRef. Their buildings, serial numbers, packages, colors, items, status, fcmOrderNumber and dates are the same. An older order may have no line ({ "id": null, "name": null }), and a building with no siding or trim items has null for that color.
  • Keeping up. The list is by creation date. Pull again from a little before the newest createdAt you have (an hour is plenty) and skip the ids you already hold: an order sent through the API is saved over a second or so, and only shows once it is complete, so it can appear just after orders created later than it. An order you already have that changes (sent, confirmed, shipped, edited in ChoiceLink) does not come around again by date: ask for the open ones with ?ids=… (up to 50 at a time).
  • since cannot be combined with ids or externalRef (400). A malformed since, cursor or limit is a 400 with a plain-English error.

Set a shop up, and read and suggest mappings

  1. Send your vocabulary once: every model, color and option you use for the shop (PUT /mappings with words and no answers). ChoiceLink guesses what it can: the same name without the part in brackets, or the one close color name.
  2. The shop, or ChoiceLink staff during onboarding, walks Lines → Colors → Options on Partner Mappings. They confirm the guesses, answer the rest, and mark options that don’t matter for metal in one click. An option’s answer can hold only on one line or for one building width.
  3. Offer “order metal” once /preflight says mappings.ready. A word that turns up later waits the same way (needs_mapping with an answerUrl).
GET/api/v1/mappings?status=needed|suggested|confirmedscope: catalog:read

Every word you've sent, seen on your orders or suggested (for your partner name), with its status, the shop's answer, and how far setup has got. Words with status needed are waiting for the shop.

200 — response
{ "partner": "shedpro", "shop": "North Shop",
  "readiness": { "ready": false, "needed": 1, "suggested": 0, "confirmed": 18, "byKind": { … } },
  "mappings": [
    { "id": "…", "kind": "option", "word": "15-Lite Transom Dormer", "width": 10,
      "status": "confirmed", "answer": { "addOn": { "id": "…", "name": "10' - 15L Dormer" } }, "timesSeen": 4 },
    { "id": "…", "kind": "color", "word": "Charcoal Gray", "width": 0, "status": "needed", "answer": null } ] }
PUT/api/v1/mappingsscope: mappings:write

Send your vocabulary, and suggest what your words mean. An entry with no answer is a word you use: saved for the shop to answer, with ChoiceLink's guess when one fits. An entry with an answer is a suggestion: checked against the shop's catalog, saved as suggested, and counted once the shop confirms it. An answer the shop already confirmed is left as is.

request
{ "mappings": [
    { "kind": "line",   "word": "Metal Utility (SMF-Z1)",    "answer": { "lineId": "66a1…" } },
    { "kind": "option", "word": "Eaves (Any Size Building)", "answer": { "variationPart": "Eaves" } },
    { "kind": "option", "word": "15-Lite Transom Dormer",    "answer": { "addOnId": "66d5…", "width": 10 } },
    { "kind": "option", "word": "2x3 Window",                "answer": { "ignore": true } },
    { "kind": "option", "word": "Eaves",                     "answer": { "ignore": true, "onlyLineId": "66a9…" } },
    { "kind": "color",  "word": "White",                     "answer": { "colorCode": "PW" } },
    { "kind": "line",   "word": "Side Utility (SMF-Z1)" } ] }    // just a word: the shop answers it
200 — one result per suggestion
{ "partner": "shedpro",
  "results": [ { "index": 0, "kind": "line", "word": "Metal Utility (SMF-Z1)", "ok": true, "id": "…", "status": "suggested" },
               { "index": 4, "kind": "color", "word": "White", "ok": false, "error": "pick one of the colors" } ] }

Idempotency

Send a unique Idempotency-Key header with each POST /api/v1/orders request. It makes network retries safe — order numbers are not unique on their own, so this is how duplicates are prevented.

ScenarioResult
Same key, same body (a retry)Returns the original response with idempotentReplay: true. No second order.
Same key, different body409 — the key was already used with a different request.
New key (or no key)Processed normally.

Errors

Errors return the matching HTTP status and a JSON body with an error string.

StatusMeaning
400Request body is not valid JSON; or, on GET /orders, a query value is wrong: no since, ids or externalRef, a since that isn't a date, a cursor that isn't a nextCursor this API gave out, a limit that isn't a whole number, more than 50 ids, or since together with ids or externalRef.
401Missing, malformed, invalid, revoked, or expired key.
403Key is valid but lacks the required scope, or is not bound to a shop.
409Shop not linked to a company, or an Idempotency-Key reused with a different body.
422Validation failed — see below. No order is created. Also: nothing to order, buildings not a list, or externalRef over 30 characters.
500Unexpected server error while staging an order, or listing orders.

A 422 from POST /orders is self-correcting: it names exactly which lines failed and why. Reference problems come back as details; lines that resolve but can’t be matched to an FCM product come back as lines.

422 — unknown / cross-account refs, or a special-trim line missing its description
{
  "error": "One or more lines could not be resolved against your catalog.",
  "details": [
    { "line": "lines[1]", "itemCode": "WIDGET", "problem": "unknown item code" },
    { "line": "lines[2]", "itemCode": "ST9-LF",
      "problem": "special-trim items require a `description`" }
  ]
}
422 — resolves, but can't be matched to an FCM product
{
  "error": "One or more lines cannot be matched to an FCM product.",
  "lines": [
    { "label": "Ridge Cap", "itemCode": "RIDGE-", "ok": false,
      "problem": "item code \"RIDGE-\" requires a color code" }
  ]
}

Building problems

Each building problem names the building (buildings[0]), its serial number and a stable code; problem says it in words, and field says which color or add-on.

codeMeaning
invalid_buildingThe building isn't an object.
missing_serial_number, serial_number_too_longA serial number is required, up to 30 characters.
missing_package, unknown_packageNo packageId, or it isn't one of your shop's packages.
line_mismatch, archived_linelineId isn't the package's line, or the line is archived.
unknown_variation, no_variationsvariationId isn't on the package, or the package has none.
missing_roof_color, unknown_colorA roof color is required; a color code isn't one of ours.
invalid_add_ons, unknown_add_on, archived_add_on, invalid_quantityaddOns isn't a list, an add-on isn't yours or is archived, or a quantity isn't a positive whole number.
package_item_missingAn item in the package or an add-on is missing from our catalog. Ask us to fix it.
fcm_unresolvableThe building can't go to FCM as it is; problem gives Send to FCM's own reason (usually a missing siding or trim color).
no_itemsThe variation and add-ons have nothing to send to FCM.

Buildings sent in words add these (each with field and word):

codeMeaning
needs_mappingThe shop hasn't said what this word means yet. answerUrl opens it on Partner Mappings.
mapping_awaiting_confirmationYou suggested an answer; the shop hasn't confirmed it yet.
stale_mappingThe answer points to a line, add-on or color that's been archived or removed; the shop answers again.
missing_line, invalid_sizeline is required; size must be "WxL" or { width, length }.
no_package_for_sizeThe line has no package of that size; ask for it in Package Requests.
no_variation_for_optionsThe package has no variation for exactly those options' parts (available lists its variations).
invalid_options, invalid_option, invalid_quantityoptions isn't a list, an option isn't a name or { name, quantity }, or a quantity isn't a positive whole number.
422 — a building that doesn't resolve
{
  "error": "One or more buildings could not be resolved against your catalog.",
  "details": [
    { "building": "buildings[0]", "serialNumber": "SMF-Z1-MU-0812-100826-373012",
      "code": "unknown_package", "problem": "no such package for this shop",
      "packageId": "66b2c3d4e5f60718293a4b5c" }
  ]
}

Per-line problem strings include: missing itemCode, quantity must be a positive integer, unknown item code, item code does not belong to this account, missing color code, unknown color code for this account, and special-trim items require a `description`.

Order lifecycle

  1. Submitted — you POST the order; it is created as Pending in the shop’s queue.
  2. Reviewed — a person at the shop opens the order in ChoiceLink and checks it.
  3. Sent — that person clicks Send to FCM, in ChoiceLink or in ChoiceLink’s review inside your app (Review and send); ChoiceLink posts it to First Choice Metals and records an FCM order number (sentToFCM becomes true).
  4. Fulfilled — the order moves through Confirmed → Shipped → Received.

Poll GET /api/v1/orders/:id to follow these transitions.

Key management (ChoiceLink admins)

These endpoints are for ChoiceLink administrators and use a logged-in ADMIN or COMPANY session (not an API key). Partners do not call them.

POST/api/admin/api-keysany valid key

Mint a key for a shop. Returns the plaintext token once.

request
{ "shopName": "North Shop",
  "name": "Acme ERP",
  "scopes": ["orders:write", "orders:read", "catalog:read"],
  "expiresAt": "2027-01-01" }
201 — token shown once
{ "id": "…", "token": "ck_live_…", "prefix": "ck_live_ab12cd34ef56",
  "scopes": ["orders:write","orders:read","catalog:read"], "shop": "North Shop",
  "warning": "Store this token now — it is shown only once and cannot be recovered." }
GET/api/admin/api-keysany valid key

List keys (never returns hashes or tokens). Optional ?shopId= filter.

DELETE/api/admin/api-keys/:idany valid key

Revoke a key (soft delete via revokedAt; history is preserved).

PATCH/api/admin/api-keys/:idany valid key

ADMIN only: { sendOrders: true | false } gives a key orders:send, or takes it away (Admin → API keys: Allow / Stop Send to FCM).

Keys can also be minted from the server with node scripts/mint-api-key.js "<shop name>" --name "Acme ERP".

Versioning & support

This is v1 (1.1.0 added buildings, /packages, /orders/preview and order lists, and limited externalRef to 30 characters, as in the order form; 1.2.0 added buildings in your own words and /mappings; 1.3.0 added sending your vocabulary, answers for one line, and setup readiness; 1.4.0 added add-on answers sized by the building's width, byWidth, for dormers; 1.5.0 added review and send inside your app, orders:send; 1.6.0 added listing your shop's orders with GET /orders?since=, whether they were sent through the API or typed into ChoiceLink). The version lives in the path; backward-incompatible changes will ship under a new path version. The machine-readable contract is the OpenAPI 3.1 spec — import it into Postman, Insomnia, or your codegen of choice. For access or help, contact your ChoiceLink administrator.