Saltar al contenido

Create an account membership

Módulo Identity

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.

  • Requiere la capacidad me.account.write.
  • Alcances de OAuth: me.
  • Envía el encabezado Idempotency-Key. Una repetición con la misma clave devuelve la respuesta original.
  • Estados de error: 400, 401, 409, 422, 429. Los errores son detalles de problema RFC 9457.

Cuerpo de la solicitud: AccountMembershipCreate

accountMemberships.create: AccountMembershipCreate
CampoTipoObligatorioDescripción
person_idstring (uuid)SíIdentifier of the member.
account_roleAccountRoleSíRole inside an external account.Restricciones: one of "Account Owner", "Account Admin", "Account Finance", "Account Member"
{
  "person_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "account_role": "Account Finance"
}

Respuesta 201: AccountMembership

accountMemberships.create: AccountMembership
CampoTipoObligatorioDescripción
idstring (uuid)SíIdentifier of the account membership.
created_atstring (date-time)SíWhen the row was created.
updated_atstring (date-time)SíWhen the row was last updated.
person_idstring (uuid)SíIdentifier of the member.
valid_fromstring (date-time)SíStart of account membership.
valid_tostring (date-time) | nullSíEnd 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"
}

Ejemplos de código

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