Purchasing Manager API · settings

Replace the organization's purchasing policy

PUT /settings

Every field is optional and falls back to its default, so a partial body is a whole configuration: poNumberPrefix and nextPoNumber are what the next order is numbered with (PO-00042); the serial only moves forward — a value at or below a number already issued is clamped to the next free one, never applied. autoInvoiceOnReceipt records the invoice at PO-line prices the moment an order is received in full; autoClose closes an order the moment it is invoiced; shortClose is what close does with undelivered quantity when the command does not say (cancel-remainder or keep-shortfall); supplierAlerts raises a member alert (purchasing.supplier-alert-raised) when a supplier's damageRatePercent or lateRatePercent reaches its threshold over the last windowDays, once minimumSample deliveries were measured. Appends purchasing.settings-configured. Idempotent by content: a retry that says what the policy already says appends nothing.

Access

Requires settings:write.

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

Retries

Idempotent by content: a retry that says what the policy already says appends nothing.

Why every write carries a key: Idempotency and retries.

Facts appended

  • purchasing.supplier-alert-raised
  • purchasing.settings-configured

What a fact is: Facts and the journal.

AI agent tool

Agents call this as purchasing_set_settings (Purchasing: Set settings), in the purchasing toolset.

Connecting an agent: AI agents.

Example

curl
curl -X PUT 'https://purchasing.getmanifold.io/settings' \
  -H "Authorization: Bearer $MANIFOLD_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "poNumberPrefix": "PO-",
  "nextPoNumber": 3,
  "autoInvoiceOnReceipt": false,
  "autoClose": true,
  "shortClose": "cancel-remainder",
  "supplierAlerts": {
    "damageRatePercent": 5,
    "lateRatePercent": 20,
    "minimumSample": 5,
    "windowDays": 90
  }
}'
JavaScript (fetch)
const response = await fetch("https://purchasing.getmanifold.io/settings", {
  method: "PUT",
  headers: { Authorization: `Bearer ${process.env.MANIFOLD_TOKEN}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "poNumberPrefix": "PO-",
    "nextPoNumber": 3,
    "autoInvoiceOnReceipt": false,
    "autoClose": true,
    "shortClose": "cancel-remainder",
    "supplierAlerts": {
      "damageRatePercent": 5,
      "lateRatePercent": 20,
      "minimumSample": 5,
      "windowDays": 90
    }
  }),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const answer = await response.json();
Request body · application/json
{
  "poNumberPrefix": "PO-",
  "nextPoNumber": 3,
  "autoInvoiceOnReceipt": false,
  "autoClose": true,
  "shortClose": "cancel-remainder",
  "supplierAlerts": {
    "damageRatePercent": 5,
    "lateRatePercent": 20,
    "minimumSample": 5,
    "windowDays": 90
  }
}
Response · 200 · application/json
{
  "poNumberPrefix": "PO-",
  "nextPoNumber": 3,
  "autoInvoiceOnReceipt": false,
  "autoClose": true,
  "shortClose": "cancel-remainder",
  "supplierAlerts": {
    "damageRatePercent": 5,
    "lateRatePercent": 20,
    "minimumSample": 5,
    "windowDays": 90
  }
}

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: purchasing-manager.openapi.json. Base URL https://purchasing.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.

409

RefusalWhat it meansWhat to do
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.

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.