Reference

Task Endpoints


Task Management

Submit Task

Submit a task for execution.

1
POST /api/v1/tasks
2
Authorization: Bearer <token>
3
Content-Type: application/json
4
5
{
6
"task_type": "send_email",
7
"task_queue": "notifications",
8
"input": {
9
"to": "customer@example.com",
10
"subject": "Order Confirmation",
11
"body": "Your order has been confirmed."
12
},
13
"timeout": 60,
14
"retry_policy": {
15
"max_attempts": 3
16
}
17
}

Response:

1
{
2
"task_id": "task_xyz123",
3
"status": "queued",
4
"created_at": "2024-01-07T12:00:00Z"
5
}

Get Task Status

1
GET /api/v1/tasks/:task_id
2
Authorization: Bearer <token>

Response:

1
{
2
"task_id": "task_xyz123",
3
"task_type": "send_email",
4
"status": "completed",
5
"result": {
6
"message_id": "msg_abc789",
7
"sent_at": "2024-01-07T12:00:15Z"
8
},
9
"started_at": "2024-01-07T12:00:01Z",
10
"completed_at": "2024-01-07T12:00:15Z",
11
"attempt": 1,
12
"duration_ms": 14000
13
}

Cancel Task

1
DELETE /api/v1/tasks/:task_id
2
Authorization: Bearer <token>

Response:

1
{
2
"task_id": "task_xyz123",
3
"status": "canceled",
4
"canceled_at": "2024-01-07T12:00:30Z"
5
}

List Tasks

1
GET /api/v1/tasks?task_type=send_email&status=completed&limit=50
2
Authorization: Bearer <token>

Response:

1
{
2
"tasks": [
3
{
4
"task_id": "task_xyz123",
5
"task_type": "send_email",
6
"status": "completed",
7
"created_at": "2024-01-07T12:00:00Z"
8
}
9
],
10
"total": 250,
11
"limit": 50,
12
"offset": 0
13
}

Next Steps