Create a role

POST /api/roles

Create a new role with the given data.

application/json

Body Required

  • name string Required

    The name of the role. It should be unique within the tenant.

    Minimum length is 1, maximum length is 128.

  • description string Required

    Minimum length is 1, maximum length is 128.

  • type string

    The type of the role. It cannot be changed after creation.

    Values are User or MachineToMachine.

  • scopeIds array[string]

    The initial API resource scopes assigned to the role.

    Minimum length of each is 1.

Responses

  • 200 application/json

    The created role.

    Hide response attributes Show response attributes object
    • id string Required

      Minimum length is 1, maximum length is 21.

    • name string Required

      Minimum length is 1, maximum length is 128.

    • description string Required

      Minimum length is 1, maximum length is 128.

    • type string Required

      Values are User or MachineToMachine.

  • 400

    Bad Request

  • 401

    Unauthorized

  • 403

    Forbidden

  • 422

    Unprocessable Content

POST /api/roles
curl \
 -X POST https://[tenant_id].logto.app/api/roles \
 -H "Content-Type: application/json" \
 -d '{"name":"string","description":"string","type":"User","scopeIds":["string"]}'
Request example
{
  "name": "string",
  "description": "string",
  "type": "User",
  "scopeIds": [
    "string"
  ]
}
Response examples (200)
{
  "id": "string",
  "name": "string",
  "description": "string",
  "type": "User"
}