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

# Create and enqueue a task.

`POST /v1/tasks`

Provide exactly one of `payload` or `payload_base64`. If the
deployment is configured with a `TaskVerificationKey`, the
caller must also supply a valid `signature`; the server does
not sign on behalf of callers.

## Headers

- `Idempotency-Key` string

## Request body

- TaskCreateRequest — Provide exactly one of `payload` or `payload_base64`. Setting both yields HTTP 400 with `code: invalid_argument`.
  - `type` string, required
  - `queue` string
  - `payload` unknown
  - `payload_base64` string, byte — Pre-encoded payload bytes for non-JSON content.
  - `deadline` string, date-time — Absolute RFC3339 cut-off for starting the task.
  - `max_tries` integer
  - `dependencies` string[]
  - `load_dependencies` boolean
  - `signature` string — Hex-encoded ed25519 signature computed over the library's signing envelope. Required only when the deployment is configured with a `TaskVerificationKey`.

## Response `201`

Task created and enqueued.

- Task — Materialized task. `payload` is base64-encoded, matching the library's `[]byte` JSON encoding. Decode before use. When resubmitting the same payload to `POST /v1/tasks`, place the undecoded base64 string into `payload_base64`.
  - `id` string, required
  - `type` string, required
  - `queue` string
  - `dependencies` string[]
  - `dependency_results` object
  - `load_dependencies` boolean
  - `payload` string, byte, required — Base64-encoded payload bytes.
  - `deadline` string, date-time
  - `max_tries` integer
  - `result` TaskResult
    - `payload` unknown, required
    - `completed` string, date-time, required
  - `state` 'new' | 'active' | 'retry' | 'expired' | 'terminated' | 'complete' | 'queue_error' | 'blocked' | 'unreachable', required
  - `created` string, date-time, required
  - `tried` string, date-time
  - `tries` integer
  - `last_err` string
  - `signature` string — Hex-encoded ed25519 signature, when present.

## Other responses

- `400` — Input validation error.
- `409` — State conflict, e.g. duplicate resource or blocked transition.
- `413` — Request body exceeds the server's size limit.

---

[API](https://skmtc.net/choria-io/apis/asyncjobs-http-api.md) · [All operations](https://skmtc.net/choria-io/apis/asyncjobs-http-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/choria-io/asyncjobs-http-api/versions/48b17d96adbf/schema)
