Docs

API Overview

Everything you need to integrate with the coSPEC API

Base URL

All API requests go to:

https://api.cospec.io

Authentication

Authenticate every request with a Bearer token — your API key:

Terminal
curl https://api.cospec.io/v1/runs \
  -H "Authorization: Bearer csk_live_..."

API keys start with csk_live_ and are scoped to a single organization. Create and manage keys in the dashboard.

Request format

  • Content-Type: application/json for request bodies
  • Methods: GET for reads, POST for creates, PATCH for updates, DELETE for deletes

Errors

Error responses follow RFC 9457 (Problem Details for HTTP APIs):

{
  "type": "VALIDATION_FAILED",
  "title": "Validation failed",
  "status": 400,
  "detail": "Invalid request body",
  "instance": "/v1/runs",
  "requestId": "req-abc123"
}

Every error response includes:

FieldTypeDescription
typestringMachine-readable error code (e.g. TEMPLATE_NOT_FOUND)
titlestringHuman-readable error summary
statusnumberHTTP status code
detailstring?Additional context about the error
instancestring?Request path that caused the error
requestIdstring?Unique ID for support requests
errorsarray?Field-level validation errors (see below)

Validation errors

When type is VALIDATION_FAILED, the errors array contains per-field details:

{
  "type": "VALIDATION_FAILED",
  "title": "Validation failed",
  "status": 400,
  "errors": [
    {
      "field": "template",
      "message": "String must contain at least 1 character(s)",
      "code": "too_small"
    }
  ]
}

HTTP status codes

StatusMeaning
400Bad request — invalid body, parameters, or state
401Unauthorized — missing or invalid API key
402Payment required — insufficient credits
403Forbidden — action not allowed
404Not found — resource doesn't exist
409Conflict — duplicate resource or constraint violation
429Too many requests — rate limit exceeded
500Internal error — unexpected server failure
502Bad gateway — upstream service failure
503Service unavailable — sandbox failed to start

Error codes

Authentication

CodeStatusMessage
AUTH_UNAUTHORIZED401Authentication required
API_KEY_INVALID401Invalid API key

Runs

CodeStatusMessage
RUN_TEMPLATE_NOT_FOUND400Template not found
RUN_API_KEY_REQUIRED400Anthropic API key required. Configure in Settings
RUN_GITHUB_APP_NOT_INSTALLED400GitHub App not installed. Install in Settings
RUN_ORCHESTRATOR_ERROR502Failed to start run

Templates

CodeStatusMessage
TEMPLATE_NOT_FOUND404Template not found
TEMPLATE_SLUG_EXISTS409A template with this slug already exists
TEMPLATE_SYSTEM_READONLY403System templates cannot be modified
TEMPLATE_HAS_RUNNING_SANDBOXES409Cannot delete template with running sandboxes

Usage & credits

CodeStatusMessage
USAGE_INSUFFICIENT_CREDITS402Insufficient credits to perform this action

General

CodeStatusMessage
VALIDATION_FAILED400Validation failed
BAD_REQUEST400Bad request
NOT_FOUND404Resource not found
CONFLICT409Resource conflict
INTERNAL_ERROR500An unexpected error occurred

Pagination

List endpoints return paginated results:

{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 42,
    "totalPages": 3
  }
}

Control pagination with page and limit query parameters.

Rate limits

The API is rate-limited per API key. Current limits are generous for normal usage. If you hit a rate limit you'll receive a 429 Too Many Requests response — back off and retry.

On this page