Bulk assign a user to organizations
const url = 'https://apisandbox.puurk.com/bulk/example/organizations';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"role":"owner","oids":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apisandbox.puurk.com/bulk/example/organizations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "role": "owner", "oids": [ "example" ] }'Grant one user the same role in several organizations in one call. Every target is a role modification. Setting a role requires one of: an organization role of owner or agencyadmin in this organization; a superadmin claim; or a service token holding the admin scope action on organizations (globally or for this organization). admin is a scope action, not an organization role, and is rejected as a role value with 400. A request naming the caller’s own uid is refused as a whole with 403. Per-organization failures — an unknown oid, insufficient privilege in that organization, or removing its last owner — are reported in results with status: error, not as an error status, so the other organizations are still written.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”User ID
Request Bodyrequired
Section titled “Request Bodyrequired”Request body
Body for POST /bulk/{uid}/organizations.
object
Role of a user in an organization, as stored in the organization’s roles map. admin is not a role: it is a service-token scope action, and a request that sends it as a role gets 400. Of the organization roles, only owner and agencyadmin may change other members’ roles.
Organization ids to grant role in.
Responses
Section titled “Responses”One result per requested oid, in request order. Check each status; a 200 does not mean every organization was written.
object
object
Outcome for one target of a bulk assignment.
Present when status is error: Organization not found, Insufficient permissions, Cannot remove the last owner of an organization, or Failed to assign user (the write for this organization failed).
Example
{ "results": [ { "status": "success" } ]}bad_request — Missing or invalid required field: role (absent, or not an OrganizationRole; admin is a scope action, not a role) or Missing or empty required field: oids.
The standard error body. error is a stable, machine-readable code — branch on it rather than on message, which is for humans and may change.
object
Machine-readable error code.
Human-readable detail.
Example
{ "error": "merchant_account_missing", "message": "The organization has no merchant account. Complete Stripe Connect onboarding for this organization before generating pricing."}Unauthorized
forbidden — the caller lacks the write action on organizations, or uid is the caller’s own uid (Cannot modify your own role). Nothing is written.
The standard error body. error is a stable, machine-readable code — branch on it rather than on message, which is for humans and may change.
object
Machine-readable error code.
Human-readable detail.
Example
{ "error": "merchant_account_missing", "message": "The organization has no merchant account. Complete Stripe Connect onboarding for this organization before generating pricing."}