Create a role

POST /api/roles

Create a new role with the given data.

application/json

Body Required

  • tenantId string

    Maximum length is 21.

  • 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.

  • isDefault boolean
  • 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
    • tenantId string Required

      Maximum length is 21.

    • 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.

    • isDefault boolean Required
  • Bad Request

  • Unauthorized

  • Forbidden

  • Not Found

  • Unprocessable Content

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