Docs
Firmly Agentic Commerce
Set theme to dark (⇧+D)

Set Postal Code

POST https://api.firmly.work/api/v2/carts/postal-code

Stores a postal code on the global session for the authenticated device. The value is reused across every merchant cart on this session; it is not scoped to a specific domain. This endpoint takes no {domain} parameter.

The postal code is consumed by per-merchant endpoints that gate behavior on it (e.g. Add Line Item returns 412 PostalCodeRequired for merchants that require a postal code before adding items).

​​ Authentication

​​ Request Body

  • postal_code (string, required) — The postal code to store. No format validation is enforced server-side — pass the value the merchant expects (US ZIP, Canadian / UK postcode, etc.).

​​ Response

  • postal_code (string) — The value that was stored.

​​ Examples


curl -X POST https://api.firmly.work/api/v2/carts/postal-code \
-H "x-firmly-authorization: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"postal_code": "90210"
}'

const response = await fetch('https://api.firmly.work/api/v2/carts/postal-code', {
method: 'POST',
headers: {
'x-firmly-authorization': 'YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({ postal_code: '90210' })
});
const { postal_code } = await response.json();

import requests
response = requests.post(
'https://api.firmly.work/api/v2/carts/postal-code',
headers={
'x-firmly-authorization': 'YOUR_TOKEN',
'Content-Type': 'application/json'
},
json={'postal_code': '90210'}
)
data = response.json()

​​ Response Example


{
"postal_code": "90210"
}

​​ Error Responses

Errors return a JSON body with code, error, and description. Program against the error value — descriptions are human-readable and may change.

400 — MissingAuthHeader

The x-firmly-authorization header is missing or empty.


{ "code": 400, "error": "MissingAuthHeader", "description": "x-firmly-authorization header is missing or invalid." }
400 — InvalidToken

The authorization token is not a valid JWT structure.


{ "code": 400, "error": "InvalidToken", "description": "Jwt token is invalid." }
401 — InvalidJWTToken

The device JWT signature does not verify, or required claims are missing.


{ "code": 401, "error": "InvalidJWTToken", "description": "Jwt token is invalid." }
404 — PartnerNotFound

The appid claim on the device JWT does not map to a known partner / tenant.


{ "code": 404, "error": "PartnerNotFound", "description": "Partner not found." }
400 — InvalidInputBody

The request body failed schema validation — postal_code is missing, null, or not a string.


{ "code": 400, "error": "InvalidInputBody", "description": "The body is not processable" }