Skip to main content
Every list endpoint in the Terminus Hub Public API returns results using a consistent pagination envelope, and every error (regardless of the endpoint or failure reason) uses the same error object structure. Learning these two patterns once means you can handle them uniformly across your entire integration.

Pagination

All list endpoints (GET /api/v1/workspaces, GET /api/v1/records, etc.) return a shared response envelope containing the page of results, a flag indicating whether more pages exist, and the total count of matching resources.

Query Parameters

Control pagination by passing the following query parameters on any list request:
page
integer
default:"1"
The page number to retrieve. Pages are 1-indexed. The first page is page=1. Omit this parameter to start from the beginning.
limit
integer
default:"100"
The number of items to return per page. Must be between 1 and 10000 (inclusive). Defaults to 100 if not specified.

Example Paginated Request

The following request fetches the second page of records, with 50 results per page:
curl "https://hub.terminus.app/api/v1/records?page=2&limit=50" \
  -H "Authorization: Bearer thub_xxxxx" \
  -H "Content-Type: application/json"

Pagination Response Envelope

Every list response wraps results in the same top-level envelope:
{
  "items": [
    {
      "id": "9b2c1f4e-7a3d-4c8e-9f1a-2b6d5e4c3a10",
      "status": "active",
      "terminus_id": "trm0kf8m2a1q",
      "data": {}
    }
  ],
  "has_more": true,
  "total_count": 142
}
items
array
required
The array of resource objects for the current page. The shape of each item depends on the endpoint (Workspace, Record, Submission, etc.).
has_more
boolean
required
true when there are additional pages beyond the current one. When false, the current page is the last page of results.
total_count
integer
required
The total number of resources matching the request’s filters, across all pages, not just the current page. Use this to calculate the total number of pages: ceil(total_count / limit).
To retrieve all results programmatically, increment page by 1 on each request and stop when has_more is false. Larger pages mean fewer requests; the maximum limit is 10000.

Errors

When a request fails, the API returns an appropriate HTTP status code and a JSON body containing a single error object. The structure is identical regardless of the error type, making it easy to write a single error-handling function for your entire integration.

Error Envelope

{
  "error": {
    "type": "not_found_error",
    "code": null,
    "message": "Record not found",
    "param": null,
    "path": null
  }
}

Error Response Fields

error
object
required
The top-level error container. All error details are nested inside this object.

Error Types Reference

TypeHTTP StatusDescription
invalid_request_error422The request was understood but a value is invalid, out of range, or fails a validation rule. Check the param field to identify the offending input. (A genuinely missing required parameter returns 400.)
authentication_error401The API key is missing, incorrectly formatted, or has been revoked. See Authentication for guidance.
authorization_error403The API key is valid but does not have permission to access the requested resource. Verify the key belongs to an account with the necessary access.
not_found_error404The requested resource does not exist. Verify the ID in the URL is correct and belongs to a resource your key can access.
rate_limit_error429Too many requests have been made in a short period. Back off and retry after the delay in the Retry-After header.
plan_limit_exceeded422The request needs a feature or exceeds a limit not included in your current plan. Check param for the feature or resource, then upgrade to proceed.
api_error500An unexpected error occurred on the Terminus Hub server. These are rare. If they persist, contact Terminus Hub support.
Your integration should always check the HTTP status code first, then inspect error.type for branching logic, and error.code for fine-grained handling. Do not rely solely on error.message, as message text may change between API versions.

Handling Errors: Example

The snippet below demonstrates a simple, robust error-handling pattern in JavaScript:
const response = await fetch(
  "https://hub.terminus.app/api/v1/records/rec_missing",
  {
    headers: { Authorization: "Bearer thub_xxxxx" },
  }
);

if (!response.ok) {
  const { error } = await response.json();

  switch (error.type) {
    case "authentication_error":
      console.error("Check your API key:", error.message);
      break;
    case "not_found_error":
      console.error("Resource not found:", error.message);
      break;
    case "rate_limit_error":
      console.warn("Rate limited, backing off...");
      // implement retry with exponential back-off
      break;
    default:
      console.error(`API error [${error.code}]:`, error.message);
  }
}

Rate limiting

Requests are rate limited per API key. Each key may make up to 100 requests per minute. (Unauthenticated requests are limited to 20 per minute per IP.) When you exceed the limit, the API responds with 429 and a rate_limit_error:
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "message": "Too many requests. Please retry after 42 seconds.",
    "param": null
  }
}
Every 429 includes headers to help you back off:
HeaderMeaning
Retry-AfterSeconds to wait before retrying
X-RateLimit-LimitThe request ceiling for the window
X-RateLimit-RemainingRequests left in the current window
X-RateLimit-ResetUnix time when the window resets
Respect Retry-After and implement exponential back-off for resilient integrations.