# Account and workspace API

Read your account and usage, manage sessions, tokens, members and invitations, and add Slack, Discord or webhook alert destinations through the API.

These routes cover your own account, your workspace and its people, and the places AgentProof sends alerts. Most of them need a signed-in browser, because they change who can reach your workspace. Two groups also accept [API tokens](/docs/api/): your usage, and alert destinations.

| Routes | API token | Browser session |
|---|---|---|
| Account, signed-in browsers, tokens | No | Yes |
| Usage | Yes, `runs:read` | Yes |
| Workspace, members, invitations | No | Yes |
| Alert destinations | Yes, `notifications:read` or `notifications:write` | Yes |

A token sent to a browser-only route gets `403 insufficient_scope`: "This token cannot perform that action." Browser requests that change something must send the `X-CSRF-Token` header from the same site; see [browser sessions and CSRF](/docs/api/#browser-sessions-and-csrf). The examples for browser-only routes show the raw request. The dashboard's **Settings** pages do the same things with buttons.

## Account routes

| Method | Path | What it does |
|---|---|---|
| GET | `/api/account` | Reads your account. |
| PATCH | `/api/account` | Changes your name and preferences. |
| GET | `/api/account/sessions` | Lists your signed-in browsers. |
| DELETE | `/api/account/sessions/{id}` | Signs out one browser. |
| GET | `/api/account/tokens` | Lists your API tokens. |
| POST | `/api/account/tokens` | Creates an API token. |
| DELETE | `/api/account/tokens/{id}` | Revokes an API token. |
| GET | `/api/account/usage` | Reads your workspace's limits, usage and hours. |
| DELETE | `/api/account` | Deletes your account. |

### Read your account

`GET /api/account` is browser session only. It answers with your account and your workspace:

```json
{
  "id": "usr_rv3mxfrog4oeikhug7ur4542",
  "workspace": {
    "id": "wks_bi3isox4bprri6pz32eg5szg",
    "name": "Sam's workspace",
    "role": "owner",
    "status": "active",
    "createdAt": "2026-11-12T09:40:58.201Z"
  },
  "email": "sam@example.com",
  "emailVerified": true,
  "displayName": "Sam",
  "status": "active",
  "timezone": "America/New_York",
  "defaultView": "month",
  "emailRunReports": true,
  "emailWeeklySummary": true,
  "createdAt": "2026-11-12T09:40:58.201Z"
}
```

`workspace` is `null` when you belong to no workspace. `role` is `owner`, `admin` or `member`. There is no separate route that reads the workspace; use this one.

### Update your profile and preferences

`PATCH /api/account` is browser session only. Send only the fields you want to change. It answers with the whole account.

| Field | Dashboard label | Rule |
|---|---|---|
| `displayName` | **Your name** | Up to 80 characters ("Use 80 characters or fewer."). |
| `timezone` | **Time zone** | A time zone name such as `Europe/Berlin` ("Choose a valid time zone."). |
| `defaultView` | **Calendar view** | `month` or `week` ("Choose month or week."). |
| `emailRunReports` | **Run reports** | `true` or `false` ("Choose on or off."). |
| `emailWeeklySummary` | **Weekly summary** | `true` or `false` ("Choose on or off."). |

```text
PATCH /api/account
Content-Type: application/json
X-CSRF-Token: <csrfToken from GET /api/auth/session>

{"timezone": "Europe/Berlin", "emailWeeklySummary": false}
```

Any other field, such as `email`, gets `400 field_not_editable` with "This field cannot be changed here." The API cannot change your email address. In the dashboard these fields are on **Settings > Account**; see [emails](/docs/emails/) for what the two email switches send.

### Signed-in browsers

`GET /api/account/sessions` is browser session only. It lists the browsers signed in to your account, most recently used first.

```json
{
  "sessions": [
    {
      "id": "wss_cjzxmc7g5bplutivmawb4u3f",
      "current": true,
      "createdAt": "2026-11-25T13:58:02.771Z",
      "lastSeenAt": "2026-11-25T14:21:40.105Z",
      "expiresAt": "2026-12-02T14:21:40.105Z",
      "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) …"
    }
  ]
}
```

`DELETE /api/account/sessions/{id}` signs that browser out and answers `204`. Signing out the browser you are using also clears its cookie. In the dashboard this is **Sign out** next to the browser under **Settings > Security**.

### Tokens through the API

These routes are browser session only. Most people create tokens in **Settings > Security** instead; see [create an API token](/docs/api/#create-an-api-token).

`GET /api/account/tokens` lists your tokens that have not expired or been revoked:

```json
{
  "tokens": [
    {
      "id": "tok_tfr566kcfdmsps4ozgzs6o25",
      "name": "Nightly CI",
      "prefix": "apt_xwrlob",
      "scopes": ["reports:read", "runs:read", "runs:write"],
      "createdAt": "2026-11-25T14:30:12.004Z",
      "expiresAt": "2026-12-25T14:30:12.004Z",
      "lastUsedAt": null
    }
  ]
}
```

`POST /api/account/tokens` creates one:

```text
POST /api/account/tokens
Content-Type: application/json
X-CSRF-Token: <csrfToken from GET /api/auth/session>

{"name": "Nightly CI", "scopes": ["runs:read", "runs:write", "reports:read"], "expiresInDays": 30}
```

It answers `201` with `{"token": {...}, "secret": "apt_..."}`. The `secret` is the token itself and is shown only in this reply.

- `name`: 1 to 60 characters ("Use 1 to 60 characters.").
- `scopes`: at least one of the [listed scopes](/docs/api/#scopes-a-token-can-have) ("Choose at least one scope." or "Choose listed scopes only.").
- `expiresInDays`: 1 to 365 ("Choose 1 to 365 days."). The dashboard form offers 7, 30 and 90.
- You must have signed in within the last 10 minutes. Otherwise the answer is `403 reauth_required` ("Check your email for a sign-in link, then try again.") and AgentProof emails you a fresh sign-in link.
- Each person can have 20 tokens. Past that: `409 limit_reached`, "Revoke a token before creating another."
- 10 tries per 15 minutes per person. Past that: `429 rate_limited`.

`DELETE /api/account/tokens/{id}` revokes a token and answers `204`.

### Usage, limits and hours

`GET /api/account/usage` accepts a token with the `runs:read` scope, or a browser session. Any member can call it.

```bash
curl https://isagentproof.com/api/account/usage \
  -H "Authorization: Bearer $AGENTPROOF_TOKEN"
```

```json
{
  "scope": { "workspaceId": "wks_bi3isox4bprri6pz32eg5szg", "activeRuns": "user" },
  "limits": { "activeRuns": 1, "agents": 50, "schedules": 5, "storageBytes": 104857600, "runModelTokens": 120000000 },
  "used": { "agents": 2, "schedules": 1, "storageBytes": 18874368 },
  "reserved": { "activeRuns": 0 },
  "runtime": { "provider": "morph", "model": "…", "harness": "0.2.2-rc.1", "vm": { "vcpu": 2, "memoryGb": 4, "diskGb": 25 } },
  "executionEnabled": true,
  "billing": {
    "enabled": true,
    "plan": "team",
    "interval": "month",
    "status": "active",
    "currentPeriodEnd": "2026-12-12T09:41:07Z",
    "cancelAtPeriodEnd": false,
    "canRun": true,
    "hours": {
      "included": 100,
      "used": 12.5,
      "left": 87.5,
      "extra": 0,
      "extraCost": "$0",
      "spendingCap": "$200",
      "resetsAt": "2026-12-12T09:41:07Z",
      "periodStart": "2026-11-12T09:41:07Z"
    }
  }
}
```

The numbers above are an example; your reply shows your workspace's own.

- `limits` are the workspace's limits. `activeRuns` is how many of your own runs can go at once; `scope.activeRuns: "user"` says it counts per person, and `reserved.activeRuns` is how many you have going now. `schedules` and `storageBytes` are shared by the workspace. `runModelTokens` is the model token budget of one run.
- `used` is what the workspace uses now: agents, schedules and stored files in bytes.
- `runtime` names the model provider, model and agent software, and the size of each agent's computer.
- `executionEnabled` is `false` when AgentProof cannot start runs right now.
- `billing.plan` is `starter`, `team` or `scale`, `interval` is `month` or `year`, and `status` is the subscription's status (`none` without one). `canRun` is `true` when the plan allows runs and hours are left.
- `billing.hours` is in hours: `included` in the plan, `used` this month, `left` of the included hours, and `extra` past them. `extraCost` is what the extra hours cost so far and `spendingCap` the most they may cost this month. `resetsAt` is when the month's hours reset. See [plans](/docs/plans/).
- When billing is not turned on, `billing` is `{"enabled": false, "canRun": true}`.

### Close your account

`DELETE /api/account` is browser session only, and needs a sign-in within the last 10 minutes (otherwise `403 reauth_required`, with a fresh link emailed to you). It allows 10 tries per 15 minutes.

It answers `202` with `{"status": "deleting"}` and signs you out. Then:

- Every signed-in browser, API token and connected app of yours stops working.
- A workspace you own where you are the only member is deleted with all its data, and its subscription is cancelled.
- In other workspaces you are removed as a member. Runs, reports and schedules you made there stay with that workspace.

If you own a workspace that has other members, the answer is `409 owner_transfer_required`: "Transfer ownership of your shared workspace before deleting your account." [Transfer ownership](#transfer-ownership) first. In the dashboard this is **Delete account** under **Settings > Security**.

**Warning:**
Deleting your account cannot be undone. A workspace deleted with it loses its reports and evidence.

## Workspace and member routes

All of these are browser session only.

| Method | Path | What it does |
|---|---|---|
| POST | `/api/workspaces` | Creates a workspace, when you have none. |
| PATCH | `/api/workspaces/current` | Renames the workspace. |
| DELETE | `/api/workspaces/current` | Deletes the workspace. |
| GET | `/api/workspaces/current/members` | Lists the members. |
| PATCH | `/api/workspaces/current/members/{userId}` | Changes a member's role. |
| DELETE | `/api/workspaces/current/members/{userId}` | Removes a member. |
| POST | `/api/workspaces/current/leave` | Leaves the workspace. |
| POST | `/api/workspaces/current/transfer` | Makes another member the owner. |

Each account belongs to one workspace. "Current" always means yours; you cannot pick another one. The dashboard does these things on **Settings > Team**; see [team and roles](/docs/team-and-roles/).

### Create a workspace

`POST /api/workspaces` with `{"name": "..."}` (1 to 60 characters) creates a workspace with you as its owner and answers `201` with the workspace. It works only when you belong to no workspace, for example after you left one. Otherwise the answer is `409 limit_reached`: "Your account already has a workspace."

### Rename the workspace

`PATCH /api/workspaces/current` with `{"name": "..."}` (1 to 60 characters, "Use 1 to 60 characters.") renames it. Owner only. It answers with the workspace.

```text
PATCH /api/workspaces/current
Content-Type: application/json
X-CSRF-Token: <csrfToken from GET /api/auth/session>

{"name": "Acme security"}
```

```json
{ "id": "wks_bi3isox4bprri6pz32eg5szg", "name": "Acme security", "role": "owner", "status": "active", "createdAt": "2026-11-12T09:40:58.201Z" }
```

### Delete the workspace

`DELETE /api/workspaces/current` deletes the workspace and everything in it. Owner only. Send the workspace's name exactly, as a check: `{"name": "Acme security"}`. A different name gets "Type the workspace name exactly." It also needs a sign-in within the last 10 minutes.

It answers `202` with `{"status": "deleting"}`. At once, runs that are going are stopped, schedules are turned off, open invitations are withdrawn and members lose access. Then AgentProof cancels the subscription and deletes the agents, runs, reports, evidence and files.

**Warning:**
Deleting the workspace cannot be undone. Export any reports you want to keep first.

### List the members

`GET /api/workspaces/current/members` works for any member. It lists the owner first, then admins, then members.

```json
{
  "members": [
    { "userId": "usr_rv3mxfrog4oeikhug7ur4542", "email": "sam@example.com", "displayName": "Sam", "role": "owner", "current": true, "joinedAt": "2026-11-12T09:40:58.201Z" },
    { "userId": "usr_xzyldbtfo7ecwuet6dmjos23", "email": "lee@example.com", "displayName": "Lee", "role": "member", "current": false, "joinedAt": "2026-11-20T16:02:11.390Z" }
  ]
}
```

`current` marks you.

### Give a member another role

`PATCH /api/workspaces/current/members/{userId}` with `{"role": "admin"}` or `{"role": "member"}` changes a role. Owner only. It answers `{"ok": true}`. The owner's own role cannot be changed this way, and a person who is not a member answers `404`; ownership moves only by [transfer](#transfer-ownership).

### Take a member out of the workspace

`DELETE /api/workspaces/current/members/{userId}` removes a member and answers `204`. Admins can remove members; only the owner can remove an admin. Nobody can remove the owner (`403 forbidden`). To remove yourself, use leave instead (`409 use_leave`: "Use Leave workspace to remove yourself.").

The person loses access at once, and their open run streams close. Runs, reports and schedules they made stay with the workspace.

### Leave the workspace

`POST /api/workspaces/current/leave` removes you and answers `204`. Admins and members can leave. The owner gets `409 owner_transfer_required`: "Transfer ownership or delete the workspace first."

### Transfer ownership

`POST /api/workspaces/current/transfer` with `{"userId": "usr_..."}` makes that member the owner. Owner only, and it needs a sign-in within the last 10 minutes. You become an admin. It answers `{"ok": true}`.

- Choosing yourself gets "Choose another member."
- A person who already owns a workspace gets `409 already_owner`: "That member already owns a workspace."
- A person who is not a member answers `404`.

## Invitation routes

All of these are browser session only.

| Method | Path | What it does |
|---|---|---|
| GET | `/api/workspaces/current/invitations` | Lists open invitations. |
| POST | `/api/workspaces/current/invitations` | Invites a person by email. |
| DELETE | `/api/workspaces/current/invitations/{id}` | Withdraws an invitation. |
| POST | `/api/workspaces/invitations/accept` | Accepts an invitation. |

### See pending invitations

`GET /api/workspaces/current/invitations` lists invitations nobody has accepted, withdrawn or let expire. Owners and admins only.

```json
{
  "invitations": [
    { "id": "inv_cepwbff5bjzxtzgvdnzy3sdz", "email": "kim@example.com", "role": "member", "createdAt": "2026-11-25T14:40:00.310Z", "expiresAt": "2026-12-02T14:40:00.310Z" }
  ]
}
```

### Invite a person

`POST /api/workspaces/current/invitations` with `{"email": "...", "role": "member"}` invites someone. Owners and admins can invite members; only the owner can invite admins.

```text
POST /api/workspaces/current/invitations
Content-Type: application/json
X-CSRF-Token: <csrfToken from GET /api/auth/session>

{"email": "kim@example.com", "role": "member"}
```

It answers `201` with the invitation and emails the person "You're invited to an AgentProof workspace" with an **Accept invitation** button. The invitation lasts 7 days. Inviting the same address again replaces the earlier invitation.

- `email`: "Enter a valid email address." or "This person is already a member."
- `role`: "Choose admin or member." or "Only the owner can invite admins."
- 20 invitations per hour per workspace (`429 rate_limited`).
- One email per address every 60 seconds: `429 email_too_soon`, "We sent an email to this address less than a minute ago. Try again in N seconds."

### Withdraw an invitation

`DELETE /api/workspaces/current/invitations/{id}` withdraws an open invitation so its link stops working. Owners and admins only. It answers `204`.

### Accept an invitation

`POST /api/workspaces/invitations/accept` with `{"token": "..."}` joins the workspace and answers with it. The token is the text after `#token=` in the invitation link. Most people just open the link and press the button on the page it opens.

- You must be signed in with the email address the invitation was sent to (`403 email_mismatch`: "This invitation is for a different email address.").
- `403 email_unverified`: "Confirm your email first."
- `400 invalid_token`: "This invitation is invalid or has expired."
- `409 workspace_exists`: "Leave or delete your current workspace before joining another." Each account belongs to one workspace.
- 20 tries per hour per person.

## Alert destination routes

Alert destinations are the Slack channels, Discord channels and webhooks that get AgentProof's events. See [notifications](/docs/notifications/) for the events, the message contents and how to check webhook signatures. In the dashboard they are on **Settings > Notifications**.

| Method | Path | What it does |
|---|---|---|
| GET | `/api/workspaces/current/notifications` | Lists destinations, recent deliveries and event names. |
| POST | `/api/workspaces/current/notifications` | Adds a destination. |
| DELETE | `/api/workspaces/current/notifications/{id}` | Removes a destination. |
| POST | `/api/workspaces/current/notifications/{id}/test` | Sends a test message. |
| POST | `/api/workspaces/current/notifications/{id}/enable` | Turns a destination on. |
| POST | `/api/workspaces/current/notifications/{id}/disable` | Turns a destination off. |
| POST | `/api/workspaces/current/notifications/{id}/rotate-secret` | Makes a new webhook signing secret. |

Listing needs `notifications:read` and works for any member. Every other route needs `notifications:write` and an owner or admin.

### Get destinations and deliveries

```bash
curl https://isagentproof.com/api/workspaces/current/notifications \
  -H "Authorization: Bearer $AGENTPROOF_TOKEN"
```

```json
{
  "destinations": [
    {
      "id": "ntf_a6ep2ufym24ab3jzbb2r5v3u",
      "kind": "slack",
      "name": "Security channel",
      "destination": "hooks.slack.com/services/...",
      "events": ["report.ready", "findings.recorded"],
      "enabled": true,
      "lastSuccessAt": "2026-11-25T14:53:05.880Z",
      "createdAt": "2026-11-20T10:12:44.017Z"
    }
  ],
  "deliveries": [
    {
      "id": "msg_wcgj36mnub5axebv6ngyjhmm",
      "endpointId": "ntf_a6ep2ufym24ab3jzbb2r5v3u",
      "destination": "Security channel",
      "event": "report.ready",
      "state": "delivered",
      "attempts": 1,
      "lastStatus": 200,
      "createdAt": "2026-11-25T14:53:02.300Z",
      "deliveredAt": "2026-11-25T14:53:05.880Z"
    }
  ],
  "events": ["report.ready", "findings.recorded", "fix.opened", "fix.ready", "fix.verified", "fix.regressed", "schedule.skipped", "domain.verification_lost", "billing.updated"]
}
```

- `destination` on a destination shows only the host of its address; the full address is never returned. On a delivery, `destination` is the destination's name.
- A turned-off destination has `"enabled": false` and a `disabledReason`: "Disabled by a workspace admin.", "The destination answered 410 Gone." or "Deliveries failed for 5 days."
- `deliveries` holds the 20 newest. `state` is `pending`, `sending`, `delivered`, `failed` or `canceled`; a failure adds `lastError`.

### Add a destination

`POST /api/workspaces/current/notifications` takes `kind`, `name`, `url` and `events`:

```bash
curl https://isagentproof.com/api/workspaces/current/notifications \
  -H "Authorization: Bearer $AGENTPROOF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "webhook",
    "name": "Our alert service",
    "url": "https://alerts.example.com/agentproof",
    "events": ["findings.recorded", "fix.verified"]
  }'
```

```json
{
  "destination": {
    "id": "ntf_a6ep2ufym24ab3jzbb2r5v3u",
    "kind": "webhook",
    "name": "Our alert service",
    "destination": "alerts.example.com/...",
    "events": ["findings.recorded", "fix.verified"],
    "enabled": true,
    "lastSuccessAt": null,
    "createdAt": "2026-11-25T15:02:19.448Z"
  },
  "secret": "whsec_..."
}
```

It answers `201`. Only a webhook has a `secret`, the key that signs each message. It is shown only in this reply, so save it.

| Field | Rule |
|---|---|
| `kind` | `webhook`, `slack` or `discord` ("Choose Webhook, Slack or Discord."). |
| `name` | 1 to 60 characters ("Use 1 to 60 characters."). |
| `url` | Slack: `https://hooks.slack.com/services/...`. Discord: `https://discord.com/api/webhooks/...`. Webhook: a public `https` address on port 443 or 8443 ("Use an https address.", "Use port 443 or 8443.", "Use a public address."). |
| `events` | At least one name from `events` ("Choose at least one event." or "Choose listed events only."). |

A workspace can have 10 destinations. Past that: `409 limit_reached`, "Remove a destination before adding another."

### Remove a destination

`DELETE /api/workspaces/current/notifications/{id}` removes it and answers `204`.

### Send a test, turn on, turn off or rotate the secret

- `POST .../{id}/test` sends an `endpoint.test` message at once and answers with its delivery, so you can see `state` and `lastStatus`. A turned-off destination gets `409 disabled`: "Enable this destination first."
- `POST .../{id}/enable` and `POST .../{id}/disable` turn it on or off and answer `{"ok": true}`.
- `POST .../{id}/rotate-secret` answers `{"secret": "whsec_..."}` with a new signing secret. For 24 hours, messages are signed with both the old and the new secret, so you can switch without missing any. Slack and Discord destinations get `409 no_secret`: "Only webhooks have a signing secret."

## Related pages

- [AgentProof API](/docs/api/) Tokens, scopes, errors, paging and limits.
- [Runs and reports API](/docs/api-runs/) Start runs, follow events, and download reports and traces.
- [Team and roles](/docs/team-and-roles/) What owners, admins and members can do.
- [Notifications](/docs/notifications/) Event payloads and webhook signatures.
