# Skills

Find, read, save and run skills, and move them between Spaces as packages.

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

A skill is a `SKILL.md` file in a Space that tells the assistant how you want a job done. You can view them in [Skills](https://app.svanja.com/skills), or use these endpoints to read and save skills from your editor, run one as a task, or copy it to another Space. To read skills, your key needs the Skills area (included in Full access and Read-only). To save or run them, you need Full access or Skills set to **Read and write**. Because skills live in Spaces, a key limited to certain Spaces only sees the skills inside them. For more background, see [Skills, tools and templates](https://www.svanja.com/docs/skills/).

`GET /skills` lists the skills your key can reach, and `GET /skills/source` reads a skill's `SKILL.md` file. To save one, use `POST /skills` or `PATCH /skills/source`. `POST /skills/runs` runs a skill and starts a task:

```json
{
  "space_id": "SPACE_ID",
  "path": "skills/monthly-report/SKILL.md",
  "inputs": {}
}
```

`POST /skills/exports` packs a skill for download. Pass the skill's location as query parameters, such as `?space_id=SPACE_ID&path=skills/monthly-report/SKILL.md`. It returns `202` and finishes the export in the background.

`POST /skills/imports` brings skills into the Space specified by `space_id`. If you upload a skill package as multipart form data in the `file` field, Svanja prepares a preview that you review and finish in the app. To copy a skill from another of your Spaces instead, send `source_space_id` and the skill's `path`. You will get a preview of the copy back; send the same request with `"confirm": true` to complete it. To do this from a terminal, see [svanja skill](https://www.svanja.com/docs/cli/skills/).

## Operations

| Operation | What it does | Effect | Endpoints |
| --- | --- | --- | --- |
| `skill.discover` | Discover Skills. | Reads only | `GET /skills` |
| `skill.export` | Export a Skill package. | Reads only | `POST /skills/exports` |
| `skill.import` | Import a Skill package. | Changes data in Svanja | `POST /skills/imports` |
| `skill.invoke` | Invoke a Skill. | Changes data in Svanja | `POST /skills/runs` |
| `skill.read` | Read Skill source. | Reads only | `GET /skills/source` |
| `skill.save` | Save or update a Skill. | Changes data in Svanja | `POST /skills`<br>`PATCH /skills/source` |

## Endpoints

### GET /api/v1/skills

Discover Skills

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `q` | query | string | no |  |
| `space_id` | query | string | no |  |

### POST /api/v1/skills

Save a new Skill

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Optional key for unsafe bearer writes. Reusing the same key and same canonical body replays the original response for 24 hours; reusing it with a different body returns idempotency_conflict. |

| Body field | Type | Required | Notes |
| --- | --- | --- | --- |
| `space_id` | string | yes |  |
| `path` | string | no |  |
| `name` | string | no |  |
| `description` | string | no |  |
| `content` | string | no |  |
| `expected_revision` | string or null | no |  |

### GET /api/v1/skills/source

Read Skill source

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `space_id` | query | string | yes |  |
| `path` | query | string | yes |  |

### PATCH /api/v1/skills/source

Update Skill source

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Optional key for unsafe bearer writes. Reusing the same key and same canonical body replays the original response for 24 hours; reusing it with a different body returns idempotency_conflict. |

| Body field | Type | Required | Notes |
| --- | --- | --- | --- |
| `space_id` | string | yes |  |
| `path` | string | no |  |
| `name` | string | no |  |
| `description` | string | no |  |
| `content` | string | no |  |
| `expected_revision` | string or null | no |  |

### POST /api/v1/skills/runs

Invoke a Skill

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Optional key for unsafe bearer writes. Reusing the same key and same canonical body replays the original response for 24 hours; reusing it with a different body returns idempotency_conflict. |

| Body field | Type | Required | Notes |
| --- | --- | --- | --- |
| `space_id` | string | yes |  |
| `path` | string | yes |  |
| `inputs` | object | no |  |
| `message` | string | no |  |

### POST /api/v1/skills/imports

Import a Skill package

### POST /api/v1/skills/exports

Export a Skill package
