PentesysDocs Sign in

Requests, errors and limits

The conventions every endpoint follows: request format, the error shape and every error code, rate limits, and how to retry safely.

Applies to
Public API v1
For
Developers, integrators
Reading time
2 min
Last updated
26 November 2026

Requests#

  • HTTPS only. Send Authorization: Bearer pts_… on every request.
  • Read with GET and query parameters. Change with POST and a JSON body, with Content-Type: application/json.
  • Write endpoints need a read and write key and the matching permission.
  • Creating something (a validation request, a risk decision request, a discussion topic or reply, a report) returns 201 Created; other writes return 200 OK. Both return the resulting object.
  • Dates are ISO 8601: 2026-12-31 for dates, 2026-11-26T10:15:00+00:00 for times. Money is in pence, in GBP.
  • Invalid input is rejected before anything changes.

The error shape#

Every error, from every endpoint, has the same shape:

{
  "error": {
    "code": "validation_failed",
    "message": "The request was not valid.",
    "details": { "status": ["The selected status is invalid."] }
  }
}

Branch on error.code (stable); show error.message to people; details appears for validation errors and lists problems per field.

Error codes#

HTTPCodeMeaningWhat to do
401missing_api_keyNo Authorization header, or it is empty.Send the key as a bearer token.
401invalid_api_keyThe key is malformed, unknown, expired or revoked.Create a new key. Do not retry.
403read_only_keyA read-only key tried to change something.Use a read and write key, if the job really writes.
403account_disabledYour account is disabled, suspended or no longer in the organisation.Contact your administrator.
403api_keys_disabledYour organisation turned API keys off.Contact your administrator.
403forbiddenYour role lacks the permission. The message names it.Ask for the permission.
404not_foundIt does not exist, or it is outside your organisation or asset groups.Check the code and your scope.
405method_not_allowedWrong HTTP method for the path.Check the reference.
422validation_failedA parameter or field is invalid; see details. Some business rules are also reported this way, with a message that explains them.Fix the input. Do not retry unchanged.
429rate_limitedMore than 60 requests in a minute with this key.Wait for Retry-After seconds, then retry.
502upstream_errorThe service could not complete the request.Retry with back-off.
503upstream_unavailable, identity_unavailableA temporary problem.Retry with back-off.

Rate limits#

Each API key may make 60 requests per minute. MCP tool calls have their own, separate limit. Responses carry the standard headers:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57

When you exceed the limit you get 429 rate_limited with a Retry-After header in seconds. Tips:

  • Use per_page=100 for exports rather than many small pages.
  • Run jobs sequentially rather than in parallel with the same key.
  • Cache slowly-changing data (roles, asset groups) for a few minutes.

Retrying safely#

ResponseRetry?
429Yes, after Retry-After.
502, 503, network errors, timeoutsYes, with exponential back-off (1 s, 2 s, 4 s, 8 s…) and a limit.
400, 401, 403, 404, 405, 422No. Fix the request, key or permission.

Updates such as setting an owner or a status can be repeated safely: sending the same values twice leaves the same result. Creating requests (validation, risk decisions, topics, reports) creates a new item each time, so check before retrying a POST that may have succeeded.

import time, requests

def call(session, method, url, **kw):
    for attempt in range(5):
        r = session.request(method, url, timeout=30, **kw)
        if r.status_code == 429:
            time.sleep(int(r.headers.get("Retry-After", "5")))
            continue
        if r.status_code in (502, 503):
            time.sleep(2 ** attempt)
            continue
        if r.status_code >= 400:
            err = r.json()["error"]
            raise RuntimeError(f'{r.status_code} {err["code"]}: {err["message"]}')
        return r.json()
    raise RuntimeError("Pentesys API unavailable after retries")