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
- Log in to constants.io
- Click your profile icon in the sidebar
- Select API Keys
- 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
| Method | Endpoint | Description |
|---|
GET | /workers | List all your Workers |
GET | /workers/:id | Get a specific Worker |
POST | /workers | Create a new Worker |
PUT | /workers/:id | Update a Worker |
DELETE | /workers/:id | Delete a Worker |
POST | /workers/:id/run | Execute a Worker |
Runs
| Method | Endpoint | Description |
|---|
GET | /workers/:id/runs | List runs for a Worker |
GET | /runs/:id | Get 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:
| Tier | Requests per minute | Requests per day |
|---|
| Free | 60 | 1,000 |
| Pro | 300 | 10,000 |
| Enterprise | Custom | Custom |
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:
| Code | Meaning |
|---|
200 | Success |
201 | Created |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Resource doesn’t exist |
429 | Too Many Requests - Rate limit exceeded |
500 | Server 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?