# Errors

Trace One APIs use standard HTTP status codes. When a request fails, the body says why.

## Status codes

| Status | Meaning | What to do |
|  --- | --- | --- |
| `400 Bad Request` | The request is malformed: invalid JSON, wrong type, missing parameter | Fix the request. Do not retry it unchanged |
| `401 Unauthorized` | The token is missing, expired or invalid | Get a new token and retry once. See [Authentication](/getting-started/authentication) |
| `403 Forbidden` | Your company has no access to this resource or operation | Do not retry |
| `404 Not Found` | The resource does not exist, or is not visible to your company | Do not retry |
| `412 Precondition Failed` | The `If-Match` value is out of date: the resource changed since you read it | Read it again, apply your change, retry. See [Writing to the Specification API](/getting-started/writing-to-specification) |
| `422 Unprocessable Content` | The request is valid JSON, but a value is refused, or the resource's state does not allow the change | Read `errors[]`, fix the value or the resource, then retry |
| `429 Too Many Requests` | You sent too many requests | Retry with exponential backoff. See [Rate limits](/getting-started/rate-limits) |
| `5xx` | Server or gateway error | Retry with exponential backoff. If it persists, [contact us](/getting-started/support) |


Trace One APIs do not use `409 Conflict`. A refused change is a `422`; a concurrency conflict is a `412`.

## Error body

Errors use the [RFC 9457 Problem Details](https://www.rfc-editor.org/rfc/rfc9457) format (`application/problem+json`), with an `errors` array that lists each problem:

```json
{
  "type": "https://tools.ietf.org/html/rfc4918#section-11.2",
  "title": "Unprocessable Content",
  "status": 422,
  "detail": null,
  "instance": null,
  "errors": [
    {
      "code": "UNPROCESSABLE_CONTENT",
      "property": "unitOfMeasureId",
      "message": "Unknown unit of measure."
    }
  ]
}
```

| Field | Description |
|  --- | --- |
| `status`, `title`, `type` | The HTTP status and its standard description |
| `errors[].code` | Stable, machine-readable code. Use it in your code |
| `errors[].property` | The request field the error is about, as named in the request. `null` when the error is not about one field |
| `errors[].message` | Text for people and logs. It can change: do not test it in your code |


Other fields (`detail`, `instance`, `legacyCode`) may appear. Do not depend on them.

## Error codes

| Code | Status | Meaning |
|  --- | --- | --- |
| `UNPROCESSABLE_CONTENT` | `422` | A value in the request is refused. `property` names it |
| `INVALID_RESOURCE_STATE` | `422` | The resource's state does not allow the change (for example, it is locked during signature). Fix the resource, not the request. `property` is `null` |
| `NAME_ALREADY_USED` | `422` | The name is already used by another object of your company. Pick another name |
| `PRECONDITION_FAILED` | `412` | The `If-Match` value is out of date |


An operation lists the codes it can return in the API reference.

## Specification API: current error body

Changing soon
The Specification API is moving to the format above. Until then, its `422` body has different field names:

```json
{
  "message": "Errors have occured",
  "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
  "errors": [
    {
      "errorCode": "UNPROCESSABLE_CONTENT",
      "errorMessage": "Unknown product type.",
      "paramName": "productTypeId",
      "legacyErrorCode": null
    }
  ]
}
```

| Current field | Field in the new format |
|  --- | --- |
| `errors[].errorCode` | `errors[].code` |
| `errors[].paramName` | `errors[].property` |
| `errors[].errorMessage` | `errors[].message` |


The codes do not change. Read both field names if you integrate now.

## Best practices

- Use `errors[].code` in your code, never the message text.
- Show `errors[].property` to the person who fixes the data.
- Log the full response body, with the time and the request URL.
- When you [contact us](/getting-started/support) about an error, send that log.


## Next steps

- [Writing to the Specification API](/getting-started/writing-to-specification) — updates, concurrency, refusals
- [Rate limits](/getting-started/rate-limits) — the limit and how to retry