API Reference
Complete REST API reference for Spooled Cloud. All endpoints require authentication via Bearer token (JWT) or API key.
Base URL: https://api.spooled.cloud
Quick Examples
Common operations across all languages:
Create a Job
curl -X POST https://api.spooled.cloud/api/v1/jobs \
-H "Authorization: Bearer sp_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queue_name": "my-queue",
"payload": {
"event": "user.created",
"user_id": "usr_123",
"email": "alice@example.com"
},
"idempotency_key": "user-created-usr_123"
}'Claim Jobs
# Claim up to 5 jobs
curl -X POST https://api.spooled.cloud/api/v1/jobs/claim \
-H "Authorization: Bearer sp_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queue_name": "my-queue",
"worker_id": "worker-1",
"limit": 5
}'Complete a Job
# Complete a job
curl -X POST https://api.spooled.cloud/api/v1/jobs/job_xyz123/complete \
-H "Authorization: Bearer sp_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"worker_id": "worker-1",
"result": {"processed": true}
}'Authentication
Include your API key or JWT token in the Authorization header:
# All API requests require authentication
curl -X POST https://api.spooled.cloud/api/v1/jobs \
-H "Authorization: Bearer sp_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue_name": "my-queue", "payload": {...}}'See Authentication for details on obtaining tokens.
Endpoints
Authentication
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/login | Exchange API key for JWT tokens |
| POST | /api/v1/auth/refresh | Refresh access token |
| GET | /api/v1/auth/me | Get current user/organization info |
| POST | /api/v1/auth/logout | Logout and invalidate tokens |
| POST | /api/v1/auth/email/start | Start passwordless email login |
| POST | /api/v1/auth/email/verify | Verify email login code |
Jobs
| Method | Endpoint | Description | SDK |
|---|---|---|---|
| POST | /api/v1/jobs | Create/enqueue a new job | client.jobs.create(...) |
| GET | /api/v1/jobs | List jobs with filtering | client.jobs.list(...) |
| GET | /api/v1/jobs/:id | Get job details | client.jobs.get(id) |
| POST | /api/v1/jobs/bulk | Bulk enqueue multiple jobs | client.jobs.bulkEnqueue(...) |
| POST | /api/v1/jobs/claim | Claim jobs for processing | client.jobs.claim(...) |
| POST | /api/v1/jobs/:id/complete | Mark job as completed | client.jobs.complete(id, ...) |
| POST | /api/v1/jobs/:id/fail | Mark job as failed | client.jobs.fail(id, ...) |
| POST | /api/v1/jobs/:id/heartbeat | Extend job lease | client.jobs.heartbeat(id, ...) |
| POST | /api/v1/jobs/:id/retry | Manually retry a job | client.jobs.retry(id) |
| PUT | /api/v1/jobs/:id/priority | Boost job priority | client.jobs.boostPriority(id, ...) |
| DELETE | /api/v1/jobs/:id | Cancel/delete a job | client.jobs.cancel(id) |
| GET | /api/v1/jobs/stats | Get job statistics | client.jobs.getStats() |
Dead Letter Queue
| Method | Endpoint | Description | SDK |
|---|---|---|---|
| GET | /api/v1/jobs/dlq | List DLQ jobs | client.jobs.dlq.list(...) |
| POST | /api/v1/jobs/dlq/retry | Retry DLQ jobs | client.jobs.dlq.retry(...) |
| POST | /api/v1/jobs/dlq/purge | Purge DLQ jobs | client.jobs.dlq.purge(...) |
Queues
| Method | Endpoint | Description | SDK |
|---|---|---|---|
| GET | /api/v1/queues | List all queues | client.queues.list() |
| GET | /api/v1/queues/:name | Get queue details | client.queues.get(name) |
| GET | /api/v1/queues/:name/stats | Get queue statistics | client.queues.getStats(name) |
| POST | /api/v1/queues/:name/pause | Pause queue processing | client.queues.pause(name) |
| POST | /api/v1/queues/:name/resume | Resume queue processing | client.queues.resume(name) |
Workers
| Method | Endpoint | Description | SDK |
|---|---|---|---|
| POST | /api/v1/workers/register | Register a new worker | client.workers.register(...) |
| GET | /api/v1/workers | List active workers | client.workers.list() |
| POST | /api/v1/workers/:id/heartbeat | Send worker heartbeat | client.workers.heartbeat(id) |
| POST | /api/v1/workers/:id/deregister | Deregister a worker | client.workers.deregister(id) |
Schedules
| Method | Endpoint | Description | SDK |
|---|---|---|---|
| POST | /api/v1/schedules | Create a schedule | client.schedules.create(...) |
| GET | /api/v1/schedules | List schedules | client.schedules.list() |
| GET | /api/v1/schedules/:id | Get schedule details | client.schedules.get(id) |
| PUT | /api/v1/schedules/:id | Update schedule | client.schedules.update(id, ...) |
| DELETE | /api/v1/schedules/:id | Delete schedule | client.schedules.delete(id) |
| POST | /api/v1/schedules/:id/pause | Pause schedule | client.schedules.pause(id) |
| POST | /api/v1/schedules/:id/resume | Resume schedule | client.schedules.resume(id) |
Outgoing Webhooks
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/outgoing-webhooks | Create outgoing webhook |
| GET | /api/v1/outgoing-webhooks | List outgoing webhooks |
| GET | /api/v1/outgoing-webhooks/:id | Get webhook details |
| DELETE | /api/v1/outgoing-webhooks/:id | Delete webhook |
| POST | /api/v1/outgoing-webhooks/:id/test | Test webhook delivery |
Real-time
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/events | SSE event stream |
| GET | /api/v1/events/jobs/:id | SSE for specific job |
| GET | /api/v1/events/queues/:name | SSE for specific queue |
| WS | /api/v1/ws | WebSocket connection |
System
| Method | Endpoint | Description |
|---|---|---|
| GET | /health | Health check |
| GET | /health/live | Liveness probe |
| GET | /health/ready | Readiness probe |
| GET | /metrics | Prometheus metrics |
gRPC API
Spooled also provides a gRPC API for high-performance worker communication using HTTP/2 + Protobuf. The gRPC API supports streaming for real-time job delivery.
- Spooled Cloud (TLS):
grpc.spooled.cloud:443 - Self-hosted / local:
localhost:50051(orGRPC_PORT)
gRPC Services
| Service | RPC | Description |
|---|---|---|
| QueueService | Enqueue | Create a new job |
| QueueService | Dequeue | Claim jobs for processing (batch) |
| QueueService | Complete | Mark job as completed |
| QueueService | Fail | Mark job as failed |
| QueueService | StreamJobs | Server streaming for real-time job delivery |
| WorkerService | Register | Register a worker |
| WorkerService | Heartbeat | Send worker heartbeat |
gRPC Authentication
Include your API key in gRPC metadata:
x-api-key: sp_live_your_api_key When to Use gRPC vs REST
| Use Case | Recommended |
|---|---|
| Web/mobile apps | REST API |
| Dashboard/admin | REST API |
| High-throughput workers | gRPC |
| Streaming job delivery | gRPC |
Response Format
All responses are JSON. Successful responses include the data directly:
{
"id": "job_abc123",
"queue_name": "emails",
"status": "pending",
"payload": { "to": "user@example.com" },
"created_at": "2024-01-15T10:30:00Z"
} Error responses include an error object:
{
"error": "validation_error",
"message": "queue_name is required",
"status": 422
} Rate Limiting
API requests are rate-limited based on your plan. Rate limit headers are included in responses:
X-RateLimit-Limit— Requests per second allowedX-RateLimit-Remaining— Remaining requests in current windowX-RateLimit-Reset— Unix timestamp when limit resets
See Rate Limits for plan-specific limits.
Rate Limited?
What to look for:
- → Current request rate
- → Daily job count
- → Retry-After header value
Actions:
- ✓ Implement exponential backoff
- ✓ Use bulk operations
- ✓ Consider upgrading your plan
Pagination
List endpoints support cursor-based pagination:
limit— Number of items per page (default: 20, max: 100)cursor— Cursor for next page (from previous response)
GET /api/v1/jobs?limit=50&cursor=eyJpZCI6Impv...