# Artifacts

Read the documents tasks made, save new versions, make charts and save them to a Space.

Web version: https://www.svanja.com/docs/api/artifacts/

An artifact is what the API calls a document, such as a PDF, a sheet, or a chart that a task made. In the app, you can find them under [Skills, Documents](https://app.svanja.com/skills?tab=documents). These endpoints let you fetch a finished document, save an edited version, or file it in a client's Space. To read artifacts, your key needs the Artifacts area, which is included in Full access and Read-only. To make changes, you need Full access or Artifacts set to **Read and write**. See [Skills, tools and templates](https://www.svanja.com/docs/skills/) for more.

`GET /artifacts` lists your documents, and `GET /artifacts/{id}` returns a single document along with its `current_version` and `versions` list. Each version has its own `id`, which you need to pass whenever you make a change:

```bash
curl -X POST https://app.svanja.com/api/v1/artifacts/ARTIFACT_ID/actions \
  -H "Authorization: Bearer $SVANJA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"action":"save_to_space","version_id":"VERSION_ID","space_id":"SPACE_ID"}'
```

You can also run `restore`, `save_source`, `save_csv`, `create_chart`, `save_chart`, and `attach`. If you attach a document to an email draft, someone still has to approve it in the app (see [The REST API](https://www.svanja.com/docs/api/)). If you prefer working from a terminal, see [svanja artifact and svanja publish](https://www.svanja.com/docs/cli/artifacts-and-publishing/).

## Operations

| Operation | What it does | Effect | Endpoints |
| --- | --- | --- | --- |
| `artifact.attach` | Attach an artifact. | Changes data in Svanja | `POST /artifacts/{id}/actions` |
| `artifact.read` | Read artifacts. | Reads only | `GET /artifacts`<br>`GET /artifacts/{id}` |
| `artifact.revise` | Revise an artifact. | Changes data in Svanja | `POST /artifacts/{id}/actions` |

## Endpoints

### GET /api/v1/artifacts

List artifacts

### POST /api/v1/artifacts

Run an artifact collection action

### GET /api/v1/artifacts/{id}

Read an artifact

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |

### PATCH /api/v1/artifacts/{id}

Update an artifact

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |

### POST /api/v1/artifacts/{id}/actions

Run an artifact action

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |
