---
title: "Create a role"
method: POST
path: "/api/roles"
tags: ["Roles"]
---

# Create a role

`POST /api/roles`

Create a new role with the given data.

## Request body

- object
  - `tenantId` string
  - `name` string, required — The name of the role. It should be unique within the tenant.
  - `description` string, required
  - `type` 'User' | 'MachineToMachine' — The type of the role. It cannot be changed after creation.
  - `isDefault` boolean
  - `scopeIds` string[] — The initial API resource scopes assigned to the role.

## Response `200`

The created role.

- object
  - `tenantId` string, required
  - `id` string, required
  - `name` string, required
  - `description` string, required
  - `type` 'User' | 'MachineToMachine', required
  - `isDefault` boolean, required

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `422` — Unprocessable Content

---

[API](https://skmtc.net/logto/apis/logto-api-references.md) · [All operations](https://skmtc.net/logto/apis/logto-api-references/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/logto/logto-api-references/revisions/a163dc77d842/schema)
