Fulfillment Manager API · orders

The margins of an order still being typed

POST /orders/margins

The margins of an order still being typed — lines priced from one catalog, not yet saved — worked out as GET /orders/:orderId/margins works out a saved one's: revenue net of the line's discount and tax, the order's net of the order discount too; cost the SKUs' cost basis, a kit's its parts'; each line held to the catalog's minimum margin (or its base catalog's).

A catalog whose prices include tax has it taken out at the organization's own rates for the SKUs' classes on today's domestic sale, so the figure can move once the order's ship-to is known and it is saved (TaxRateMissing when a class has no rate today). Only a caller holding margins:read sees cost. Appends nothing: a pure calculation, acknowledged in the request log. No idempotency key: it records nothing, so a retry answers the same figures.

Access

Requires margins:read.

How scopes come from roles: Scopes and roles. Getting a token: Authentication and app tokens.

Retries

No idempotency key: it records nothing, so a retry answers the same figures.

Why every write carries a key: Idempotency and retries.

Facts appended

None. This call records nothing in a journal.

What a fact is: Facts and the journal.

AI agent tool

No agent tool. the new-order form's preview of lines not yet saved; an agent saves a draft quote and reads its margins with fulfillment_get_order_margins

Connecting an agent: AI agents.

Example

curl
curl -X POST 'https://fulfillment.getmanifold.io/orders/margins' \
  -H "Authorization: Bearer $MANIFOLD_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "catalogId": "cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e",
  "lines": [
    {
      "sku": "MUG-SPECKLE",
      "quantity": 24,
      "unitPriceCents": 2400,
      "discountCents": 1200
    }
  ]
}'
JavaScript (fetch)
const response = await fetch("https://fulfillment.getmanifold.io/orders/margins", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.MANIFOLD_TOKEN}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "catalogId": "cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e",
    "lines": [
      {
        "sku": "MUG-SPECKLE",
        "quantity": 24,
        "unitPriceCents": 2400,
        "discountCents": 1200
      }
    ]
  }),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const answer = await response.json();
Request body · application/json
{
  "catalogId": "cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e",
  "lines": [
    {
      "sku": "MUG-SPECKLE",
      "quantity": 24,
      "unitPriceCents": 2400,
      "discountCents": 1200
    }
  ]
}
Response · 200 · application/json
{
  "currency": "AUD",
  "lines": [
    {
      "sku": "MUG-SPECKLE",
      "catalogId": "cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e",
      "quantity": 24,
      "status": "costed",
      "revenueCents": 56400,
      "unitCostCents": 1250,
      "costCents": 30000,
      "marginCents": 26400,
      "marginBps": 4681,
      "minimumMarginBps": 3500,
      "belowMinimum": false
    }
  ],
  "order": {
    "revenueCents": 56400,
    "costCents": 30000,
    "marginCents": 26400,
    "marginBps": 4681,
    "linesWithoutCost": 0,
    "unpricedLines": 0,
    "linesBelowMinimum": 0
  }
}

The panel writes this call in other languages. It does not send it: Manifold's APIs do not take calls from a web page on another site, so run the call from your own code or terminal. The whole API as OpenAPI: fulfillment-manager.openapi.json. Base URL https://fulfillment.getmanifold.io.

Errors

Every refusal is a status and a JSON body whose _tag names it. A refused call changes nothing.

401

RefusalWhat it meansWhat to do
Unauthorized reason The token is missing, expired or not one Manifold issued.Get a fresh token and send the call again.
TokenAlreadyUsed tokenId A single-use app token was already spent.Mint a new token for this call.

402

RefusalWhat it meansWhat to do
SubscriptionRequired status The organization's subscription has lapsed, so writes are refused.An owner settles billing. Reads still work meanwhile.

403

RefusalWhat it meansWhat to do
TenantRequired userId The token names no organization.Choose the organization, then get a new token.
ScopeRequired required The token's roles do not grant the scope this call needs.Ask an owner or admin for a role that grants it.

404

RefusalWhat it meansWhat to do
OrderCatalogNotFound catalogId No such record in this organization.Check the id in the path or the body.

409

RefusalWhat it meansWhat to do
TaxRateMissing class, at The organization charges tax on this class but has no rate for it on that day.An owner adds a rate for the class in Settings › Tax.
MirroredFromSource source This area is fed by your source system until the organization goes live.Make the change in the source system, or go live first.

502

RefusalWhat it meansWhat to do
InventoryUnavailable reason The inventory service did not answer, so nothing changed.Send the same request again shortly.

503

RefusalWhat it meansWhat to do
RequestLogUnavailable tokenId, reason The service could not record the request, so it did nothing.Send the same request again shortly.

How refusals work everywhere: Errors.