Skip to content

Bulk assign users to an organization

POST
/bulk/{oid}/users
curl --request POST \
--url https://apisandbox.puurk.com/bulk/example/users \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "role": "owner", "uids": [ "example" ] }'

Grant several users the same role in one organization 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 that includes the caller’s own uid is refused as a whole with 403. A per-user failure — removing the organization’s last owner — is reported in results with status: error, not as an error status, so the other users are still written.

oid
required
string

Organization ID

Request body

Media typeapplication/json

Body for POST /bulk/{oid}/users.

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
uids
required

User ids to grant role to.

Array<string>
>= 1 items

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

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

Outcome for one target of a bulk assignment.

string
Allowed values: success error
error

Present when status is error: Cannot remove the last owner of an organization, or Failed to assign user (the write for this user 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: uids.

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 for this organization, uids includes the caller’s own uid (Cannot modify your own role), or the caller holds none of: an organization role of owner or agencyadmin, a superadmin claim, or a service token with the admin scope action on organizations. 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."
}

not_found — the organization does not exist.

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."
}