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 API Keys section.

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. See API Keys
API_KEY_INVALID401Invalid API key. See API Keys

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_GIT_PROVIDER_NOT_INSTALLED400Git provider not connected. Connect in Settings
RUN_ORCHESTRATOR_ERROR502Failed to start run
CONCURRENT_RUN_LIMIT_EXCEEDED429Too many active runs — wait for existing runs to complete

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

Webhooks

CodeStatusMessage
WEBHOOK_NOT_FOUND404Webhook not found
WEBHOOK_LIMIT_EXCEEDED409Maximum number of webhooks reached (25 per organization)
WEBHOOK_URL_DUPLICATE409A webhook with this URL already exists

Repositories

CodeStatusMessage
REPOSITORY_NOT_FOUND404Repository not found

Usage & credits

CodeStatusMessage
USAGE_INSUFFICIENT_CREDITS402Insufficient credits to perform this action. See Usage

General

CodeStatusMessage
VALIDATION_FAILED400Validation failed
BAD_REQUEST400Bad request
NOT_FOUND404Resource not found
CONFLICT409Resource conflict
RATE_LIMIT_EXCEEDED429Too many requests — back off and retry
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 enforces 200 requests per minute per API key across all endpoints. Every response includes rate limit headers:

HeaderDescriptionExample
X-RateLimit-LimitMax requests per window200
X-RateLimit-RemainingRequests left in current window147
X-RateLimit-ResetUnix timestamp when the window resets1740831660
Retry-AfterSeconds until retry (429 responses only)12

When the limit is exceeded, you'll receive a 429 response with error code RATE_LIMIT_EXCEEDED. Back off and retry after the Retry-After period.

If you're polling run status, we recommend intervals of 5–10 seconds to stay well within the limit.

Concurrent run limits

Each organization can have up to 10 concurrent runs (pending + running) at any time. If you try to create a run while at the limit, you'll receive a 429 response with error code CONCURRENT_RUN_LIMIT_EXCEEDED. Wait for existing runs to complete before starting new ones.

On this page