Skip to content

Bulk assign a user to organizations

POST
/bulk/{uid}/organizations
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.

uid
required
string

User ID

Request body

Media typeapplication/json

Body for POST /bulk/{uid}/organizations.

object
role
required

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.

string
Allowed values: owner manager read write provider accountant officeadmin agencyadmin agencyuser none
oids
required

Organization ids to grant role in.

Array<string>
>= 1 items

One result per requested oid, in request order. Check each status; a 200 does not mean every organization was written.

Media typeapplication/json
object
results
required
Array<object>
object
oid
required
string
status
required

Outcome for one target of a bulk assignment.

string
Allowed values: success error
error

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).

string
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.

Media typeapplication/json

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
error

Machine-readable error code.

string
message

Human-readable detail.

string
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.

Media typeapplication/json

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
error

Machine-readable error code.

string
message

Human-readable detail.

string
Example
{
"error": "merchant_account_missing",
"message": "The organization has no merchant account. Complete Stripe Connect onboarding for this organization before generating pricing."
}