Ir al contenido
AtheronDEVELOPERS

Webhooks

The events we send, their payloads, how they are signed and how retries work.

Inicie sesión para ver su propio ID de cliente de prueba en los ejemplos.

Add a webhook for the test or live environment on your app's Webhooks page. We send a POST with a JSON body to your https address, signed with your signing secret.

Events

typeWhen
user.signed_inSomebody signed in to your app: a code was issued to your client.
consent.revokedSomebody took back your access, from their account or any other way, or we suspended your app.
membership.changedThe plan of somebody who granted you the membership scope changed.
pingYou pressed Send a test on the app's Webhooks page.

Headers

HeaderWhat it is
Atheron-Signaturet=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with your signing secret>.
Atheron-Event-IdThe event's id. Keep the ones you handled and ignore a repeat.
Content-Typeapplication/json.

Checking the signature

The hex is HMAC-SHA256 of <t>.<raw body> with your signing secret (whsec_..., shown once). Use the raw body, exactly as received, and refuse anything older than five minutes.

Este ejemplo aún no está escrito en cURL. Se muestra en TypeScript.

// Check that a webhook came from Atheron before you act on it. Pass the raw body, exactly as received.
import { verifyWebhook, type WebhookEvent } from "@aton-network/sdk";

export async function handleWebhook(request: Request): Promise<Response> {
  const raw = await request.text();
  const ok = await verifyWebhook(request.headers.get("atheron-signature"), raw, process.env.ATHERON_WEBHOOK_SECRET!);
  if (!ok) return new Response("bad signature", { status: 400 });
  const event = JSON.parse(raw) as WebhookEvent;
  if (event.type === "consent.revoked") {
    // Delete the refresh token you hold for event.data.sub, and stop using what you read.
  }
  return new Response(null, { status: 204 });
}

Retries

Answer with any 2xx within ten seconds. Anything else is tried again after 1, 5 and 30 minutes, then 2, 6, 12 and 24 hours, then we give up. We never follow redirects, and never deliver to a private or loopback address. Use Atheron-Event-Id to ignore a delivery you already handled.

Sending a delivery again

When your endpoint was down, send past deliveries again from the app's Webhooks tab (one, or every one that gave up) or with atheron webhooks replay. A resend is the original delivery as it was, the same body and the same Atheron-Event-Id, signed at the moment it goes, so the handler that drops repeats keeps working. Each resend is tried once. You can resend deliveries from the last thirty days, up to 25 at a time and 60 an hour for an app; live deliveries need the owner or admin role, and every resend shows in the app's Activity.

A full walk through is in the webhooks tutorial.

Pregunte a Atlas

Asistente de IA

Pregunte lo que quiera sobre Iniciar sesión con Atheron, la API o el portal. La respuesta sale de nuestra documentación, con enlaces a las páginas usadas.