---
title: Errors and retries
summary: What each status means, what to do about it, and which writes are safe to send twice.
group: Get started
order: 40
---

## Status codes

| Status | Body | Meaning | What to do |
| --- | --- | --- | --- |
| `200` / `201` | envelope | Success. `201` usually means something was created. | For `POST /v1/sales`, success means **queued**: confirm with `GET /v1/sales/{pid}`. |
| `400` | envelope | The request is wrong: a missing or invalid field, an unknown query parameter, bad JSON. `data` often names the field. | Fix the request. Don't retry it unchanged. |
| `401` | `{"message":"Unauthorized"}` | Token missing, mistyped, expired, paused or deleted. | Fix or rotate the token. Don't retry in a loop. |
| `403` | envelope | Your company can't use this endpoint (for example sales endpoints for SequiPay-only companies). | Contact Sequifi. |
| `403` | `{"message":"Missing Authentication Token"}` | The path or method doesn't exist. | Check the path, the method and for a trailing slash. |
| `404` | envelope | No record with that id **in your company**. | Check the id came from this company's data. |
| `409` | envelope with `data.code` | Conflicts with the current state: already done, already exists, in progress. | Read `data.code`. On a retry it often means your first attempt succeeded. |
| `422` | envelope with `data.code` | Valid JSON, but the change isn't allowed (for example a date that breaks a rule). | Fix the input. |
| `429` | `{"message":"Too Many Requests"}` | Too many requests. | Back off exponentially (1s, 2s, 4s, ...) and retry. |
| `429` | envelope with `data.code` and a `Retry-After` header | A per-company limit on an expensive endpoint, such as `POST /v1/sales/{pid}/recalculate`. | Wait the `Retry-After` seconds, then retry. Read `data.code` for which limit. |
| `500` | envelope | Unexpected error. | Retry once after a short wait; if it repeats, contact Sequifi with the time and the request. |
| `502` / `503` | envelope or gateway body | Sequifi could not complete a change it forwards internally, or is busy. | Retry with backoff. For a write, check first whether it already landed (table below). |
| `504` | `{"message":"Endpoint request timed out"}` | No answer within about 29 seconds. **The write may still have happened.** | Check before retrying a write (table below). |

## Is it safe to send again?

A timeout or dropped connection leaves you not knowing whether a write landed. This is what a repeat does:

| Write | Repeat after success | Safe practice |
| --- | --- | --- |
| `POST /v1/sales` | Updates the same sales (keyed by `pid`) | Safe. Re-send the whole batch with the same `pid`s. |
| `POST /v1/users` (profile update) | Writes the same values again | Safe with the same body. |
| `POST /v1/users/{id}/terminate` | `200` with `already_terminated: true` | Safe with the same date. A different date returns `409`. |
| `POST /v1/users/{id}/transfer` | Usually `200` again; sometimes `409` `NO_CHANGE` | Safe with the same body. Treat `NO_CHANGE` as "already done". |
| `POST /v1/users/{id}/position` | Converges on the same position | Safe. |
| `POST /v1/users/termination` | **Flips the user back** | Not safe: it is a toggle. Read the user's status first. |
| `POST /v1/onboarding` (create) | `400` "Email or mobile number already exists." | Find the record with `GET /v1/onboarding?email=` instead of retrying. |
| `PUT /v1/onboarding/hire` | `400` "already exists" | Check `GET /v1/users?email=` before retrying. |
| `POST /v1/onboarding/{id}/send-offer` | `409` `NOT_SENDABLE` | Safe: a repeat never sends a second offer. |
| `POST /v1/teams` | `409` `TEAM_ALREADY_EXISTS` or `CREATE_IN_PROGRESS` | Safe if you repeat the identical body. Don't change the name, manager or start date on a retry. |
| `POST /v1/timesheet` | Depends on the entry type | See the endpoint page before retrying. |
| `PATCH /v1/payroll-history` | Writes the same journal ids | Safe with the same ids. A different id replaces the first one. |
| `POST /v1/sales/{pid}/recalculate` | Same result. Within 10 minutes: `429` `COOLDOWN` with `data.last_run` | Safe. `data.last_run.outcome` says whether the first attempt landed. |

## Retry recipe

1. Retry only `429`, `500`, `502`, `503`, `504` and network errors. Never retry `400`, `401`, `403`, `404` or `422` unchanged.
2. Wait 1, 2, 4, 8 seconds between attempts (add a little random jitter); stop after about five. When the response has a `Retry-After` header, wait that many seconds instead.
3. Before retrying a write that is not marked safe above, read back the state first.
4. Log the HTTP status, the response body and the time of every failure. That is what Sequifi support needs.
