Workspaces and team management
Invite people to a workspace, give each one of four roles (admin, member, approver or viewer) workspace-wide or per environment, keep emergency access, and create the API keys your agents use.
A workspace holds your environments, API keys, members, plan and usage. Each workspace has its own data and its own members, and one person can belong to several workspaces.
Roles are how you keep the people who run agents apart from the people who set the rules for them. A member can build actions and connect accounts but cannot raise an impact limit, change an approval policy or create an API key. So the controls that govern an agent stay with admins, and an agent’s own key never holds the authority to loosen them.
Who can call these endpoints
The endpoints on this page are console endpoints. They take a signed-in console session (the better-auth.session_token cookie), not an API key, and they are not in the API reference. Most teams manage members and keys in the console under Settings → Team and Settings → API keys. The examples below use curl with the session cookie, for scripting the same steps.
A console session can do what the signed-in member’s role allows. An app connected with OAuth is held to the role of the member who connected it. An API key has no role: its scopes decide what it can do.
Choose a role for each person
There are four roles. Admin and member change things. Approver and viewer are for people who should see the workspace without changing it.
| Role | What it can do |
|---|---|
| Viewer | Read everything: actions, approvals, receipts, policies, members and API keys. Change nothing. |
| Approver | Everything a viewer can, and decide approvals. |
| Member | Decide and request approvals. Create, edit, import and invoke actions. Connect accounts and manage secrets. Manage chat integrations. Halt an environment. |
| Admin | Everything a member can, and: change workspace settings and the plan; invite, re-role and remove members; create, regenerate and delete API keys; create, protect, resume and delete environments; change approval policies; set budgets and impact limits; settle unknown outcomes and replay effects; create and promote agents; set or remove an environment’s own OAuth apps; change notification channels, single sign-on, SCIM, audit streaming and secret stores; delete the workspace. |
Halting is the safe direction, so a member or an admin can halt an environment. Only an admin resumes it.
Check what you can do before you try it. GET /api/v2/workspaces/{workspaceId}/permissions returns your role, whether you hold emergency access, and for each environment the role that applies there and its permissions:
curl https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/permissions \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN"
{
"success": true,
"data": {
"role": "member",
"emergencyAccess": false,
"permissions": ["workspace.read", "environments.halt", "actions.manage", "actions.invoke", "connections.manage", "integrations.manage", "approvals.request", "approvals.decide", "resources.write"],
"environmentRolesEnabled": true,
"environments": [
{ "environmentId": "6b0f7c1e-2d4a-4f8e-9b3c-1a2d3e4f5a6b", "role": "approver", "granted": true, "permissions": ["workspace.read", "approvals.decide"] }
]
}
}
A request your role does not allow answers 403, and the message names what is missing, for example “Only a workspace admin can do this.”
List your workspaces
curl https://api.anlyon.com/api/v2/workspaces \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN"
{
"success": true,
"data": [
{
"workspace": {
"id": "2f8a1f72-7cf9-4fef-95e8-df9de5f2f5d0",
"name": "Acme",
"slug": "acme",
"plan": "growth",
"subscriptionStatus": "active",
"trialEndsAt": null,
"createdAt": "2026-09-23T10:00:00.000Z",
"updatedAt": "2026-10-20T08:00:00.000Z"
},
"role": "admin",
"joinedAt": "2026-09-23T10:00:00.000Z"
}
]
}
The workspace object carries a few more usage fields. plan is the plan id: see Plans, billing and usage limits.
Invite someone
An admin sends an invitation by email. The person joins when they sign in with that email address and accept it.
curl -X POST https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/invitations \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "email": "newmember@example.com", "role": "approver" }'
roleisadmin,member,approverorviewer, andmemberwhen you leave it out.- An invitation expires after 7 days. Until then it counts as a seat.
GET /api/v2/workspaces/{workspaceId}/invitationslists pending invitations.POST /api/v2/workspaces/{workspaceId}/invitations/{invitationId}/resendsends one again, andDELETE /api/v2/workspaces/{workspaceId}/invitations/{invitationId}cancels it.- The invited person sees it under
GET /api/v2/invitations/pendingand accepts withPOST /api/v2/invitations/{token}/accept. Accepting from an account with a different email answers403.
When the workspace uses single sign-on, people on its verified domains can join by signing in through the provider instead, and a SCIM directory can add them for you.
Change a member’s role
curl -X PATCH https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/members/$USER_ID \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "role": "viewer" }'
The change applies to the member’s next request. A workspace always keeps at least one admin: demoting or removing the last one, or the last one leaving, answers 409 LAST_ADMIN.
The owner role was merged into admin on 2026-10-24. A request that sends "role": "owner" answers 400 OWNER_ROLE_RETIRED; send "admin". POST /api/v2/workspaces/{workspaceId}/transfer-ownership is deprecated: give emergency access instead.
Remove a member, or leave
# An admin removes someone
curl -X DELETE https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/members/$USER_ID \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN"
# You leave a workspace yourself
curl -X POST https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/leave \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN"
Either way, the person loses access to this workspace only:
- the API keys they created in this workspace are revoked (kept, not deleted, so their history stays readable);
- their apps’ OAuth grants to this workspace end;
- a console session they hold is refused at this workspace from its next request.
Their account and their other workspaces are untouched. Each revoked key is an api_key.revoked audit record whose data.reason is member_removed or member_left.
Revoking someone’s keys stops any agent that used them. Before you remove a person whose keys run production agents, create replacement keys under another admin.
Keep emergency access
One or two admins hold emergency access. When the workspace requires single sign-on, they still sign in with a password and two-factor, and directory sync can never deactivate, delete or re-role them. A mistake at the identity provider therefore cannot lock everyone out. Whoever creates a workspace has it.
An admin with emergency access gives it to another admin, or removes it, in Settings → Team or with:
curl -X PUT https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/members/$USER_ID/emergency-access \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "enabled": true }'
| Answer | Why |
|---|---|
409 EMERGENCY_ACCESS_LIMIT |
Two admins already hold it. Remove it from one first. |
409 LAST_EMERGENCY_ACCESS_ADMIN |
This is the last admin with it. Give it to another admin first. |
409 CONFLICT |
The person is not an admin. Make them an admin first. |
403 |
You do not hold emergency access yourself: only an admin with it can change who has it. |
Each change is a member.emergency_access_granted or member.emergency_access_removed audit record. Give these accounts strong two-factor authentication.
Give someone a different role in one environment
A member can hold a different role in one environment, for example approver in production and member in staging. Every permission that lives in an environment, such as deciding an approval or editing an action, is checked against the role in that environment. An admin with emergency access keeps the admin role in every environment. Roles per environment apply to people, not to API keys: a key belongs to one environment and its scopes decide what it can do. Slack and Discord notification integrations belong to the whole workspace, so the workspace role decides who changes them, not a role in one environment.
curl -X PUT https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/members/$USER_ID/environment-roles/$ENVIRONMENT_ID \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "role": "approver" }'
GET /api/v2/workspaces/{workspaceId}/members/{userId}/environment-roles lists a member’s grants, and DELETE on the path above removes one so the workspace role applies there again. Each change is a member.environment_role_granted or member.environment_role_removed audit record.
Roles per environment are a Team feature. Giving or changing one on a plan without it answers 403 PLAN_FEATURE_REQUIRED. A grant made earlier keeps applying, and removing one always works. See which plans have the Team features.
Who can decide an approval
Deciding needs the approver, member or admin role in the approval’s environment. On top of that, nobody decides their own agent’s request:
- An API key never decides an approval it requested, and an app never decides one it requested for the same person.
- A person never decides a request they or their agent made: one they requested in the console, one an app acting for them requested, or one requested by an API key they created. The request answers
403 SELF_APPROVAL_NOT_ALLOWED, from the console, an app or a key alike. - One exception: the only person who can decide in that environment, deciding directly in the console or with a Slack button, never through an app or an API key. If you work alone, you can decide your own agent’s requests. Each such decision is marked Self-approved (only approver in this environment) in the console, in Slack, in the API (
selfApproved: trueon the vote and on the decision) and in the audit record.
As soon as a second person can decide in that environment, including an approver granted only there, their decision is needed, or a separate approver key’s. Automation that should not need a person is an auto_approve policy, decided in advance by an admin, never the requester voting.
Create an API key for an agent
An admin creates keys in Settings → API keys or with the call below. A key belongs to one environment, which you cannot change later, and holds a set of scopes. See Authentication and API keys for the scopes and presets.
curl -X POST https://api.anlyon.com/api/v2/workspaces/$WORKSPACE_ID/api-keys \
-H "Cookie: better-auth.session_token=$SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Support agent, staging",
"environmentId": "6b0f7c1e-2d4a-4f8e-9b3c-1a2d3e4f5a6b",
"scopes": ["actions:invoke", "actions:read", "approvals:read"],
"expiresAt": "2027-12-31T23:59:59Z",
"endUserRequired": true
}'
| Field | Meaning |
|---|---|
name |
1 to 100 characters. Name the agent and the environment. |
environmentId |
The environment the key belongs to. The workspace’s default environment when left out. |
scopes |
At least one scope. Left out, the key gets the default set, which holds no privileged scope. |
expiresAt |
Optional, and in the future. |
endUserRequired |
true for a key your product uses to act for its users: every action call must name an end user. See Keys that act for your users. |
{
"success": true,
"data": {
"apiKey": {
"id": "c3d4e5f6-0a1b-4c2d-8e3f-4a5b6c7d8e9f",
"workspaceId": "2f8a1f72-7cf9-4fef-95e8-df9de5f2f5d0",
"environmentId": "6b0f7c1e-2d4a-4f8e-9b3c-1a2d3e4f5a6b",
"name": "Support agent, staging",
"keyPrefix": "anlyon_live_a1b2c3d4",
"version": 1,
"isActive": true,
"lastUsedAt": null,
"createdAt": "2026-10-27T10:00:00.000Z",
"expiresAt": "2027-12-31T23:59:59.000Z",
"scopes": ["actions:invoke", "actions:read", "approvals:read"],
"endUserRequired": true
},
"key": "anlyon_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
}
}
key is the full key, and it is shown once. Store it in your secret manager straight away. GET /api/v2/workspaces/{workspaceId}/api-keys lists keys without it, and DELETE /api/v2/workspaces/{workspaceId}/api-keys/{keyId} revokes one.
Errors
| Status and code | When | What to do |
|---|---|---|
401 |
No console session, or an API key sent to a console endpoint. | Sign in to the console. |
403 |
Your role does not allow it. The message says which role can. | Ask an admin. |
403 SELF_APPROVAL_NOT_ALLOWED |
You tried to decide your own agent’s request. | A second approver decides it, or use an auto_approve policy. |
403 PLAN_FEATURE_REQUIRED |
A role per environment on a plan without Team features. | See billing. |
400 OWNER_ROLE_RETIRED |
A body with "role": "owner". |
Send "admin". |
409 LAST_ADMIN, LAST_EMERGENCY_ACCESS_ADMIN, EMERGENCY_ACCESS_LIMIT |
The change would leave no admin, no admin with emergency access, or more than two with it. | Change another member first. |
409 CONFLICT |
The person is already a member, or already has a pending invitation. | Resend the existing invitation. |
429 QUOTA_EXCEEDED |
The plan’s seats are full. Members and pending invitations both count. | Remove a member or cancel an invitation, or change plan. |
Good practice
- Give the admin role to the few people who change keys, members, limits or policies. Make everyone who only decides approvals an approver.
- Keep two admins with emergency access, each with strong two-factor.
- Give each agent its own key, in one environment, with the scopes it uses and an expiry.
- Review members and API keys on a schedule, and revoke keys you no longer use.
Related
- Authentication and API keys: environments, scopes and privileged scopes.
- Single sign-on and SCIM: sign people in through your provider and let your directory manage members.
- Environments and the kill switch: keep a staging key out of production data.
- Approvals and policies: who decides what, and routing with policies.
- Plans, billing and usage limits: seats and Team features by plan.

