Saltar al contenido

Invite a member

Módulo Identity

POST/invitesinvites.create

Invites an email to the caller's organization with a role the inviter may grant and an expiry of 1 hour to 30 days, through `app.invite_member`. Replaces any pending invite for the same email. Refused with 422 for a role above the inviter's band, a capability the inviter does not hold, an out-of-range expiry or a self-invite. The token is returned once. Requires `Idempotency-Key`; a replay returns the original response. A rule that refuses the request returns 422 with `refusal` and `reason`.

  • Requiere la capacidad org.members.invite.
  • Alcances de OAuth: org.
  • 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: InviteMemberRequest

invites.create: InviteMemberRequest
CampoTipoObligatorioDescripción
emailstring (email)SíInvitee email.
role_idstring (uuid)SíIdentifier of the role offered, at or below the inviter's band.
valid_for_hoursintegerNoHours until the invite expires, from 1 to 720. Default 336 (14 days).Restricciones: range 1 to 720
{
  "email": "alex.rivera@northwindlive.example",
  "role_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "valid_for_hours": 336
}

Respuesta 201: InviteMemberResult

invites.create: InviteMemberResult
CampoTipoObligatorioDescripción
invite_idstring (uuid)SíIdentifier of the invite.
invite_tokenstringSíInvite token from the invitation email. Sent in the body, never in a URL.Restricciones: length 1 to any
{
  "invite_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "invite_token": "xinv_3f9a1c0d7e2b4a6f8c1d0e9b7a5c3f1e"
}

Ejemplos de código

curl -X POST "$XOS_BASE_URL/invites" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"email":"alex.rivera@northwindlive.example","role_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","valid_for_hours":336}'
const { data } = await xos.invites.create({
    "email": "alex.rivera@northwindlive.example",
    "role_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
    "valid_for_hours": 336
  });
response = xos.invites.create({"email": "alex.rivera@northwindlive.example", "role_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "valid_for_hours": 336})
xos invites create --data '{"email":"alex.rivera@northwindlive.example","role_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","valid_for_hours":336}'