Access
Preview

Create a custom role

POST
/roles
cookiebetter-auth.session_token<token>

Better Auth session cookie. Production uses the __Secure- prefixed name.

Idempotency-Key?string

Makes retries safe. A repeated key with the same request returns the first result and sets Idempotent-Replayed: true. The same key with a different request answers 409 idempotency.key_reused, and while the first request is still running 409 idempotency.in_progress. Results are kept for 24 hours. Server errors and refusals for lack of sign-in or permission are not kept, so a retry runs again.

Match^[A-Za-z0-9_.:-]+$
Length1 <= length <= 255
application/json
  1. body
name*string
Length1 <= length <= 80
description*string
Lengthlength <= 500
granted*string
Value in"org""scope"
permissions*array<string>

Response Body

The created role.

application/json
  1. response
id*string
Formatuuid
name*string
description*string
granted*string

Given org-wide, or on a scope.

Value in"org""scope"
builtin*boolean

Built-in roles can be duplicated but not edited or deleted.

permissions*array<string>

Permission keys. * is everything, *:read every read.

bindingCount*integer
Formatint64
minOrgRole?OrgRole

The lowest organization role a person needs for this role to count. Below it the role is paused.

Value in"owner""admin""contributor""viewer"
placeKinds?array<>

The kinds of place this role can be granted on.

Example Request
curl -X POST 'https://wardn.example.com/api/v1/roles' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "description": "string",  "granted": "org",  "permissions": [    "string"  ]}'
Example Response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "name": "string",  "description": "string",  "granted": "org",  "builtin": true,  "permissions": [    "string"  ],  "bindingCount": 0,  "minOrgRole": "owner",  "placeKinds": [    "org"  ]}