Infrastrure as code Tasks API
The Tasks API allows you to manage IAC tasks in your organization, including creating, monitoring, and controlling their execution lifecycle.
Tasks are powered behind the scenes using Terraform and allows a flexible interface for users and agents to consume infrastrcuture automations from within workflows
Base URL
https://api.kubiya.ai/api/v1/tasks
All endpoints require authentication with a valid API key.
Endpoints
Method Path Description GET /api/v1/tasks
List all tasks GET /api/v1/tasks/{taskId}
Get task details POST /api/v1/tasks
Create a new task PUT /api/v1/tasks/{taskId}/cancel
Cancel a task GET /api/v1/tasks/{taskId}/logs
Get task logs GET /api/v1/tasks/{taskId}/status
Get task status GET /api/v1/tasks/agent/{agentId}
List tasks for an agent GET /api/v1/tasks/runner/{runnerId}
List tasks for a runner
Common Response Status Codes
Status Code Description 200 Success 400 Bad Request - Invalid parameters or request body 401 Unauthorized - Invalid or missing API key 403 Forbidden - Insufficient permissions 404 Not Found - Resource doesn’t exist 500 Internal Server Error
{
"error" : {
"code" : "string" ,
"message" : "string" ,
"details" : {}
}
}
Task Object
Task Object
Task with Logs
{
"id" : "task-123" ,
"name" : "Deploy Application" ,
"description" : "Deploy application to production environment" ,
"status" : "running" ,
"progress" : 75 ,
"created_at" : "2023-01-01T00:00:00Z" ,
"updated_at" : "2023-01-01T00:15:00Z" ,
"started_at" : "2023-01-01T00:00:00Z" ,
"completed_at" : null ,
"agent_id" : "agent-456" ,
"runner_id" : "runner-789" ,
"metadata" : {
"environment" : "production" ,
"version" : "1.2.0" ,
"priority" : "high"
},
"result" : {
"output" : {},
"error" : null
}
}
List Tasks
Retrieve all tasks in your organization.
Query Parameters
Maximum number of tasks to return
Page number for pagination
Sort by field (created_at, updated_at, status)
Example Request
List All Tasks
Filter by Status
Filter by Agent
curl -X GET "https://api.kubiya.ai/api/v1/tasks" \
-H "Authorization: UserKey $KUBIYA_API_KEY "
Response
[
{
"id" : "task-123" ,
"name" : "Deploy Application" ,
"description" : "Deploy application to production environment" ,
"status" : "running" ,
"progress" : 75 ,
"created_at" : "2023-01-01T00:00:00Z" ,
"updated_at" : "2023-01-01T00:15:00Z" ,
"started_at" : "2023-01-01T00:00:00Z" ,
"completed_at" : null ,
"agent_id" : "agent-456" ,
"runner_id" : "runner-789" ,
"metadata" : {
"environment" : "production" ,
"version" : "1.2.0" ,
"priority" : "high"
}
}
]
Get Task Details
Retrieve details for a specific task.
GET /api/v1/tasks/{taskId}
Path Parameters
Example Request
Get Task Details
Get with JSON Processing
curl -X GET "https://api.kubiya.ai/api/v1/tasks/task-123" \
-H "Authorization: UserKey $KUBIYA_API_KEY "
Response
{
"id" : "task-123" ,
"name" : "Deploy Application" ,
"description" : "Deploy application to production environment" ,
"status" : "running" ,
"progress" : 75 ,
"created_at" : "2023-01-01T00:00:00Z" ,
"updated_at" : "2023-01-01T00:15:00Z" ,
"started_at" : "2023-01-01T00:00:00Z" ,
"completed_at" : null ,
"agent_id" : "agent-456" ,
"runner_id" : "runner-789" ,
"metadata" : {
"environment" : "production" ,
"version" : "1.2.0" ,
"priority" : "high"
},
"result" : {
"output" : {},
"error" : null
}
}
Create Task
Create a new task.
Request Body
ID of the agent to execute the task
Additional metadata for the task
Example Requests
Create Task
Create with Response Processing
curl -X POST "https://api.kubiya.ai/api/v1/tasks" \
-H "Authorization: UserKey $KUBIYA_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"name": "Deploy Application",
"description": "Deploy application to production environment",
"agent_id": "agent-456",
"runner_id": "runner-789",
"metadata": {
"environment": "production",
"version": "1.2.0",
"priority": "high"
},
"parameters": {
"app_name": "my-app",
"deploy_strategy": "rolling"
}
}'
Response
{
"id" : "task-123" ,
"name" : "Deploy Application" ,
"description" : "Deploy application to production environment" ,
"status" : "pending" ,
"progress" : 0 ,
"created_at" : "2023-01-01T00:00:00Z" ,
"updated_at" : "2023-01-01T00:00:00Z" ,
"started_at" : null ,
"completed_at" : null ,
"agent_id" : "agent-456" ,
"runner_id" : "runner-789" ,
"metadata" : {
"environment" : "production" ,
"version" : "1.2.0" ,
"priority" : "high"
}
}
Cancel Task
Cancel a running task.
PUT /api/v1/tasks/{taskId}/cancel
Path Parameters
Example Request
Cancel Task
Cancel with Confirmation
curl -X PUT "https://api.kubiya.ai/api/v1/tasks/task-123/cancel" \
-H "Authorization: UserKey $KUBIYA_API_KEY "
Response
{
"id" : "task-123" ,
"status" : "cancelled" ,
"cancelled_at" : "2023-01-01T00:30:00Z" ,
"cancelled_by" : "user@example.com"
}
Get Task Logs
Retrieve logs for a specific task.
GET /api/v1/tasks/{taskId}/logs
Path Parameters
Query Parameters
Filter logs after this timestamp
Filter logs before this timestamp
Filter by log level (info, error, debug)
Maximum number of log entries to return
Example Request
Get Task Logs
Filter Error Logs
Get Recent Logs
curl -X GET "https://api.kubiya.ai/api/v1/tasks/task-123/logs" \
-H "Authorization: UserKey $KUBIYA_API_KEY "
Response
{
"task_id" : "task-123" ,
"logs" : [
{
"timestamp" : "2023-01-01T00:00:00Z" ,
"level" : "info" ,
"message" : "Task started" ,
"metadata" : {
"component" : "runner" ,
"step" : "initialization"
}
},
{
"timestamp" : "2023-01-01T00:15:00Z" ,
"level" : "error" ,
"message" : "Failed to connect to database" ,
"metadata" : {
"component" : "database" ,
"error_code" : "DB001"
}
}
]
}
Get Task Status
Get the current status of a task.
GET /api/v1/tasks/{taskId}/status
Path Parameters
Example Request
Get Task Status
Get Status with Progress
curl -X GET "https://api.kubiya.ai/api/v1/tasks/task-123/status" \
-H "Authorization: UserKey $KUBIYA_API_KEY "
Response
{
"id" : "task-123" ,
"status" : "running" ,
"progress" : 75 ,
"started_at" : "2023-01-01T00:00:00Z" ,
"updated_at" : "2023-01-01T00:15:00Z" ,
"metadata" : {
"current_step" : "deploying" ,
"steps_completed" : 3 ,
"total_steps" : 4
}
}
List Tasks for Agent
Retrieve all tasks associated with a specific agent.
GET /api/v1/tasks/agent/{agentId}
Path Parameters
Example Request
curl -X GET "https://api.kubiya.ai/api/v1/tasks/agent/agent-456" \
-H "Authorization: UserKey $KUBIYA_API_KEY "
Response
[
{
"id" : "task-123" ,
"name" : "Deploy Application" ,
"status" : "running" ,
"progress" : 75 ,
"created_at" : "2023-01-01T00:00:00Z" ,
"updated_at" : "2023-01-01T00:15:00Z"
}
]
List Tasks for Runner
Retrieve all tasks associated with a specific runner.
GET /api/v1/tasks/runner/{runnerId}
Path Parameters
Example Request
curl -X GET "https://api.kubiya.ai/api/v1/tasks/runner/runner-789" \
-H "Authorization: UserKey $KUBIYA_API_KEY "
Response
[
{
"id" : "task-123" ,
"name" : "Deploy Application" ,
"status" : "running" ,
"progress" : 75 ,
"created_at" : "2023-01-01T00:00:00Z" ,
"updated_at" : "2023-01-01T00:15:00Z"
}
]
Common Errors
Task Not Found
Invalid Request
Unauthorized
{
"error" : {
"code" : "not_found" ,
"message" : "Task not found" ,
"details" : {
"taskId" : "task-123"
}
}
}
Error Status Codes
HTTP Status Description 400 Bad Request - Invalid request body or missing required fields 401 Unauthorized - API key is missing or invalid 403 Forbidden - The API key doesn’t have permission to perform this action 404 Not Found - The specified task was not found 409 Conflict - Task is in an invalid state for the requested operation 500 Internal Server Error - An unexpected error occurred on the server
Next Steps