Errors
The error body, the statuses, and the partner's codes with what to do next.
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 partner's codes
| Code | Status | Routes | What your system does |
|---|---|---|---|
PARTNER_ITEM_NOT_FOUND | 404 | A card by its id | Check the id. Another partner's card gives this code too |
PARTNER_ITEM_SOLD | 409 | The price adjustment, a take-back | Stop: the card is sold and can no longer change. Read its state |
PARTNER_ITEM_TAKEN_BACK | 409 | The price adjustment | Stop: you asked to take the card back |
PARTNER_WEBHOOK_URL_INVALID | 409 | Set the webhook | Use an address with a public host |
PARTNER_WEBHOOK_NOT_SET | 409 | A new webhook secret | Set a webhook address first. It makes a secret |
PARTNER_STATEMENT_DAY_NOT_CLOSED | 409 | Statements | Wait: a day closes at 00:01 UTC of the next day |
SERVICE_UNAVAILABLE | 503 | The cards, the price adjustment, a take-back, the intakes | Send the request again after the seconds of the header Retry-After |
ROUTE_NOT_FOUND | 404 | Any path that does not exist | Check the path |
The routes of your record, your webhook, the report lines and the statements never answer 503 for another part of Grail Network.