Skip to content

Create an account membership

Identity module

POST/account-membershipsaccountMemberships.create

A person in an external organization's account. Creates an account membership. Requires `Idempotency-Key`; a replay returns the original response. The organization is derived from the credential or the parent row, never from the body.

  • Requires the capability me.account.write.
  • OAuth scopes: me.
  • Send an Idempotency-Key header. A replay with the same key returns the original response.
  • Error statuses: 400, 401, 409, 422, 429. Errors are RFC 9457 problem details.

Request body: AccountMembershipCreate

accountMemberships.create: AccountMembershipCreate
FieldTypeRequiredDescription
person_idstring (uuid)YesIdentifier of the member.
account_roleAccountRoleYesRole inside an external account.Constraints: one of "Account Owner", "Account Admin", "Account Finance", "Account Member"
{
  "person_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "account_role": "Account Finance"
}

Response 201: AccountMembership

accountMemberships.create: AccountMembership
FieldTypeRequiredDescription
idstring (uuid)YesIdentifier of the account membership.
created_atstring (date-time)YesWhen the row was created.
updated_atstring (date-time)YesWhen the row was last updated.
person_idstring (uuid)YesIdentifier of the member.
valid_fromstring (date-time)YesStart of account membership.
valid_tostring (date-time) | nullYesEnd of account membership.
{
  "id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "created_at": "2026-10-08T14:30:00Z",
  "updated_at": "2026-10-08T14:30:00Z",
  "person_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "valid_from": "2026-10-08T14:30:00Z",
  "valid_to": "2026-10-08T14:30:00Z"
}

Code samples

curl -X POST "$XOS_BASE_URL/account-memberships" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"person_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","account_role":"Account Finance"}'
const { data } = await xos.accountMemberships.create({
    "person_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
    "account_role": "Account Finance"
  });
response = xos.account_memberships.create({"person_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "account_role": "Account Finance"})
xos account-memberships create --data '{"person_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","account_role":"Account Finance"}'