# Capabilities and approvals

Find out what your key can do, and prepare actions for a person to approve.

Web version: https://www.svanja.com/docs/cli/discovery/

`svanja capabilities` lists every API operation, shows whether your key can run it right now, and explains why if it can't. Run `svanja capabilities show <name>` for details on a single operation. Agents use these commands to see what they're allowed to do, and you can use them to check a key before running a script.

For actions that need a person's OK in the app, like turning on a rule or publishing a document, use `svanja authorization`. Both `capabilities` and `authorization` work with any key you signed in with, and the person who owns the key is the one who approves. For more background, see [The REST API](https://www.svanja.com/docs/api/).

To prepare an action for approval, run `svanja authorization request`:

```bash
svanja authorization request --body '{"operation":"rule.enable","input":{"id":"RULE_ID"}}' --json
```

The response includes an `approval_url` and an `id`. Once the key's owner opens the link and approves the request, run the action using that `id`:

```bash
svanja rule enable RULE_ID --field authorization_request_id=AUTHORIZATION_REQUEST_ID
```

You can check whether a request has been approved with `svanja authorization show`. Sending email works differently and uses its own two-step flow with [`svanja mail send prepare`](https://www.svanja.com/docs/cli/mail/).

## Commands

### svanja authorization request

Create a human action authorization request.

This command calls POST /authorization-requests on the public Svanja API. The API remains authoritative for validation, access, capabilities, receipts, conflicts and domain-specific failure reasons. Use --query key=value for filters, cursors, pages or operation-specific query fields.

Build the request body with --field key=value, --body '<json>' or --body-file <path>; field flags cannot be combined with body input. Every real mutation sends an idempotency key so a retried request is not applied twice. Pass --idempotency-key <key> to supply your own. Use --dry-run to preview the method, path, query, body fields and idempotency behavior without resolving credentials or contacting the API.

Output modes: default human detail, --plain copy-safe output, --json stable JSON, and --jq/--template transforms over the documented JSON value.

--include-meta adds safe transport context under meta when --json, --jq or --template is selected. The ordinary value moves under data; output without --include-meta remains unchanged. It cannot be combined with --dry-run.

```text
svanja authorization request [flags]
```

Needs a stored key (svanja login) or SVANJA_API_KEY.

| Flag | What it does |
| --- | --- |
| `--body` | JSON request body (mutually exclusive with --field and --body-file) |
| `--body-file` | read the JSON request body from a file, or - for stdin |
| `--dry-run` | preview the request without resolving credentials or contacting the API |
| `--field` | body field as key=value (repeatable; mutually exclusive with --body and --body-file) |
| `--idempotency-key` | explicit idempotency key (1-255 visible ASCII bytes); generated when omitted |
| `--query` | query parameter as key=value (repeatable) |

```bash
svanja authorization request --body '{"operation":"rule.enable","input":{"id":"<rule-id>"}}' --json
svanja authorization show <authorization-request-id>
```

### svanja authorization show

Show an action authorization request.

This command calls GET /authorization-requests/{request} on the public Svanja API. The API remains authoritative for validation, access, capabilities, receipts, conflicts and domain-specific failure reasons. Use --query key=value for filters, cursors, pages or operation-specific query fields.

Output modes: default human detail, --plain copy-safe output, --json stable JSON, and --jq/--template transforms over the documented JSON value.

--include-meta adds safe transport context under meta when --json, --jq or --template is selected. The ordinary value moves under data; output without --include-meta remains unchanged. It cannot be combined with --dry-run.

```text
svanja authorization show <request-id> [flags]
```

Needs a stored key (svanja login) or SVANJA_API_KEY.

| Flag | What it does |
| --- | --- |
| `--query` | query parameter as key=value (repeatable) |

```bash
svanja authorization show <request-id> --json
svanja authorization show <request-id> --plain
svanja authorization show <request-id> --jq .
svanja authorization show <request-id> --template '{{.}}'
svanja authorization show <request-id> --json --include-meta
```

### svanja authorization

Create and inspect action authorization requests.

Use this family to call native Svanja public API operations with the active team API key. The server owns validation, access checks, authorization, receipts and domain-specific behavior; the CLI supplies product identity, explicit arguments, stable output modes and safe local request handling.

```text
svanja authorization [flags]
```

Works without a key.

```bash
svanja authorization --help
```

### svanja capabilities show

Show one capability.

This command calls GET /capabilities/{name} on the public Svanja API. The API remains authoritative for validation, access, capabilities, receipts, conflicts and domain-specific failure reasons. Use --query key=value for filters, cursors, pages or operation-specific query fields.

Output modes: default human detail, --plain copy-safe output, --json stable JSON, and --jq/--template transforms over the documented JSON value.

--include-meta adds safe transport context under meta when --json, --jq or --template is selected. The ordinary value moves under data; output without --include-meta remains unchanged. It cannot be combined with --dry-run.

```text
svanja capabilities show <name> [flags]
```

Needs a stored key (svanja login) or SVANJA_API_KEY.

| Flag | What it does |
| --- | --- |
| `--query` | query parameter as key=value (repeatable) |

```bash
svanja capabilities show <name> --json
svanja capabilities show <name> --plain
svanja capabilities show <name> --jq .
svanja capabilities show <name> --template '{{.}}'
svanja capabilities show <name> --json --include-meta
```

### svanja capabilities

List available operations and unavailable reasons.

This command calls GET /capabilities on the public Svanja API. The API remains authoritative for validation, access, capabilities, receipts, conflicts and domain-specific failure reasons. Use --query key=value for filters, cursors, pages or operation-specific query fields.

Output modes: default human detail, --plain copy-safe output, --json stable JSON, and --jq/--template transforms over the documented JSON value.

--include-meta adds safe transport context under meta when --json, --jq or --template is selected. The ordinary value moves under data; output without --include-meta remains unchanged. It cannot be combined with --dry-run.

```text
svanja capabilities [flags]
```

Needs a stored key (svanja login) or SVANJA_API_KEY.

| Flag | What it does |
| --- | --- |
| `--query` | query parameter as key=value (repeatable) |

```bash
svanja capabilities --json
svanja capabilities --plain
svanja capabilities --jq .
svanja capabilities --template '{{.}}'
svanja capabilities --json --include-meta
```
