1. Docs
  2. API Reference
  3. Bulk-create role assignments. All-or-nothing: any failure rolls back the entire batch

Bulk-create role assignments. All-or-nothing: any failure rolls back the entire batch

POST/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/assignments/bulk-create

Authentication

  • Bearer Token Authorization

    JWT access token

Request body

  • assignmentsBulkCreateAssignmentItemDto[]*

Code samples

cURLJavaScriptPythonGo
curl -X POST "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/assignments/bulk-create" \
  -H "Authorization: Bearer $CANOPY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "assignments": [
      {
        "identity_id": "string",
        "node_id": "string",
        "role_id": "string",
        "effective_from": "string",
        "effective_to": "string"
      }
    ]
  }'

Responses

200 Assignments created — all items succeeded
{
  "summary": {
    "total": 0,
    "succeeded": 0,
    "failed": 0
  },
  "results": [
    {
      "index": 0,
      "status": "success",
      "code": 0,
      "data": {
        "id": "string",
        "identity_id": "string",
        "application_node_id": "string",
        "role_id": "string",
        "effective_from": "2026-04-20T12:00:00.000Z",
        "effective_to": "2026-04-20T12:00:00.000Z",
        "created_at": "2026-04-20T12:00:00.000Z",
        "updated_at": "2026-04-20T12:00:00.000Z"
      }
    }
  ]
}

application/json

  • summaryobject*
  • resultsobject[]*
207 Assignments created — mixed outcomes (one or more items failed)
{
  "summary": {
    "total": 0,
    "succeeded": 0,
    "failed": 0
  },
  "results": [
    {
      "index": 0,
      "status": "success",
      "code": 0,
      "data": {
        "id": "string",
        "identity_id": "string",
        "application_node_id": "string",
        "role_id": "string",
        "effective_from": "2026-04-20T12:00:00.000Z",
        "effective_to": "2026-04-20T12:00:00.000Z",
        "created_at": "2026-04-20T12:00:00.000Z",
        "updated_at": "2026-04-20T12:00:00.000Z"
      }
    },
    {
      "index": 0,
      "status": "error",
      "code": 0,
      "input": {},
      "error": {
        "code": "string",
        "message": "string",
        "details": {}
      }
    }
  ]
}

application/json

  • summaryobject*
  • results("success" | "error")[]*
401 Invalid or expired token
403 This token is not authorized for this endpoint (wrong principal type — e.g., admin token on identity-only endpoint, or vice versa)
On this page

Related endpoints

GETList all assignments across the Application
GETGet App-wide assignment summary
POSTAssign a role to an identity at a node
PATCHUpdate an assignment
DELETERemove an assignment
POSTBulk remove assignments
POSTBulk change role on assignments