/v1/apps/{app_id}/rolesAuthCreate a new role (no permissions yet — set them via PUT /:roleName/permissions)
Path parameters
app_id*stringId of the app.
Headers
Idempotency-KeystringRetry safety: a repeat with the same key and body replays the first response instead of creating a role again. Same key with a different body: 409 `IDEMPOTENCY_KEY_REUSE`. 24 h window.
Request body
name*stringName of the role.
Example: "editor"
descriptionstringFree-text description of the role, or `null`.
Example: "Can edit content"
Response · 201 Role created.
id*stringRole UUID.
app_id*stringApp scope (UUID).
name*stringRole name slug.
Example: "admin"
description*stringFree-text description.
is_system*booleanWhether this is a system role (owner / admin / member).
created_at*string · date-timeWhen the role was created (ISO 8601).
updated_at*string · date-timeWhen the role was last changed (ISO 8601).
Example
Request
POST https://api.auth.productcraft.co/v1/apps/{app_id}/roles
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"name": "editor",
"description": "Can edit content"
}import { Auth } from "@productcraft/auth";
// Admin routes read PRODUCTCRAFT_API_KEY; consumer routes need no key
const auth = new Auth();
const role = await auth.admin.app("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f").roles.create({ name: "editor" });auth.admin.app(…).roles.create(params, options?): Auth.Role
Response
{
"id": "string",
"app_id": "string",
"name": "admin",
"description": "string",
"is_system": false,
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z"
}