# Discovery and account

Who the key belongs to, what it may do, the team's plan and credits, and approvals.

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

These endpoints tell your code where it stands before it does anything. `GET /whoami` returns the team, the key, and its access. `GET /capabilities` lists every operation and tells you whether this key can use it right now. `GET /capabilities/{name}` gives the details for a single operation. Agents that explore the API on their own start here.

The account endpoints show your plan, what it includes, and what you've used, much like [Credits and usage](https://app.svanja.com/credits) in the app. They require the Account, Credits, and Team areas, which are included in both Full access and Read-only keys. For more on how these work, see [The REST API](https://www.svanja.com/docs/api/) and [Plans, credits and prices](https://www.svanja.com/docs/credits-and-prices/).

The account endpoints are `GET /account`, `/account/entitlements`, and `/account/usage`. Credits have separate endpoints for the balance and the list of transactions. The team endpoints list the members and the team's invitations, along with each one's status.

`POST /authorization-requests` sets up an operation that needs a person's approval before it runs, such as turning on a rule:

```json
{ "operation": "rule.enable", "input": { "id": "RULE_ID" } }
```

The response includes an `approval_url` to send to the person and an `id`. Once they approve it, send the operation itself with `authorization_request_id` set to that id. You can check the status in the meantime with `GET /authorization-requests/{id}`. Sending email uses its own flow and isn't prepared here.

You can also fetch the [OpenAPI document](https://app.svanja.com/api/v1/openapi.json) without a key. If you prefer the terminal, `svanja whoami`, `svanja capabilities`, `svanja account`, and `svanja credits` do the same things. See [Sign-in and setup commands](https://www.svanja.com/docs/cli/setup/) and [Account, credits and API keys](https://www.svanja.com/docs/cli/account/).

## Operations

| Operation | What it does | Effect | Endpoints |
| --- | --- | --- | --- |
| `account.read` | Read account state and entitlements. | Reads only | `GET /account`<br>`GET /account/entitlements`<br>`GET /account/usage` |
| `capability.discover` | Search available operations. | Reads only | `GET /capabilities` |
| `capability.read` | Read one operation contract. | Reads only | `GET /capabilities/{name}` |
| `credit.read` | Read credit balances and transactions. | Reads only | `GET /credits/balance`<br>`GET /credits/transactions` |
| `team.read` | Read team directory. | Reads only | `GET /team/members`<br>`GET /team/invitations` |
| `whoami` | Read authenticated caller identity. | Reads only | `GET /whoami` |

## Endpoints

### GET /api/v1/openapi.yaml

Download the OpenAPI YAML document

Works without an API key.

### GET /api/v1/openapi.json

Download the OpenAPI JSON document

Works without an API key.

### GET /api/v1/capabilities

Search public API operation capabilities

Returns family summaries, operation summaries, examples and the authenticated key's current availability for matching public operations. Discovery is descriptive and does not grant authority.

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `q` | query | string | no |  |
| `family` | query | string | no |  |
| `effect_class` | query | one of read, internal, external, owner | no |  |
| `available` | query | boolean | no |  |
| `include_examples` | query | boolean | no |  |

### GET /api/v1/capabilities/{name}

Read one public API operation capability

Returns full operation metadata including schemas, examples, endpoints, failure reasons, effect class, undo metadata and current availability.

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

### GET /api/v1/whoami

Show the authenticated team API key context

Returns the team, API key metadata, effective public API capabilities, and selected-project scope summary for the bearer key.

### GET /api/v1/account

Show account summary

Returns compact account, key, plan, subscription, API access, credit, billing availability, auto top-up, and related endpoint links for any valid team API key.

### GET /api/v1/account/entitlements

Show account entitlements

Returns account-level capability, feature, limit, and project-scope entitlement state for a key with Account read access.

### GET /api/v1/account/usage

Show account usage

Returns bounded credit, purchased-credit, usage-window, and recent transaction summaries for a key with Account read access.

### GET /api/v1/credits/balance

Show credit balance

Returns the team-level credit balance, normalized subscription summary, and last credit update timestamp.

### GET /api/v1/credits/transactions

List credit transactions

Lists the team-level credit ledger with public transaction type labels. Selected-project keys with Credits read access see the full team ledger.

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `page` | query | integer | no | Page number. Defaults to 1. |
| `per_page` | query | integer | no | Page size. Defaults to 25 and is capped at 100. |
| `type` | query | one of credit_added, credit_spent, debt, adjustment, other | no | Public credit transaction type. |
| `created_from` | query | string | no | Inclusive created_at lower bound. Must include seconds and Z or an explicit UTC offset. |
| `created_to` | query | string | no | Inclusive created_at upper bound. Must include seconds and Z or an explicit UTC offset. |
| `sort` | query | one of created_at, -created_at | no | Sort credit transactions by creation time. |

### GET /api/v1/team/members

List team members

Lists active team members for the authenticated team. The owner appears first with the owner role, followed by active pivot members ordered by join time. Removed and soft-deleted users are excluded.

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `page` | query | integer | no | Page number. Defaults to 1. |
| `per_page` | query | integer | no | Page size. Defaults to 25 and is capped at 100. |

### GET /api/v1/team/members/{member}

Show a team member

Shows one active team member by public user ID. Missing, malformed, cross-team, removed, and soft-deleted users return the same public not-found error once the key has Team read access.

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `member` | path | string | yes | Team member public user ULID. This is not the legacy numeric user id. |

### GET /api/v1/team/invitations

List pending team invitations

Lists non-deleted pending invitations for the authenticated team, ordered newest first with id as a stable tie-breaker.

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `page` | query | integer | no | Page number. Defaults to 1. |
| `per_page` | query | integer | no | Page size. Defaults to 25 and is capped at 100. |

### GET /api/v1/team/invitations/{invitation}

Show a pending team invitation

Shows one pending team invitation by public invitation ID. Missing, malformed, cross-team, and deleted invitations return the same public not-found error once the key has Team read access.

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `invitation` | path | string | yes | Team invitation public ULID. This is not the legacy numeric invitation id. |

### POST /api/v1/authorization-requests

Create a human authorization request

Prepare an operation that requires human approval using the same target resolution as execution. Supply input.id for an existing resource and input.action when choosing among actions. Other input fields are the intended execution body. The server binds current target versions; caller-supplied _target is ignored. After browser approval, execute the matching route/body with authorization_request_id before expires_at. Approval is bound to this API key and visibility user. Changed targets or inputs require new approval. Operations without an action handoff return validation_failed.

| Body field | Type | Required | Notes |
| --- | --- | --- | --- |
| `operation` | string | yes |  |
| `family` | string | no | Optional compatibility hint; the operation determines the family. |
| `input` | object | yes |  |
| `message` | string | no |  |

### GET /api/v1/authorization-requests/{authorization_request}

Read a human authorization request

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