Kosmobids Public API

Errors and limits

Response envelopes, status-code semantics, retryability, and the hard limits enforced by the Public API.

Two error shapes

Endpoint handlers use the typed response envelope:

{
  "data": { "message": "Tender not found" },
  "error": null
}

Authentication middleware runs before the typed handler and returns a plain error object:

{
  "error": "Unauthorized",
  "message": "Invalid API key"
}

Always branch on the HTTP status first. If the body has a top-level error string, read message; otherwise read data.

Status codes

Status Typical body Meaning Retry?
200 { data, error: null } Success. —
201 { data, error: null } Created. —
202 { data, error: null } Asynchronous work accepted. —
400 Validation detail Private-API validation error. The public API normally normalises this to 422. No
401 { error, message } Missing or invalid API key. No
403 { error, message } or { data: {}, error: null } The key has no access to the endpoint, has no company scope, or is scoped to a different company. No
404 { data: { message }, error: null } The resource does not exist or belongs to another company. No
409 { data: { error, message }, error: null } A business rule blocks the request, such as the saved-search limit or documents not being ready. No
422 { data: null, error: [...] } Request validation failed. No
429 { error, message } A rate-limit window is exhausted. Yes, after Retry-After
500 { error, message } or { data: { error }, error: null } Unexpected server error, including internal service-authentication failures. Once, then escalate
502 { data: { error }, error: null } The internal service request failed. Yes, with backoff
503 { data: { error }, error: null } A required backend service is not configured or unavailable. Yes, with backoff

Validation errors

422 contains an array of issues:

{
  "data": null,
  "error": [
    {
      "field": "body.questions",
      "type": "body",
      "message": "Too small: expected array to have >=1 items"
    }
  ]
}

field uses the request location (body, query, param, or general). Multiple issues can be returned. Fix every reported issue before retrying.

Retry and timeout guidance

  • Retry 502 and 503 with exponential backoff.
  • Retry 429 only after Retry-After (or the x-rate-limit-*-reset header) has elapsed.
  • Treat 500 as transient once, then alert.
  • Never retry 401, 403, 404, 409, or 422 without changing the request or the resource state.
  • A final error, failed, or aborted workflow is not retried by polling. Start a new run or analysis.
  • Use a client timeout that is longer than a single request's expected latency, and keep polling outside that timeout.

Hard limits

Limit Value
Saved searches per company 10
Pipeline page size 1–100, default 25
Matching runs page size 1–100, default 50
Run matches page size 1–500, default 25
Look-alike results 1–100, default 25
Analysis questions 1–20
CPV code length 8 characters
Semantic search phrase length at least 5 characters
Request body size 10 MB

Formats

  • Dates and timestamps in responses are ISO 8601 strings. Requests accept ISO 8601 date strings; relative windows are expressed with submissionDeadlineAtLeastDays and publishedDaysAgo.
  • IDs are opaque strings. The tender detail endpoint expects the UUID-shaped tender (lot) ID returned by the API; document, notice, and workflow IDs are opaque.
  • Unknown request fields are ignored. Do not rely on this for forward compatibility; only send documented fields.
  • Unknown response fields may appear. Ignore them.

Rate limits

Every authenticated request is counted against a per-company bucket with three windows:

Window Default limit
1 second 3 requests
1 minute 100 requests
1 hour 1,000 requests

Some endpoints have a tighter per-minute limit. A request is rejected with 429 when any window is exhausted; rejected requests do not consume quota.

Every authenticated response carries the current state of each window:

x-rate-limit-second-limit: 3
x-rate-limit-second-remaining: 2
x-rate-limit-second-reset: 1730000001
x-rate-limit-minute-limit: 100
x-rate-limit-minute-remaining: 87
x-rate-limit-minute-reset: 1730000042
x-rate-limit-hour-limit: 1000
x-rate-limit-hour-remaining: 990
x-rate-limit-hour-reset: 1730001830
  • *-remaining is the number of requests left in that window.
  • *-reset is the Unix epoch second at which the window resets.
  • A 429 response also includes Retry-After in seconds.

Use Retry-After (or the reset headers) instead of fixed sleeps. Requests rejected with 429 were not executed.