---
title: "Attach an existing artifact to a task"
method: POST
path: "/tasks/{taskId}/artifacts"
tags: ["Tasks"]
---

# Attach an existing artifact to a task

`POST /tasks/{taskId}/artifacts`

## Request

- Base URL: `https://api.ziggsai.com`
- URL: `https://api.ziggsai.com/tasks/{taskId}/artifacts`
- Auth: HTTP bearer

## Path parameters

- `taskId` string, required

## Request body

- AttachTaskArtifactDto
  - `artifactId` string, required: Artifact to attach to this container
  - `role` 'input' | 'output': What the artifact is to this task: `output` (a deliverable, the default) or `input` (consumed by it). Set once: a link's role never changes, and asking for a different one on an existing link is reported as a conflict rather than silently ignored.

## Response `201`

Attached. `outcome` is `created` for a new link, or `existing` when the artifact was already attached to this task with this role.

- ArtifactAttachResponseSchema
  - `success` true, required
  - `link` object, required
  - `outcome` 'created' | 'existing', required

## Other responses

- `409`: Already attached with the OTHER role. A link's role is set once (a task's inputs and outputs are not interchangeable), so the request is refused rather than silently keeping the stored role.

---

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