Skip to content

Create Role

POST/web/v1/workspaces/{workspaceId}/roles JWT

Creates a new custom role within a workspace. Only CUSTOM roles can be created via this endpoint; OWNER roles are created automatically with the workspace.

Required Headers

HeaderExample ValueDescription
Content-Typeapplication/jsonRequest content type
Acceptapplication/jsonExpected response type
X-Client-HashClient device fingerprint
Accept-Languageen, zh, zh-Hant, ja, viResponse language (default: en)
AuthorizationBearerJWT access token
X-Workspace-IdTarget workspace ID

Request Parameters

NameTypeRequiredInDescription
workspaceIdStringRequiredpathBusiness ID of the workspace

Request Body

json
{
  "roleName": "Editor",
  "description": "Custom role with edit permissions"
}

Request Example

json
{
  "roleName": "Editor",
  "description": "Can edit content"
}

Success Response

Status: 201 Created

201 Created 201
{
  "version": "1.3.0",
  "timestamp": 1709337600000,
  "success": true,
  "code": "2001",
  "message": "CREATED",
  "data": {
    "bizId": "role_abc123def456",
    "workspaceBizId": "WS_ROLE_TEST_001",
    "roleName": "Editor",
    "roleType": {
      "value": 10010902,
      "name": "CUSTOM",
      "code": "CUSTOM"
    },
    "description": "Custom role with edit permissions",
    "permissionCodes": null,
    "createdAt": "2026-03-22T10:30:00Z",
    "updatedAt": "2026-03-22T10:30:00Z"
  }
}

Response Fields

FieldTypeDescription
bizIdStringUnique role business ID
workspaceBizIdStringParent workspace business ID
roleNameStringRole display name
roleTypeObjectRole type enum: OWNER or CUSTOM
descriptionStringRole description
permissionCodesArrayPermission codes (null on creation, set via Set Role Permissions)
createdAtStringISO 8601 creation timestamp
updatedAtStringISO 8601 last update timestamp

Error Responses

Unauthorized 401
{
  "success": false,
  "code": "4010",
  "message": "Invalid or expired token"
}
Conflict 409
{
  "success": false,
  "code": "WORKSPACE.ROLE_NAME_EXISTS",
  "message": "A role with this name already exists in the workspace"
}

Notes

  • Returns HTTP 201 with response code "2001" on success.
  • Duplicate role names within the same workspace return 409 WORKSPACE.ROLE_NAME_EXISTS.
  • Requires workspace:role:write permission.

SlaunchX Internal Documentation