---
title: "Create a task"
method: POST
path: "/tasks"
tags: ["Tasks"]
---

# Create a task

`POST /tasks`

## Request

- Base URL: `https://api-docs.jackhamr.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api-docs.jackhamr.ai/tasks`
- Auth: none declared

Create a new task in the caller's org.

When ``agent_id`` is provided it must belong to the caller's org;
otherwise a 422 is returned. The task starts in ``pending`` status.

## Request body

- TaskCreate: Request body for ``POST /api/v1/tasks``.
  - `name` string, required
  - `description` string, nullable
  - `task_type` string
  - `agent_id` string, nullable
  - `parent_id` string, nullable
  - `command` string, nullable
  - `working_directory` string, nullable
  - `environment_vars` object, nullable
  - `dependencies` string[], nullable
  - `priority` integer
  - `scheduled_at` string, date-time, nullable
  - `max_retries` integer

## Response `201`

Successful Response

- TaskOut: A task as returned by ``GET/POST/PATCH /api/v1/tasks``.
  - `id` string, required
  - `agent_id` string, nullable
  - `parent_id` string, nullable
  - `name` string, required
  - `description` string, nullable
  - `task_type` string, required
  - `status` string, required
  - `priority` integer
  - `command` string, nullable
  - `working_directory` string, nullable
  - `environment_vars` object, nullable
  - `dependencies` string[], nullable
  - `progress_percent` integer
  - `progress_message` string, nullable
  - `result_data` object, nullable
  - `error_message` string, nullable
  - `started_at` string, date-time, nullable
  - `completed_at` string, date-time, nullable
  - `scheduled_at` string, date-time, nullable
  - `duration_seconds` integer, nullable
  - `exit_code` integer, nullable
  - `max_retries` integer
  - `retry_count` integer
  - `retry_delay_seconds` integer
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/jackhamr/apis/jackhamr-api.md) · [All operations](https://skmtc.dev/jackhamr/apis/jackhamr-api/llms.txt) · [OpenAPI document](https://skmtc.dev/jackhamr/apis/jackhamr-api/revisions/f75d221481d8?raw)
