Simple REST API
AsyncQueue provides a clean REST API. One POST request creates a task. One GET request checks the result.
Endpoints
Section titled “Endpoints”| Method | Path | Description |
|---|---|---|
POST | /v1/tasks | Create a new task |
GET | /v1/tasks | List tasks with filtering and pagination |
GET | /v1/tasks/:id | Get a single task by ID |
POST | /v1/tasks/:id/cancel | Cancel a pending or delayed task |
Design principles
Section titled “Design principles”- JSON everywhere - All request and response bodies use JSON
- Bearer authentication - API key in the
Authorizationheader - Consistent errors - Every error returns
{"error": "message"}with an appropriate HTTP status code - Pagination - List endpoints return
paginationmetadata withtotal,limit,offset, andhasMore
Code examples
Section titled “Code examples”JavaScript
Section titled “JavaScript”const API_KEY = 'your-api-key';const BASE_URL = 'https://api.asyncqueue.io';
async function createTask(taskData) { const response = await fetch(`${BASE_URL}/v1/tasks`, { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify(taskData) }); return response.json();}
const { task } = await createTask({ targetUrl: 'https://api.example.com/process', body: JSON.stringify({ orderId: 12345 }), maxRetries: 5});Python
Section titled “Python”import requests
API_KEY = 'your-api-key'BASE_URL = 'https://api.asyncqueue.io'
headers = { 'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'}
def create_task(task_data): response = requests.post( f'{BASE_URL}/v1/tasks', headers=headers, json=task_data ) return response.json()
result = create_task({ 'targetUrl': 'https://api.example.com/process', 'body': '{"orderId": 12345}', 'maxRetries': 5})# Create a taskcurl -X POST https://api.asyncqueue.io/v1/tasks \ -H "Authorization: Bearer your-api-key" \ -H "Content-Type: application/json" \ -d '{"targetUrl": "https://api.example.com/webhook"}'
# Check statuscurl https://api.asyncqueue.io/v1/tasks/TASK_ID \ -H "Authorization: Bearer your-api-key"
# List pending taskscurl "https://api.asyncqueue.io/v1/tasks?status=pending&limit=10" \ -H "Authorization: Bearer your-api-key"
# Cancel a taskcurl -X POST https://api.asyncqueue.io/v1/tasks/TASK_ID/cancel \ -H "Authorization: Bearer your-api-key"