Explicitly check billing before closing an order
All field references · Shipping
POST /v1/dispatches/closure/preview
Reads only the same permitted service billing as the user interface. Returns a freshness token that does not replace any permission. After a partial shipment, services are preserved; later credits are a separate operation.
Required scopes: "dispatch:close".
#Request body
Request body required.
Content type: application/json
| Field | Type | Presence | null | Meaning, limits and examples |
|---|---|---|---|---|
| $ (whole value) | object | Whole value | Not allowed | Additional properties are not allowed. |
| order_id | string | Required when parent is present | Not allowed | Meykt order ID from authorized reads; not order number/external reference. format: "uuid". |
#Response 200
200: Success
Content type: application/json
| Field | Type | Presence | null | Meaning, limits and examples |
|---|---|---|---|---|
| $ (whole value) | object | Whole value | Not allowed | Additional properties are not allowed. |
| data | object | Required when parent is present | Not allowed | Authorized response payload or documented event data. Additional properties are not allowed. |
| data.closure | object | Required when parent is present | Not allowed | Current order-closure state and any required next action. Additional properties are not allowed. |
| data.closure.order_id | string | Required when parent is present | Not allowed | Meykt order identifier from an authorized order read; not the order number or external reference. format: "uuid". |
| data.closure.quantities_closed | boolean | Required when parent is present | Not allowed | Whether every required quantity has been shipped, cancelled or otherwise explicitly resolved. |
| data.closure.state | string | Required when parent is present | Not allowed | Current state of this operation; processing or decision states do not confirm completion. enum: ["open","closed","work_review_required","billing_review_required"]. |
| data.closure.final_status | alternative (anyOf) | Required when parent is present | Allowed by schema | Order status after the closure operation. |
| data.closure.final_status | string | Conditional: anyOf 1/2 | Not allowed | anyOf 1/2: At least one alternative must match. Order status after the closure operation. enum: ["cancelled","completed","shipped"]. |
| data.closure.final_status | null | Conditional: anyOf 2/2 | Allowed by schema | anyOf 2/2: At least one alternative must match. Order status after the closure operation. |
| data.closure.next_action | alternative (anyOf) | Required when parent is present | Allowed by schema | Next permitted step suggested by the current operation state. |
| data.closure.next_action | string | Conditional: anyOf 1/2 | Not allowed | anyOf 1/2: At least one alternative must match. Next permitted step suggested by the current operation state. enum: ["resolve_existing_work","review_cancellation_billing"]. |
| data.closure.next_action | null | Conditional: anyOf 2/2 | Allowed by schema | anyOf 2/2: At least one alternative must match. Next permitted step suggested by the current operation state. |
| data.closure.may_reverse_billing | boolean | Required when parent is present | Not allowed | Whether the current closure state permits reversing booked services. |
| data.billing | object | Required when parent is present | Not allowed | Service billing positions authorized for this explicit closure decision. Additional properties are not allowed. |
| data.billing.order_id | string | Required when parent is present | Not allowed | Meykt order ID from authorized reads; not order number/external reference. format: "uuid". |
| data.billing.preview_token | string | Required when parent is present | Not allowed | Freshness token returned by the matching preview; send it unchanged with the approved operation. pattern: "^[a-f0-9]{32}$". |
| data.billing.billing_choice | alternative (anyOf) | Required when parent is present | Allowed by schema | Explicit billing decision: preserve keeps booked services, reverse requests reversal where permitted. |
| data.billing.billing_choice | string | Conditional: anyOf 1/2 | Not allowed | anyOf 1/2: At least one alternative must match. Explicit billing decision: preserve keeps booked services, reverse requests reversal where permitted. enum: ["preserve","reverse"]. |
| data.billing.billing_choice | null | Conditional: anyOf 2/2 | Allowed by schema | anyOf 2/2: At least one alternative must match. Explicit billing decision: preserve keeps booked services, reverse requests reversal where permitted. |
| data.billing.positions | array | Required when parent is present | Not allowed | Inventory or billing positions returned by this authorized operation. maxItems: 10000. |
| data.billing.positions[] | object | Every array item | Not allowed | Additional properties are not allowed. |
| data.billing.positions[].id | string | Required when parent is present | Not allowed | Stable entry identifier. format: "uuid". |
| data.billing.positions[].service_name | string | Required when parent is present | Not allowed | Display name of the booked service. |
| data.billing.positions[].quantity | number | Required when parent is present | Not allowed | Quantity represented as a JSON number in the stated unit. |
| data.billing.positions[].unit | string | Required when parent is present | Not allowed | Exact offered unit; no implicit carton, weight or dimension conversion. |
| data.billing.positions[].unit_price | number | Required when parent is present | Not allowed | Price per unit in the accompanying currency; interpret its tax basis as documented for this operation. |
| data.billing.positions[].amount | number | Required when parent is present | Not allowed | Monetary amount in the accompanying currency. |
| data.billing.positions[].currency | string | Required when parent is present | Not allowed | Currency code for the supplied monetary amounts. |
| data.billing.positions[].credited | boolean | Required when parent is present | Not allowed | Whether this booked service position has already been credited. |
| data.billing.totals | array | Required when parent is present | Not allowed | Monetary totals grouped by their stated currency. maxItems: 1000. |
| data.billing.totals[] | object | Every array item | Not allowed | Additional properties are not allowed. |
| data.billing.totals[].currency | string | Required when parent is present | Not allowed | Currency code for the supplied monetary amounts. |
| data.billing.totals[].amount | number | Required when parent is present | Not allowed | Monetary amount in the accompanying currency. |
| data.billing.run_count | integer | Required when parent is present | Not allowed | Number of production runs included in this closure decision. minimum: 0. maximum: 1000. |
#Response 401, 403, 404, 409, 413, 422, 429, 500, 503
401: The key is missing, unknown, revoked or expired. 403: The key lacks a required scope, or the operation requires a live key. 404: Not found. Also applies to IDs that belong to another organization — we deliberately do not distinguish between "does not exist" and "does not belong to you". 409: The same ID already exists with different content. It is never overwritten. 413: The JSON request exceeds 256 KiB. 422: Content validation failed. The response lists all affected locations at once. 429: A rate limit was reached and the request did not run. Wait for Retry-After, then repeat it unchanged. X-RateLimit-Scope names the limit: key (120 requests per minute), organization (300 per minute across all keys), write (1,000 at once, refilling at 60 per minute) or list (300 unfiltered list pages at once, refilling at 10 per minute). 500: Unexpected error on our side. 503: Temporarily unavailable. Repeat the same request with the same business identity.
Content type: application/json
| Field | Type | Presence | null | Meaning, limits and examples |
|---|---|---|---|---|
| $ (whole value) | object | Whole value | Not allowed | — |
| error | object | Required when parent is present | Not allowed | Machine-readable error code; use it to select the documented recovery path. |
| error.code | string | Required when parent is present | Not allowed | Machine-readable, permanently stable error code. Program against it, not against message. |
| error.message | string | Required when parent is present | Not allowed | Explanation for humans. May change at any time. |
| error.field | string | Optional | Not allowed | Affected location in the request, if it can be determined. |
| error.doc_url | string | Required when parent is present | Not allowed | Documentation link explaining this API error. format: "uri". |
Machine-readable version of this page: https://www.meykt.com/developers/fields-preview-dispatch-closure.md