Errors and limits

What a refused request tells you, and how to retry safely.

A refused request answers with a status code and a JSON body that says what went wrong in a sentence you can show in a log. The code field stays the same from one version to the next, so match on that rather than the wording.

A refused request
{
  "type": "https://unforged.sh/problems/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "name: the client needs a name",
  "code": "invalid_request"
}

The codes you’ll see

400 invalid_request
Something in the request is missing or wrong. The detail names it.
401 unauthorized
No key, or a key that’s been removed.
403 permission_denied
The key reads only and the request would change something.
404 not_found
No client, contact or matter with that id in your firm.
409 conflict
It changed since you read it (send the version you have), or an Idempotency-Key was reused with a different request.
429 rate_limited
Too many requests in a short time. Wait for the seconds in the Retry-After header, then try again.

Retrying without doubling up

Every POST needs an Idempotency-Key header: any string up to 255 characters, such as a UUID or your own record’s id. If the connection drops and you send the same request again with the same key within 24 hours, you get the first answer back and nothing is added twice.

Changing something someone else changed

Clients, contacts and matters carry a version number. Send the version you read when you change one. If someone has changed it since, you get a 409, so you can read it again and decide what to do, instead of quietly overwriting their work.