{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tune.toys/schemas/platform/api-error.schema.json",
  "title": "ApiError",
  "description": "Error envelope returned by every failing API response. `requestId` echoes the X-Request-Id response header.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[A-Z][A-Z0-9_]*$",
          "description": "Stable machine-readable code, for example RATE_LIMIT, SCOPE or KEY_INVALID."
        },
        "message": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500,
          "description": "Human-readable explanation; never parse it."
        },
        "details": {
          "type": "object",
          "maxProperties": 16,
          "description": "Bounded machine-readable context such as requiredScopes or rate-limit state."
        },
        "requestId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        }
      },
      "required": ["code", "message"]
    }
  },
  "required": ["error"]
}
