Identity & Access Management

Preview — pending review

This reference is generated from the platform API contract and is still under review. Operations, fields, and descriptions can change before publication.

Clone a role into a new custom role

POST
/scopes/{scopeId}/iam/roles/{roleId}/actions/clone

Clones an existing role (built-in or custom) into a new editable custom role, copying its full permission matrix, description and assignable scopes ("Clone role" / "Clone" in the role detail page). This is the starting point for building a custom role: clone a base role, then edit it. The clone is created with custom: true, builtIn: false, zero assignments, and defaults its name to " (copy)" unless overridden in the request body. Validation: source role must exist and be visible to the caller (else 404 NOT_FOUND); the source role's current state must permit cloning; the effective target name must be unique in the tenant (duplicate → 409 CONFLICT) and 1–64 chars when provided — invalid override fields → 422 VALIDATION_FAILED. Async & state: Asynchronous; returns 202 with an Operation (action iam.role.clone) that moves PENDING → RUNNING → SUCCEEDED once the cloned role document is materialized (FAILED on error). On success a resource.updated SSE frame with kind iam.role announces the new role, which then appears in the scoped role list with its resourceId referenced by the Operation. Errors: 401 unauthenticated; 403 when the caller lacks iam:manage in the scope; 404 when the source role does not exist; 409 CONFLICT when the target name already exists; 422 for invalid override fields; 500 on internal failure. Idempotency/Concurrency: Idempotency-Key is required; replaying the same key returns the original 202 Operation instead of producing a second copy. No If-Match applies — the source role is read-only for this action.

Authorization

bearerToken
headerAuthorizationBearer <token>

An API token (pc_live_…) or a service-account key (sak_live_…), created in Identity & Access Management and sent as Authorization: Bearer <token>. Requests are rate limited per credential and per tenant: every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, and a refused request gets 429 RATE_LIMITED with Retry-After.

Path Parameters

scopeId*string

Opaque ownership+authorization scope resolving to tenant + subscription + project.

roleId*string

Identifier of the source role to clone.

Header Parameters

Idempotency-Key*string

Required: this operation creates a new resource asynchronously, so a retry without the key would create a second one. Same key+body within 24h replays the original result; the same key with a different body is 409 CONFLICT. Keys are unique per tenant (the same key in two tenants is two different requests). An API token or service-account (bearer) caller MUST send it -- a request without it is refused with 400 IDEMPOTENCY_KEY_REQUIRED (ErrIdempotencyKeyRequired); reuse the same key on every retry of one logical request. A console session gets one from the edge.

Formatuuid

Request Body

application/json
  1. body

Optional overrides for cloning a role. When omitted, the clone is named " (copy)" and copies the source description, assignable scopes and permissions.

name?string

Display name for the cloned role; defaults to " (copy)".

Match^[^\p{C}\p{Z}\x{10000}-\x{10FFFF}](?:[^\p{C}\p{Zl}\p{Zp}\x{10000}-\x{10FFFF}]*[^\p{C}\p{Z}\x{10000}-\x{10FFFF}])?$
Length1 <= length <= 255
description?string

Description override for the cloned role.

Lengthlength <= 255

Response Body

Clone accepted; returns the tracking Operation for the new custom role.

application/json
  1. response

A long-running operation record. GET /operations/{operationId} returns its current state.

id*string

Operation identifier, unique platform-wide.

action*string

Canonical action id that started this operation, e.g. compute.instance.create.

state*OperationState

State machine for long-running operations. PENDING and RUNNING are transitional; the rest are terminal.

Value in"PENDING""RUNNING""SUCCEEDED""FAILED""CANCELLED"
resourceKind?|

Kind of the target resource (matches RealtimeEvent.kind), null for resource-less actions.

resourceId?|

Identifier of the target resource; null until the resource is allocated.

resourceName?|

Human-readable name of the target resource captured when the operation was opened; null when unknown or the resource has been deleted (clients fall back to resourceId).

principalId?|

Subject id (user id/email or service-account id) of the actor that initiated this operation, captured at the create chokepoint; null on internal/worker paths with no request-scoped principal or for historical rows. This is the real actor the Activity feed renders.

sourceIp?|

Source IP address of the request that initiated this operation; null when unavailable (internal/worker paths, historical rows).

progressPercent?|

Best-effort progress; null when the action does not report progress.

Range0 <= value <= 100
error?|null

Populated only when state is FAILED (or CANCELLED with partial rollback notes).

warning?|null

Non-fatal degradation recorded on an operation that still SUCCEEDED - the primary action completed but something explicitly requested could not be delivered (e.g. publicIp was requested at instance create but no floating IP could be assigned). On a CANCELLED create it reports that the provider resource had already been created and was kept (live and billed until deleted; details.disposition = left_in_place). Same code+message shape as error so clients render both uniformly; null when the operation ran without degradation.

startedAt?|

When the worker began executing; null while PENDING.

finishedAt?|

When a terminal state was reached; null while transitional.

createdAt*string
updatedAt*string
curl -X POST "https://example.com/scopes/string/iam/roles/string/actions/clone" \  -H "Idempotency-Key: 497f6eca-6276-4993-bfeb-53cbbbba6f08" \  -H "Content-Type: application/json" \  -d '{}'
{  "id": "string",  "action": "string",  "state": "PENDING",  "resourceKind": "string",  "resourceId": "string",  "resourceName": "string",  "principalId": "string",  "sourceIp": "string",  "progressPercent": 0,  "error": {    "code": "string",    "message": "string",    "field": "string",    "details": {},    "retryable": false  },  "warning": {    "code": "string",    "message": "string",    "field": "string",    "details": {},    "retryable": false  },  "startedAt": "string",  "finishedAt": "string",  "createdAt": "string",  "updatedAt": "string"}