Error Reference

This page is a quick reference for the error envelope returned by the Worksome GraphQL API. For a detailed guide on handling errors in your code, see Error Handling.

Error envelope

Every GraphQL error returned by the gateway includes an extensions.code field that identifies the broad failure mode. Use the code (not the message) to drive your control flow. Many platform-side errors also include a serviceName and a structured validation map.

Code HTTP Retryable Description
GRAPHQL_VALIDATION_FAILED 200 No The query references a field, argument, or type that does not exist on the schema. Fix the query.
GRAPHQL_PARSE_FAILED 200 No The GraphQL document could not be parsed (syntax error). Fix the query.
BAD_REQUEST 400 No The HTTP request shape is wrong (e.g. missing Content-Type: application/json, GET without an apollo-require-preflight header, or a body that is not valid JSON).
DOWNSTREAM_SERVICE_ERROR 200 Sometimes The query is valid but the platform rejected the operation. Discriminate using the additional extensions fields described below: presence of validation means input validation; guards: ["api"] with message: "Unauthenticated." means missing/invalid token; otherwise it is generally an authorization or business-rule failure.

Warning

Errors arrive over HTTP 200 in almost every case — GraphQL puts failures in the response body. Always parse the errors array, even if data is present.

Validation errors

Validation errors come back as DOWNSTREAM_SERVICE_ERROR with an extensions.validation map of dot-notation field paths to messages.

{
  "errors": [
    {
      "message": "Validation failed for the field [createDraftHire].",
      "path": ["createDraftHire"],
      "extensions": {
        "validation": {
          "input.startDate": ["The start date is not a valid date."],
          "input.trustedContact": ["The selected input.trusted contact is invalid."]
        },
        "serviceName": "platform",
        "code": "DOWNSTREAM_SERVICE_ERROR"
      }
    }
  ]
}

Common validation errors

Field pattern Error Resolution
input.{field} “The {field} field is required.” Include the required field in your input.
input.{field} “The {field} is not a valid date.” Use ISO 8601 format: YYYY-MM-DD.
input.{field} “The selected {field} is invalid.” Verify the ID exists, is the right entity type, and is reachable by the authenticated user.
input.rate “The rate must be a number.” Provide a numeric value (integer or float).
input.currency “The selected currency is invalid.” Use a valid ISO 4217 currency code (e.g., USD, GBP, EUR, DKK).

Authentication errors

A missing or invalid bearer token is also wrapped as DOWNSTREAM_SERVICE_ERROR, with the platform’s api guard listed in extensions.guards.

{
  "errors": [
    {
      "message": "Unauthenticated.",
      "extensions": {
        "guards": ["api"],
        "serviceName": "platform",
        "code": "DOWNSTREAM_SERVICE_ERROR"
      }
    }
  ]
}
Cause Resolution
Missing Authorization header Add Authorization: Bearer {token} to your request headers.
Expired token Tokens expire 6 months after creation. Generate a new Personal Access Token.
Revoked token The token was manually revoked. Create a new one.
Malformed header Ensure the format is exactly Bearer {token} with a single space.

Authorization errors

When the token is valid but the operation is not allowed for the authenticated user (or for the requested record), you also receive a DOWNSTREAM_SERVICE_ERROR. The envelope has no machine-readable “authorization” tag — discriminate by the absence of a validation map plus the operation path and message.

{
  "errors": [
    {
      "message": "You are not authorized to perform this action.",
      "path": ["terminateHire"],
      "extensions": {
        "serviceName": "platform",
        "code": "DOWNSTREAM_SERVICE_ERROR"
      }
    }
  ]
}
Cause Resolution
Insufficient role Ensure the API token belongs to a user with the required role (e.g., manager, admin).
Wrong company scope The resource belongs to a different company than the authenticated user.
Field-level restriction Some fields require elevated permissions. The field returns null in data with a corresponding entry in errors.

Query errors

The gateway validates the query against the schema before reaching the platform. Field/argument/type mismatches surface as GRAPHQL_VALIDATION_FAILED; pure syntax errors surface as GRAPHQL_PARSE_FAILED.

{
  "errors": [
    {
      "message": "Cannot query field \"nonExistent\" on type \"Hire\".",
      "locations": [{ "line": 3, "column": 5 }],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED"
      }
    }
  ]
}
Cause Resolution
Unknown field Check the field name against the schema reference.
Missing required argument Add the required argument to the field.
Type mismatch Ensure argument values match the expected types (e.g., ID! expects a string).
Syntax error Check for unclosed braces, missing commas, or invalid GraphQL syntax.

Bad request errors

The gateway rejects HTTP requests that do not conform to its expectations (e.g. missing Content-Type, GET without an apollo-require-preflight header) before reaching GraphQL.

{
  "errors": [
    {
      "message": "This operation has been blocked as a potential Cross-Site Request Forgery (CSRF). Please either specify a 'content-type' header (with a type that is not one of application/x-www-form-urlencoded, multipart/form-data, text/plain) or provide a non-empty value for one of the following headers: x-apollo-operation-name, apollo-require-preflight",
      "extensions": {
        "code": "BAD_REQUEST"
      }
    }
  ]
}
Cause Resolution
Missing Content-Type Send Content-Type: application/json on every POST.
GET request Use POST. If you genuinely need GET (e.g. for caching), add apollo-require-preflight: true.
Body is not JSON Make sure the body is a JSON object with query (and optional variables/operationName).

Server errors

If the platform itself fails (timeout, unhandled exception), the gateway forwards a DOWNSTREAM_SERVICE_ERROR with serviceName: "platform" and a generic message. These are typically transient — retry with exponential backoff (1s, 2s, 4s) up to 3 times. If the error persists, contact Support with the full error response and your query.

Rate limiting

The Worksome platform applies rate limiting per API token (default 60 requests per minute). When you exceed the limit, the gateway forwards a DOWNSTREAM_SERVICE_ERROR; the gateway does not currently expose X-RateLimit-* headers on the response. Treat repeated DOWNSTREAM_SERVICE_ERROR responses with a “Too Many Requests” message as rate-limit signals, and back off. See Rate Limiting for details.

Partial responses

GraphQL can return both data and errors in the same response. Always check the errors array even when data is present.

{
  "errors": [
    {
      "message": "You are not authorized to access this field.",
      "path": ["hire", "rate"],
      "extensions": {
        "serviceName": "platform",
        "code": "DOWNSTREAM_SERVICE_ERROR"
      }
    }
  ],
  "data": {
    "hire": {
      "id": "SGlyZTox",
      "rate": null
    }
  }
}

Fields that error return null in the data, with corresponding entries in the errors array. Use the available data and handle individual field errors gracefully.