---
title: "Create an AI Agent Task"
method: POST
path: "/v1/ai/agents/tasks"
tags: ["AI Agent Tasks"]
---

# Create an AI Agent Task

`POST /v1/ai/agents/tasks`

## Request

- Base URL: `https://eu1.api.matillion.com/dpc`
- URL: `https://eu1.api.matillion.com/dpc/v1/ai/agents/tasks`
- Auth: HTTP bearer

Creates a new AI agent task and starts async execution. Poll the messages endpoint to retrieve results.

## Request body

- CreateTaskRequest
  - `agentConfig` DataEngineerAgentConfig, required
    - `name` string, required: The agent type identifier. Must be "data_engineer_agent"
    - `environmentName` string, required: The name of the environment to use for execution
    - `generateBranch` boolean: Whether the agent should auto-generate a new branch for its changes
    - `graphId` string, nullable: The ID of the pipeline graph the agent will work on
    - `mode` 'PLAN' | 'ACT', required: The execution mode. ACT allows the agent to make changes; PLAN produces a plan only
    - `projectId` string, uuid, required: The ID of the project the agent will work within
    - `sourceBranchName` string, required: The branch the agent will read from
    - `targetBranchName` string, nullable: The branch the agent will write changes to. Required unless generateBranch is true
    - `workingDirectory` string, nullable: The working directory within the project for the agent
  - `grantedPermissions` AllowedTool[], nullable: Permissions pre-granted to the agent for this task. Each entry must be unique
    - `toolName` string, required: The name of the tool to allow
  - `message` string, required: The instruction or question to send to the agent

## Response `201`

Agent task created successfully

- CreateTaskResponse
  - `agentName` string: The name of the agent handling the task
  - `createdAt` string, date-time: The date and time the task was created
  - `status` 'RUNNING' | 'STOPPED' | 'STOPPING' | 'ERRORED': The current status of the task
  - `taskId` string, uuid: The unique identifier of the created task

## Other responses

- `400`: Invalid request body
- `401`: Missing or invalid authentication token
- `403`: Insufficient permissions to create an agent task
- `404`: Resource not found
- `502`: Upstream service error
- `504`: Upstream service timeout

---

[API](https://skmtc.dev/maia/apis/maia-public-rest-api.md) - [All operations](https://skmtc.dev/maia/apis/maia-public-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/maia/apis/maia-public-rest-api/revisions/6239825f68eb?raw)
