1. Docs
  2. API Reference
  3. Bulk-attach AppMemberships for the env-scoped Add-from-directory picker

Bulk-attach AppMemberships for the env-scoped Add-from-directory picker

POST/portal/v1/accounts/{accountSlug}/applications/{appSlug}/app-memberships/bulk-attach

Authentication

  • Bearer Token Authorization

    JWT access token

Request body

  • identity_idsstring[]*

    Identity IDs to attach to this Application as active AppMembership rows. Each row is processed independently — pre-existing memberships and validation failures are reported per-item rather than failing the batch. Max 200 per request.

Code samples

cURLJavaScriptPythonGo
curl -X POST "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/app-memberships/bulk-attach" \
  -H "Authorization: Bearer $CANOPY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "identity_ids": [
      "id_01HXABC...",
      "id_01HXDEF..."
    ]
  }'

Responses

200 Per-row AppMembership creation. Each identity is processed independently — pre-existing memberships and validation errors fail individually without aborting the batch. Returns 200 on full success or 207 Multi-Status on mixed outcomes; the body is always `{ summary, results }` so callers iterate the same way regardless. AppMembership only — to assign a role at a node, follow up with the env-scoped bulk-create-assignments endpoint. — all items succeeded
{
  "summary": {
    "total": 0,
    "succeeded": 0,
    "failed": 0
  },
  "results": [
    {
      "index": 0,
      "status": "success",
      "code": 0,
      "data": {
        "id": "string",
        "identity_id": "string",
        "application_id": "string",
        "status": "invited",
        "invited_at": "2026-04-20T12:00:00.000Z",
        "activated_at": "2026-04-20T12:00:00.000Z",
        "deactivated_at": "2026-04-20T12:00:00.000Z",
        "created_at": "2026-04-20T12:00:00.000Z"
      }
    }
  ]
}

application/json

  • summaryobject*
  • resultsobject[]*
207 Per-row AppMembership creation. Each identity is processed independently — pre-existing memberships and validation errors fail individually without aborting the batch. Returns 200 on full success or 207 Multi-Status on mixed outcomes; the body is always `{ summary, results }` so callers iterate the same way regardless. AppMembership only — to assign a role at a node, follow up with the env-scoped bulk-create-assignments endpoint. — 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_id": "string",
        "status": "invited",
        "invited_at": "2026-04-20T12:00:00.000Z",
        "activated_at": "2026-04-20T12:00:00.000Z",
        "deactivated_at": "2026-04-20T12:00:00.000Z",
        "created_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)