# Create task

```http
POST /projects/{project_reference}/tasks
```

Create a task source file in the project source or a preview branch when a new unit of work must be runnable or schedulable; returns the task source document. Requires project.runs.write.

## Parameters

| Name                 | In    | Required | Description                                                           |
| -------------------- | ----- | -------- | --------------------------------------------------------------------- |
| `project_reference`  | path  | Yes      | Project slug, UUID, or domain that identifies the project.            |
| `source_target_kind` | query |          | Source to write: project or preview\_branch. Defaults to project.     |
| `target_branch_id`   | query |          | Preview branch to write when source\_target\_kind is preview\_branch. |

## Request body

| Field         | Type        | Required | Description                                                                          |
| ------------- | ----------- | -------- | ------------------------------------------------------------------------------------ |
| `id`          | string      | Yes      | Stable task identifier used in MCP and project source.                               |
| `name`        | string      | Yes      | Human-readable task name.                                                            |
| `description` | string,null |          | Optional short description of what the task does.                                    |
| `schedulable` | boolean     |          | Whether the task can be used from schedulers and cron definitions. Defaults to true. |

## Responses

| Status | Description           |
| ------ | --------------------- |
| 201    | Created task document |
| 400    | Bad request           |
| 401    | Unauthorized          |
| 403    | Forbidden             |
| 409    | Conflict              |
