Bulk-attach AppMemberships for the env-scoped Add-from-directory picker
/portal/v1/accounts/{accountSlug}/applications/{appSlug}/app-memberships/bulk-attachAuthentication
- Bearer Token
AuthorizationJWT access token
Request body
identity_ids *string[]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
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..."
]
}'const response = await fetch("https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/app-memberships/bulk-attach", {
method: "POST",
headers: {
"Authorization": "Bearer $CANOPY_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"identity_ids": [
"id_01HXABC...",
"id_01HXDEF..."
]
}),
});
const data = await response.json();import requests
response = requests.post(
"https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/app-memberships/bulk-attach",
headers={
"Authorization": "Bearer $CANOPY_TOKEN",
"Content-Type": "application/json"
},
json={
"identity_ids": [
"id_01HXABC...",
"id_01HXDEF...",
],
},
)
data = response.json()package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload := map[string]interface{}{
"identity_ids": []interface{}{
"id_01HXABC...",
"id_01HXDEF...",
},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/app-memberships/bulk-attach", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer $CANOPY_TOKEN")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
}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
summary *objectresults *object[]
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
summary *objectresults *("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)