Flavours Partner API

Errors

The response envelope, HTTP status codes, and the validation-error format.

Every response — success or error — uses the same envelope. Read meta.status to branch, meta.code for the machine-readable outcome (it mirrors the HTTP status), and meta.message for a human-readable summary.

The envelope

{
  "meta": {
    "code": 200,
    "status": "success",
    "message": "Product list retrieved successfully."
  },
  "data": { }
}
FieldTypeDescription
meta.codeintegerMirrors the HTTP status code.
meta.statusstring"success" or "error".
meta.messagestring | nullHuman-readable summary of the outcome.
dataobject | array | nullThe payload on success; error details (or null) on failure.

There is no top-level errors key

Unlike a default Laravel API, Flavours does not return a top-level errors object. Everything lives under meta and data. On a validation failure the field errors are an array inside data — see below.

HTTP status codes

Statusmeta.statusWhen
200successThe request succeeded.
400errorMalformed request.
401errorMissing or invalid credentials.
403errorAuthenticated, but not allowed to perform this action.
404errorThe resource (or route) does not exist.
405errorThe HTTP method is not allowed on this route.
422errorValidation failed. data lists the field errors.
429errorRate limit exceeded — see Rate limiting.
500errorAn unexpected server error.

Successful responses are always 200

Write endpoints (create, update) also return 200 — not 201 — on success. Branch on meta.status, and read the created or updated resource from data.

Validation errors (422)

When a request fails validation, the response is HTTP 422. meta.message carries a summary, and data is a flat array of field errors, one entry per failing rule:

{
  "meta": {
    "code": 422,
    "status": "error",
    "message": "The name field is required."
  },
  "data": [
    {
      "code": 0,
      "message": "The name field is required.",
      "field": "name"
    },
    {
      "code": 0,
      "message": "The selected branch is invalid.",
      "field": "branch"
    }
  ]
}

Each error item has:

FieldTypeDescription
codeintegerReserved for a future error taxonomy; currently always 0.
messagestringHuman-readable description of the failing rule.
fieldstringThe input field that failed.

Field names are normalised

The field value drops the _id / _ids suffix of the underlying column: a failure on branch_id is reported as field: "branch". Match on the base name, not the raw column.

Other error examples

A missing or invalid credential returns 401:

{
  "meta": {
    "code": 401,
    "status": "error",
    "message": "Unauthenticated."
  },
  "data": null
}

A resource that does not exist returns 404:

{
  "meta": {
    "code": 404,
    "status": "error",
    "message": "Resource not found."
  },
  "data": null
}

An unexpected server error returns 500 with a generic message (internal details are never leaked):

{
  "meta": {
    "code": 500,
    "status": "error",
    "message": "Something went wrong, please try again later."
  },
  "data": null
}

Don't parse messages

meta.message wording is meant for humans and may change. Branch your code on meta.code / the HTTP status and, for 422, on the field values in data — never on the message string.

On this page