Auth API reference

Auth API · Consumer-Admin-Roles

put/{app_slug}/v1/admin/roles/{role_name}/permissionsAuth

Replace a role's permission set

Destructive — the role's permission set is replaced wholesale with the supplied array. Caller-narrowed: the caller must hold every permission in the request, otherwise 403 `Cannot grant actions you don't have: ...`. For EndUser callers the caller-held set is their app-membership role's effective permissions. For M2M callers the held set is the token's `scopes[]` claim — the M2M cannot grant a role any verb that wasn't configured on the M2M credential. Unknown permission strings return 400.

Path parameters

app_slug*string

Slug of the app.

role_name*string

Name of the role (e.g. `admin`).

Request body

permissions*array

Array of permission strings in resource.action format

Example: ["user.read","role.create"]

Response · 200 Permissions updated. Returns the set the role now holds — the write is caller-narrowed, so the resulting set is what the caller needs to see.

Array of object

id*string

Unique identifier of the role permission.

resource*string

Resource half of the permission key (`resource.action`).

Example: "user"

action*string

Action half of the permission key (`resource.action`).

Example: "read"

description*string

Free-text description of the role permission, or `null`.

Example

Request

PUT https://api.auth.productcraft.co/{app_slug}/v1/admin/roles/{role_name}/permissions
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "permissions": [
    "user.read",
    "role.create"
  ]
}

Response

[
  {
    "id": "string",
    "resource": "user",
    "action": "read",
    "description": "string"
  }
]