Errors
The error body, the statuses, and where each route lists its codes.
The error body
An error answer has the content type application/problem+json (RFC 9457, "Problem Details for HTTP APIs"):
{
"status": 409,
"code": "PULL_BALANCE_TOO_LOW",
"detail": "The shop's balance is lower than the amount of the pull.",
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736"
}codeis the error's name. It never changes. Your code branches oncode, never ondetail.detailis a text for a developer. It can change. Never show it to a buyer.traceIdnames the request in Grail Network's logs. Send it to Grail Network when you report a problem.
The statuses
| Status | Meaning | What to do |
|---|---|---|
400 VALIDATION_FAILED | A field of the request does not fit its schema. errors lists each field with field and message | Correct the request. Do not send it again as it is |
| 401 | The API key is missing or not valid | Check the header and the key |
403 FORBIDDEN | The key may not call this route | Use the routes of your own section |
| 404 | The record does not exist, or it is not yours | Check the id |
| 409 | The state of the data refuses the request, such as a balance that is too low | Read code. Each route's page lists its codes |
| 503 | Another part of Grail Network gave no answer | Send the request again later |
| 500 | A mistake of Grail Network | Report it with the traceId |
A business error is always 404 or 409. Grail Network never answers 422.
An example of 400:
{
"status": 400,
"code": "VALIDATION_FAILED",
"detail": "The request does not fit its schema.",
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"errors": [{ "field": "packCount", "message": "Too big: expected a number of at most 5" }]
}The codes of each route
| Area | Where its codes are |
|---|---|
| A pull | Purchases of packs |
| A proof | PULL_PROOF_NOT_FOUND (404): the pull is not completed. See Check a pull |
| A pack | PACK_NOT_FOUND (404). See Packs |
| A sale back | Holdings |
| A quote and an order | Shipping |
A request that fails stays failed: a pull, a market purchase and an order answer their first error to each repeat of the same request. To try again, send a new request id (and a new commitment for a pull, a new quote for an order).