Skip to content

Give a code to the orders that have none

POST
/order-format-settings/missing-codes
Code sample: Shell / cURL
curl --request POST \
--url https://example.com/api/v1/order-format-settings/missing-codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "clientId": "example", "dryRun": true }'

Gives every order that has no code the code a new order of its company and type would get, numbered oldest first (start date, else creation date) after the highest number already issued under the same prefix and type code; a template’s {year} is the order’s own year. An order whose name starts with a code in square brackets, such as [AG-S01] Sprint, takes that code as written, with no number issued, unless another order of the workspace already holds it as its code or an alias (ignoring case) or an older order of the run names it first; those are numbered as usual and counted in bracketFallbacks. An order that already has a code is never changed. An order is skipped, and counted by reason, when its company has no prefix (NO_COMPANY_PREFIX), its order type has no code (NO_TYPE_CODE), the workspace has code generation off (CODES_DISABLED), or another order took the generated code while the run was writing it (CODE_TAKEN; run it again). Each assignment is audited like an edit of the order’s code. It is safe to repeat: a second run assigns nothing. dryRun defaults to true, so a call without it only previews; the response counts the orders per company and per skip reason and lists a sample of the codes. 404 when clientId is not a company of the workspace. Requires the settings.manage permission.

Media typeapplication/json
object
clientId

Limits the run to the orders of this company; omit it to cover the workspace.

string
>= 1 characters
dryRun

When true (the default) nothing is written and the response says what would be assigned. Send false to assign the codes.

boolean
default: true

What was assigned, or would be on a dry run.

Media typeapplication/json
object
data
required

What assigning codes to the orders that have none did, or would do.

object
assigned
required

Orders given a code, or that would be on a dry run.

integer
<= 9007199254740991
bracketFallbackOrders

The first 25 of the bracketFallbacks orders, by id and name. Absent on an older server.

Array<object>
object
orderId
required
string
orderName
required
string
bracketFallbacks
required

Orders that wanted the code their name starts with and were numbered as usual, because another order holds it or an older order of the run names it first.

integer
<= 9007199254740991
bracketed
required

Of the assigned orders, those that took the code their name starts with.

integer
<= 9007199254740991
companies
required

The counts per company that had orders without a code.

Array<object>
object
assigned
required
integer
<= 9007199254740991
clientId
required
string
clientName
required
string
prefix
required
string | null
skipped
required
integer
<= 9007199254740991
skippedByReason
required

Only the reasons that apply to this company.

object
CODES_DISABLED
integer
<= 9007199254740991
CODE_TAKEN
integer
<= 9007199254740991
NO_COMPANY_PREFIX
integer
<= 9007199254740991
NO_TYPE_CODE
integer
<= 9007199254740991
dryRun
required

True when nothing was written.

boolean
missing
required

Orders without a code when the run started, within the company asked for.

integer
<= 9007199254740991
sample
required

A few of the codes: the oldest orders of several companies, then a few that took the code of their name.

Array<object>
object
bracketed
required

True when the code is the one the order’s name starts with.

boolean
clientName
required
string
code
required

The code given, or that would be.

string
orderId
required
string
orderName
required
string
skipped
required

Orders left without a code.

integer
<= 9007199254740991
skippedByReason
required

The skipped orders by why they could not be coded.

object
CODES_DISABLED
required
integer
<= 9007199254740991
CODE_TAKEN
required
integer
<= 9007199254740991
NO_COMPANY_PREFIX
required
integer
<= 9007199254740991
NO_TYPE_CODE
required
integer
<= 9007199254740991

Example generated

{
"data": {
"assigned": 1,
"bracketFallbackOrders": [
{
"orderId": "example",
"orderName": "example"
}
],
"bracketFallbacks": 1,
"bracketed": 1,
"companies": [
{
"assigned": 1,
"clientId": "example",
"clientName": "example",
"prefix": "example",
"skipped": 1,
"skippedByReason": {
"CODES_DISABLED": 1,
"CODE_TAKEN": 1,
"NO_COMPANY_PREFIX": 1,
"NO_TYPE_CODE": 1
}
}
],
"dryRun": true,
"missing": 1,
"sample": [
{
"bracketed": true,
"clientName": "example",
"code": "example",
"orderId": "example",
"orderName": "example"
}
],
"skipped": 1,
"skippedByReason": {
"CODES_DISABLED": 1,
"CODE_TAKEN": 1,
"NO_COMPANY_PREFIX": 1,
"NO_TYPE_CODE": 1
}
}
}

Validation error. Parse failures include field paths and expectations.

Media typeapplication/json

Validation error with safe field paths and expected values; submitted values are never returned.

object
error
required
object
code
required

Stable machine-readable error code.

string
issues
Array<object>
object
expected
required
string
message
required
string
path
required
Array<string | number>
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Unauthorized.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Forbidden.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Not found.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Rate limit exceeded. Wait for Retry-After before retrying.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}
RateLimit-Limit
string
/^\d+$/

Maximum requests in the current quota window.

RateLimit-Policy
string

Quota policy in requests and window seconds, for example 60;w=60.

RateLimit-Remaining
string
/^\d+$/

Requests left in this quota window (zero when blocked).

RateLimit-Reset
string
/^\d+$/

Seconds until the current quota window resets, when available from the rate-limit store.

Retry-After
string
/^\d+$/

Seconds until another request may be attempted.