Skip to main content

Overview

Constants provides APIs for programmatic access to your Workers and account features. This enables automation, integration with other tools, and advanced workflows.
The Constants API is currently in beta. Some endpoints may change as we refine the interface.

Authentication

All API requests require authentication using an API key.

Getting Your API Key

  1. Log in to constants.io
  2. Click your profile icon in the sidebar
  3. Select API Keys
  4. Create a new key for API access

Using Your Key

Include your API key in the Authorization header:
curl -X GET https://api.constants.io/v1/workers \
  -H "Authorization: Bearer YOUR_API_KEY"

Base URL

All API endpoints are available at:
https://api.constants.io/v1

Available Endpoints

Workers

MethodEndpointDescription
GET/workersList all your Workers
GET/workers/:idGet a specific Worker
POST/workersCreate a new Worker
PUT/workers/:idUpdate a Worker
DELETE/workers/:idDelete a Worker
POST/workers/:id/runExecute a Worker

Runs

MethodEndpointDescription
GET/workers/:id/runsList runs for a Worker
GET/runs/:idGet a specific run result

Example Requests

List Workers

curl -X GET https://api.constants.io/v1/workers \
  -H "Authorization: Bearer YOUR_API_KEY"
Response:
{
  "workers": [
    {
      "id": "wrk_abc123",
      "name": "Sales Dashboard",
      "status": "ready",
      "created_at": "2025-01-15T10:30:00Z",
      "updated_at": "2025-01-18T14:22:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "per_page": 20,
    "total": 1
  }
}

Run a Worker

curl -X POST https://api.constants.io/v1/workers/wrk_abc123/run \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"date_range": "last_30_days"}}'
Response:
{
  "run_id": "run_xyz789",
  "status": "running",
  "created_at": "2025-01-20T08:15:00Z"
}

Rate Limits

To ensure fair usage, the API has rate limits:
TierRequests per minuteRequests per day
Free601,000
Pro30010,000
EnterpriseCustomCustom
When you exceed rate limits, the API returns a 429 Too Many Requests response with a Retry-After header.

Error Handling

The API uses standard HTTP status codes:
CodeMeaning
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Resource doesn’t exist
429Too Many Requests - Rate limit exceeded
500Server Error - Something went wrong
Error responses include a JSON body with details:
{
  "error": {
    "code": "invalid_parameter",
    "message": "The 'worker_id' parameter is required",
    "param": "worker_id"
  }
}

SDKs

Official SDKs are coming soon for:
  • Python - pip install constants-sdk
  • JavaScript/TypeScript - npm install @constants/sdk
In the meantime, you can use any HTTP client to interact with the API.

Webhooks

Configure webhooks to receive notifications when events occur:
  • Worker run completed
  • Worker run failed
  • Worker updated
Webhook configuration is available in your account settings.

Need Help?