Kubiya LogoKubiya Developer Docs

Tasks API

API endpoints for managing tasks in the Kubiya platform

Tasks API

The Tasks API provides endpoints to manage automation tasks in Kubiya. Tasks are used for managing workflows and automation processes, including infrastructure deployments, configuration management, and other DevOps operations.

This playground makes API calls to Kubiya API through a secure server-side proxy. Your requests never expose your API token directly to the browser.

List all tasks

GET
Authentication
Enter your Kubiya API key only. The "UserKey" prefix will be added automatically.

Create a new task

POST
Authentication
Enter your Kubiya API key only. The "UserKey" prefix will be added automatically.

List Tasks

Retrieve a list of all tasks in your organization.

GET /v1/tasks

Headers

NameRequiredDescription
AuthorizationYesUserKey YOUR_API_KEY
Content-TypeNoapplication/json

Response

[
  {
    "id": "task-123456",
    "name": "Deploy Application",
    "description": "Automated deployment of the application to production",
    "icons": ["🚀", "⚙️"],
    "readme": "# Deployment Task\n\nThis task handles automated deployments...",
    "url": "https://github.com/org/deployment-tasks",
    "providers": [
      {
        "name": "aws"
      },
      {
        "name": "kubernetes"
      }
    ],
    "resources": [
      {
        "name": "application_deployment",
        "type": "kubernetes_deployment",
        "provider": "kubernetes",
        "variables": [
          {
            "name": "namespace",
            "type": "string",
            "value": "production",
            "default": "default",
            "description": "Kubernetes namespace",
            "has_error": false
          }
        ]
      }
    ],
    "variables": [
      {
        "name": "environment",
        "type": "string",
        "value": "production",
        "default": "staging",
        "description": "Deployment environment",
        "has_error": false,
        "required": true
      }
    ],
    "secrets": [
      {
        "name": "api_key",
        "description": "API key for external service",
        "to_env": "API_KEY",
        "value": "******"
      }
    ]
  }
]

Create Task

Create a new task in your organization.

POST /v1/tasks

Headers

NameRequiredDescription
AuthorizationYesUserKey YOUR_API_KEY
Content-TypeYesapplication/json

Request Body

{
  "name": "New Deployment Task",
  "description": "Automated deployment of the application to production",
  "icons": ["🚀", "⚙️"],
  "url": "https://github.com/org/deployment-tasks",
  "providers": [
    {
      "name": "aws"
    }
  ],
  "variables": [
    {
      "name": "environment",
      "type": "string",
      "default": "staging",
      "description": "Deployment environment",
      "required": true
    }
  ],
  "secrets": [
    {
      "name": "api_key",
      "description": "API key for external service",
      "to_env": "API_KEY",
      "value": "secret-value"
    }
  ]
}

Required Fields

  • name: Name of the task
  • description: Description of what the task does

Response

{
  "id": "task-123456",
  "name": "New Deployment Task",
  "description": "Automated deployment of the application to production",
  "icons": ["🚀", "⚙️"],
  "url": "https://github.com/org/deployment-tasks",
  "providers": [
    {
      "name": "aws"
    }
  ],
  "variables": [
    {
      "name": "environment",
      "type": "string",
      "default": "staging",
      "description": "Deployment environment",
      "required": true
    }
  ],
  "secrets": [
    {
      "name": "api_key",
      "description": "API key for external service",
      "to_env": "API_KEY",
      "value": "******"
    }
  ]
}

Get Task Details

Retrieve detailed information about a specific task.

GET /v1/tasks/{task_id}

Path Parameters

NameTypeRequiredDescription
task_idstringYesID of the task to retrieve

Headers

NameRequiredDescription
AuthorizationYesUserKey YOUR_API_KEY
Content-TypeNoapplication/json

Response

{
  "id": "task-123456",
  "name": "Deploy Application",
  "description": "Automated deployment of the application to production",
  "icons": ["🚀", "⚙️"],
  "readme": "# Deployment Task\n\nThis task handles automated deployments...",
  "url": "https://github.com/org/deployment-tasks",
  "providers": [
    {
      "name": "aws"
    },
    {
      "name": "kubernetes"
    }
  ],
  "resources": [
    {
      "name": "application_deployment",
      "type": "kubernetes_deployment",
      "provider": "kubernetes",
      "variables": [
        {
          "name": "namespace",
          "type": "string",
          "value": "production",
          "default": "default",
          "description": "Kubernetes namespace",
          "has_error": false
        }
      ]
    }
  ],
  "variables": [
    {
      "name": "environment",
      "type": "string",
      "value": "production",
      "default": "staging",
      "description": "Deployment environment",
      "has_error": false,
      "required": true
    }
  ],
  "secrets": [
    {
      "name": "api_key",
      "description": "API key for external service",
      "to_env": "API_KEY",
      "value": "******"
    }
  ]
}

Update Task

Update an existing task with new parameters.

PUT /v1/tasks/{task_id}

Path Parameters

NameTypeRequiredDescription
task_idstringYesID of the task to update

Headers

NameRequiredDescription
AuthorizationYesUserKey YOUR_API_KEY
Content-TypeYesapplication/json

Request Body

{
  "name": "Updated Deployment Task",
  "description": "Updated deployment task with new parameters",
  "variables": [
    {
      "name": "environment",
      "type": "string",
      "value": "production",
      "description": "Deployment environment",
      "required": true
    },
    {
      "name": "version",
      "type": "string",
      "value": "1.2.3",
      "description": "Application version",
      "required": true
    }
  ]
}

Response

{
  "id": "task-123456",
  "name": "Updated Deployment Task",
  "description": "Updated deployment task with new parameters",
  "variables": [
    {
      "name": "environment",
      "type": "string",
      "value": "production",
      "description": "Deployment environment",
      "required": true
    },
    {
      "name": "version",
      "type": "string",
      "value": "1.2.3",
      "description": "Application version",
      "required": true
    }
  ]
}

Run Task

Execute a task with specific parameters.

POST /v1/tasks/{task_id}/run

Path Parameters

NameTypeRequiredDescription
task_idstringYesID of the task to run

Headers

NameRequiredDescription
AuthorizationYesUserKey YOUR_API_KEY
Content-TypeYesapplication/json

Request Body

{
  "variables": {
    "environment": "production",
    "version": "1.2.3"
  },
  "plan_only": false
}

Response

{
  "run_id": "run-123456",
  "task_id": "task-123456",
  "status": "running",
  "started_at": "2023-01-01T00:00:00Z",
  "variables": {
    "environment": "production",
    "version": "1.2.3"
  }
}

Example Usage

List Tasks

curl -X GET "https://api.kubiya.ai/v1/tasks" \
  -H "Authorization: UserKey YOUR_API_KEY" \
  -H "Content-Type: application/json"

Create a Task

curl -X POST "https://api.kubiya.ai/v1/tasks" \
  -H "Authorization: UserKey YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Deploy Application",
    "description": "Deploys the application to production",
    "url": "https://github.com/organization/deploy-scripts",
    "providers": [
      {
        "name": "kubernetes"
      }
    ],
    "variables": [
      {
        "name": "environment",
        "type": "string",
        "description": "Deployment environment",
        "default": "staging"
      }
    ]
  }'

Get Task Details

curl -X GET "https://api.kubiya.ai/v1/tasks/task-123456" \
  -H "Authorization: UserKey YOUR_API_KEY" \
  -H "Content-Type: application/json"

Update a Task

curl -X PUT "https://api.kubiya.ai/v1/tasks/task-123456" \
  -H "Authorization: UserKey YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Deployment Task",
    "description": "Updated deployment task with new parameters",
    "variables": [
      {
        "name": "environment",
        "type": "string",
        "value": "production",
        "description": "Deployment environment",
        "required": true
      }
    ]
  }'

Run a Task

curl -X POST "https://api.kubiya.ai/v1/tasks/task-123456/run" \
  -H "Authorization: UserKey YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "variables": {
      "environment": "production",
      "version": "1.2.3"
    },
    "plan_only": false
  }'

Common Errors

HTTP StatusDescription
400Bad Request - Missing required fields or invalid parameter
401Unauthorized - Missing or invalid API key
403Forbidden - API key doesn't have permission for this operation
404Not Found - Task not found
409Conflict - A task with this name already exists
500Internal Server Error - Unexpected server error

Data Types

Task

FieldTypeDescription
idstringUnique identifier for the task
namestringHuman-readable name for the task
descriptionstringDescription of what the task does
iconsstring[]Array of emoji icons representing the task
readmestringMarkdown documentation for the task
urlstringSource URL for the task (e.g., GitHub repository)
providersProvider[]Infrastructure providers used by this task
resourcesResource[]Resources managed by this task
variablesVariable[]Variables that can be configured for this task
secretsSecret[]Secrets used by this task

Variable

FieldTypeDescription
namestringVariable name
typestringData type (string, number, boolean, etc.)
valueanyCurrent value (optional)
defaultanyDefault value (optional)
descriptionstringHuman-readable description
requiredbooleanWhether this variable is required
has_errorbooleanWhether there's an error with this variable
error_detailstringDetailed error message if has_error is true
error_summarystringSummary of the error if has_error is true

Secret

FieldTypeDescription
namestringSecret name
descriptionstringHuman-readable description
to_envstringEnvironment variable name to map this secret to
valuestringSecret value (masked in responses)

Task Execution

While the Tasks API manages task definitions, execution of tasks is typically handled through the following mechanisms:

  1. Direct Execution: Tasks can be executed directly through the Execution API
  2. Event-Driven: Tasks can be triggered by webhook events
  3. Scheduled: Tasks can be executed on a schedule

The execution details and status tracking are handled through separate API endpoints.

Task Variables and Secrets

Tasks can have variables and secrets that control their behavior:

  • Variables: Configuration options that can be set at task creation or execution time
  • Secrets: Sensitive information (like API keys) that are securely stored and made available during task execution

Common Use Cases

Tasks in Kubiya are commonly used for:

  1. Application Deployments: Automate the deployment of applications to various environments
  2. Infrastructure Management: Provision and configure infrastructure resources
  3. CI/CD Integration: Integrate with continuous integration and deployment pipelines
  4. Automated Remediation: Fix common issues automatically when triggered by alerts
  5. Scheduled Maintenance: Perform routine maintenance tasks on a schedule

For detailed examples of task implementations, refer to the Task Examples Guide.