Saltar al contenido

Create a notification preference

Módulo Platform

POST/notification-preferencesnotificationPreferences.create

A per-kind, per-channel notification preference. Creates a notification preference. 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.notifications.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: NotificationPreferenceCreate

notificationPreferences.create: NotificationPreferenceCreate
CampoTipoObligatorioDescripción
channel"In App" | "Email" | "SMS" | "Push"SíDelivery channel.
enabledbooleanSíWhether the channel is on for the kind.
membership_idstring (uuid)SíIdentifier of the membership whose preference this is; preferences are per org.
category_codestringSíNotification category.Restricciones: pattern ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$
{
  "channel": "In App",
  "enabled": true,
  "membership_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "category_code": "approvals"
}

Respuesta 201: NotificationPreference

notificationPreferences.create: NotificationPreference
CampoTipoObligatorioDescripción
idstring (uuid)SíIdentifier of the notification preference.
created_atstring (date-time)SíWhen the row was created.
updated_atstring (date-time)SíWhen the row was last updated.
channel"In App" | "Email" | "SMS" | "Push"SíDelivery channel.
enabledbooleanSíWhether the channel is on for the kind.
membership_idstring (uuid)SíIdentifier of the membership whose preference this is; preferences are per org.
category_codestringSíNotification category.Restricciones: pattern ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$
{
  "id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "created_at": "2026-10-08T14:30:00Z",
  "updated_at": "2026-10-08T14:30:00Z",
  "channel": "In App",
  "enabled": true,
  "membership_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "category_code": "approvals"
}

Ejemplos de código

curl -X POST "$XOS_BASE_URL/notification-preferences" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"channel":"In App","enabled":true,"membership_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","category_code":"approvals"}'
const { data } = await xos.notificationPreferences.create({
    "channel": "In App",
    "enabled": true,
    "membership_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
    "category_code": "approvals"
  });
response = xos.notification_preferences.create({"channel": "In App", "enabled": True, "membership_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "category_code": "approvals"})
xos notification-preferences create --data '{"channel":"In App","enabled":true,"membership_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","category_code":"approvals"}'