# Create a role

`POST https://console.advinservers.com/api/v1/client/teams/{team}/roles`

### Overview

Creates a team role. Send a unique `name` of up to 64 characters, an optional `description` of up to 512 characters without line breaks, and a `permissions` array. Names cannot contain control characters. An empty permission list is allowed. Unknown permission keys return 422. You can grant only permissions you hold. Include each permission's `requires` entries so the role can use it.

### Permissions

Requires the account permission `teams.manage` (Manage teams).

## Authorization

Send `Authorization: Bearer <token>` with the request. Your API key, sent as a bearer token. Create one in the control panel under API Keys, give it only the permissions the integration needs, and copy it when it is created. It cannot be shown again. Each key is restricted to one owned team. The key determines the team for every request.

## Path parameters

- `team` (string, required): The team uuid short

## Body

Sent as `application/json`.

- `name` (string, required): The name shown to customers. 1 to 64 characters. Must match `^[^\p{C}]+$`
- `description` (string | null): An optional description shown to customers. At most 512 characters. Must match `^[^\p{C}\n\r]*$`
- `permissions` (string[], required): The value of `permissions`. At most 44 items

## Response 200

The record, as a JSON object. There is no envelope.

- `id` (string, required): The id ID.
- `uuid_short` (string, required): The value of `uuid_short`.
- `name` (string, required): The name shown to customers.
- `description` (string | null, required): An optional description shown to customers.
- `permissions` (string[], required): Read through the model rather than off the column: a seeded role resolves its permissions from the catalogue every time, so it picks up anything added in a later release, and a key that no longer exists is dropped instead of being shown.
- `type` (string, required): The role type: `system` or `custom`. One of: `system`, `custom`.
- `system_key` (string | null, required): The value of `system_key`.
- `is_system` (boolean, required): The three seeded roles are readable and assignable but never editable or deletable, so an account always has a working set to hand out.
- `members_count` (integer | null, required): Only present when the listing asked for it; a role fetched on its own does not pay for the count.
- `created_at` (string | null, required): The date and time for created at, in UTC.

```json
{
  "id": "18f11680-0831-4d41-9d71-824c99009cbf",
  "uuid_short": "Uuid short",
  "name": "Research Associate",
  "description": "Runs the test chamber servers and takes snapshots before each experiment, but cannot delete, reinstall or spend money.",
  "permissions": [
    "team.read",
    "server.read",
    "server.power",
    "server.console",
    "server.update",
    "backup.read",
    "backup.create",
    "snapshot.read",
    "snapshot.create",
    "firewall.read",
    "firewall.update",
    "network.read",
    "sshkey.read",
    "sshkey.update"
  ],
  "type": "custom",
  "system_key": null,
  "is_system": false,
  "members_count": 1,
  "created_at": "2026-01-09T20:14:52+00:00"
}
```

## Errors

- `401`: The key was missing, malformed, revoked, or belongs to an account that no longer exists.
- `403`: Access denied. Check the key's team, permissions and allowed IP addresses. Some actions, such as managing API keys, require a browser session. The response message explains the reason.
- `404`: The resource was not found in the selected team. Resources in another account or team also return 404.
- `422`: A field is missing or invalid, or the resource cannot accept this change in its current state. Check `message` for details. Field validation also includes an `errors` object keyed by field name.
- `429`: Too many requests. The `Retry-After` header says how many seconds to wait. Limits are per account, so several keys on one account share them.

## Example request

```bash
curl --request POST \
  --url 'https://console.advinservers.com/api/v1/client/teams/{team}/roles' \
  --header 'Authorization: Bearer <token>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Security Officer",
  "description": "Watches the perimeter: can restart servers and manage the firewall, but cannot change, reinstall or delete anything.",
  "permissions": [
    "team.read",
    "server.read",
    "server.power",
    "server.console",
    "firewall.read",
    "firewall.update",
    "network.read"
  ]
}'
```
