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.
curl -s https://v2.choice-link.net/api/v1/preflight \
-H "Authorization: Bearer ck_live_…"curl -s https://v2.choice-link.net/api/v1/packages \
-H "Authorization: Bearer ck_live_…"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:
| Scope | Grants |
|---|---|
catalog:read | GET /api/v1/catalog, GET /api/v1/packages, GET /api/v1/mappings and GET /api/v1/preflight |
orders:write | POST /api/v1/orders and POST /api/v1/orders/preview |
orders:read | GET /api/v1/orders/:id and GET /api/v1/orders |
mappings:write | PUT /api/v1/mappings |
orders:send | POST /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:
- The shop belongs to a company that has its First Choice Metals API key configured.
- The shop has its FCM customer id set, and its warehouse has the FCM warehouse/department ids (warehouse ids are optional but recommended).
- At least one person belongs to that shop to review and click Send to FCM.
- 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).| itemCode | color | Resulting FCM product id |
|---|---|---|
ST9- | BR | ST9BR |
POLY100 | CL | POLY100 (color ignored) |
RIDGE- | WH | RIDGEWH |
GUTTER | AL | GUTTERAL |
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/jsonon 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
errorstring (see Errors).
Check readiness
/api/v1/preflightany valid keyConfirms your key works and reports whether the bound shop can stage orders and have them sent to FCM. Any valid key works.
{
"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
/api/v1/catalogscope: catalog:readThe authoritative list of item codes and color codes your shop may order. Pull this to build your crosswalk and re-sync when it changes.
{
"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
/api/v1/packagesscope: catalog:readWhat 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.
{
"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
/api/v1/ordersscope: orders:writeStages 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
| Field | Required | Notes |
|---|---|---|
externalRef | no | Your PO / reference, up to 30 characters. Becomes the order number and the FCM customer PO. |
buildings[].serialNumber | yes | The building's serial number, up to 30 characters. |
buildings[].packageId | yes | A package from /packages. It must be your shop's. |
buildings[].lineId | no | The package's line. When sent, it must match; an archived line can't be ordered. |
buildings[].variationId | no | One of the package's variations. Omitted: its first by name, as in the order form. |
buildings[].roofColor | yes | A color code. |
buildings[].sidingColor, trimColor | conditional | Color 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.
{
"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 } ] }
]
}{
"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
| Field | Required | Notes |
|---|---|---|
lines | see note | Flat array of line items — the standard form. |
groups | see note | Labeled groups for multi-building orders: [{ "reference": "Building A", "lines": [ … ] }]. customPackages is an alias. If lines is present it takes precedence. |
lines[].itemCode | yes | An item code from /catalog. |
lines[].color | yes | A color code from /catalog. Required on every line. |
lines[].quantity | yes | Positive integer. |
lines[].feet, lines[].inches | conditional | Length (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[].description | conditional | Required 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.
{
"externalRef": "PO-10432",
"lines": [
{ "itemCode": "RC9-10", "color": "BR", "quantity": 12 },
{ "itemCode": "AG9", "color": "BR", "quantity": 8, "feet": 12, "inches": 0 }
]
}{
"externalRef": "PO-10433",
"lines": [
{ "itemCode": "ST9-LF", "color": "BR", "quantity": 4, "feet": 10, "inches": 6,
"description": "L-trim 3.5x1.5 bent 90" }
]
}{
"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 } ] }
]
}{
"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.
{ "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 thatsize.- 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 (
Standardwhen there are none); sendvariationto 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:
"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
/api/v1/orders/previewscope: orders:writeThe 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.
{
"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
/api/v1/orders/:idscope: orders:readOne 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.
{
"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.
/api/v1/orders?ids=… or ?externalRef=…scope: orders:readSeveral 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
/api/v1/orders?since=…scope: orders:readEvery 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.
| Query | Required | Notes |
|---|---|---|
since | yes | An 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. |
limit | no | Orders 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. |
cursor | no | The 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. |
{
"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
nextCursoris a string there may be more orders: send it back ascursor. It isnullon the last page. Treat the cursor as opaque text. Orders are listed by when they were created and then byid, 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:
sourceandexternalRefarenull(only the API fills them in), andorderNumberis whatever the person typed in the order form rather than yourexternalRef. Their buildings, serial numbers, packages, colors, items, status,fcmOrderNumberand dates are the same. An older order may have noline({ "id": null, "name": null }), and a building with no siding or trim items hasnullfor that color. - Keeping up. The list is by creation date. Pull again from a little before the newest
createdAtyou have (an hour is plenty) and skip theids 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). sincecannot be combined withidsorexternalRef(400). A malformedsince,cursororlimitis a 400 with a plain-Englisherror.
Review and send, inside your app
A shop can send a staged order to FCM without leaving your software: you ask for a short-lived link to ChoiceLink’s review of the order and show it in a frame. The person checks the buildings (and FCM’s price, where the shop’s company prices orders at Send) and presses ChoiceLink’s own Send to FCM. Your software never sends anything to FCM.
/api/v1/orders/:id/review-linkscope: orders:sendA link to the order's review, for 15 minutes, for the person you name. The order must be your shop's and not yet sent.
{ "by": { "name": "Pat Lee", "email": "pat@example.com" }, // named on the order's send log
"origin": "https://os.stormor.tech" } // the page that frames the review{ "url": "https://v2.choice-link.net/connect/review/…",
"expiresAt": "2026-10-16T15:15:00.000Z" }409 when the order is already sent (with its fcmOrderNumber), 404 when it isn’t your shop’s, 422 when origin isn’t a page ChoiceLink lets frame the review. Only the partner pages ChoiceLink lists may frame it; every other ChoiceLink page refuses to be framed.
The review tells the framing page what happened with postMessage, to the origin you gave only:
{ "source": "choicelink-review", "type": "height", "orderId": "…", "height": 640 }
{ "source": "choicelink-review", "type": "sent", "orderId": "…", "fcmOrderNumber": "48213", "alreadySent": false }
{ "source": "choicelink-review", "type": "close", "orderId": "…" }Check the message’s origin is ChoiceLink’s, then read the order with GET /api/v1/orders/:id: that is the record. Revoking the key, or an admin taking orders:send away, stops every open link at once.
Set a shop up, and read and suggest mappings
- Send your vocabulary once: every model, color and option you use for the shop (
PUT /mappingswith words and no answers). ChoiceLink guesses what it can: the same name without the part in brackets, or the one close color name. - 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.
- Offer “order metal” once
/preflightsaysmappings.ready. A word that turns up later waits the same way (needs_mappingwith ananswerUrl).
/api/v1/mappings?status=needed|suggested|confirmedscope: catalog:readEvery 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.
{ "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 } ] }/api/v1/mappingsscope: mappings:writeSend 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.
{ "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{ "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.
| Scenario | Result |
|---|---|
| Same key, same body (a retry) | Returns the original response with idempotentReplay: true. No second order. |
| Same key, different body | 409 — 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.
| Status | Meaning |
|---|---|
400 | Request 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. |
401 | Missing, malformed, invalid, revoked, or expired key. |
403 | Key is valid but lacks the required scope, or is not bound to a shop. |
409 | Shop not linked to a company, or an Idempotency-Key reused with a different body. |
422 | Validation failed — see below. No order is created. Also: nothing to order, buildings not a list, or externalRef over 30 characters. |
500 | Unexpected 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.
{
"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`" }
]
}{
"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.
| code | Meaning |
|---|---|
invalid_building | The building isn't an object. |
missing_serial_number, serial_number_too_long | A serial number is required, up to 30 characters. |
missing_package, unknown_package | No packageId, or it isn't one of your shop's packages. |
line_mismatch, archived_line | lineId isn't the package's line, or the line is archived. |
unknown_variation, no_variations | variationId isn't on the package, or the package has none. |
missing_roof_color, unknown_color | A roof color is required; a color code isn't one of ours. |
invalid_add_ons, unknown_add_on, archived_add_on, invalid_quantity | addOns isn't a list, an add-on isn't yours or is archived, or a quantity isn't a positive whole number. |
package_item_missing | An item in the package or an add-on is missing from our catalog. Ask us to fix it. |
fcm_unresolvable | The 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_items | The variation and add-ons have nothing to send to FCM. |
Buildings sent in words add these (each with field and word):
| code | Meaning |
|---|---|
needs_mapping | The shop hasn't said what this word means yet. answerUrl opens it on Partner Mappings. |
mapping_awaiting_confirmation | You suggested an answer; the shop hasn't confirmed it yet. |
stale_mapping | The answer points to a line, add-on or color that's been archived or removed; the shop answers again. |
missing_line, invalid_size | line is required; size must be "WxL" or { width, length }. |
no_package_for_size | The line has no package of that size; ask for it in Package Requests. |
no_variation_for_options | The package has no variation for exactly those options' parts (available lists its variations). |
invalid_options, invalid_option, invalid_quantity | options isn't a list, an option isn't a name or { name, quantity }, or a quantity isn't a positive whole number. |
{
"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
- Submitted — you POST the order; it is created as
Pendingin the shop’s queue. - Reviewed — a person at the shop opens the order in ChoiceLink and checks it.
- 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 (
sentToFCMbecomes true). - 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.
/api/admin/api-keysany valid keyMint a key for a shop. Returns the plaintext token once.
{ "shopName": "North Shop",
"name": "Acme ERP",
"scopes": ["orders:write", "orders:read", "catalog:read"],
"expiresAt": "2027-01-01" }{ "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." }/api/admin/api-keysany valid keyList keys (never returns hashes or tokens). Optional ?shopId= filter.
/api/admin/api-keys/:idany valid keyRevoke a key (soft delete via revokedAt; history is preserved).
/api/admin/api-keys/:idany valid keyADMIN 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.