Webhooks

On this page

Tenth sends a webhook to your server for every change to your customers: a subscription starting or renewing, a refund, credits being spent, and so on. Each delivery carries the customer's full state, so you can update your records from the webhook alone.

Set up an endpoint

  1. In the dashboard, open Webhooks and add an endpoint. Its URL must be https and reachable from the public internet.
  2. Choose the event types it receives, or leave the list empty to receive everything.
  3. Copy the signing secret (tenth_whsec_...). It's shown only when you create or rotate it.
  4. Use Send test event to check your handler. Test deliveries have type test.

Then verify each delivery with verifyWebhook from @tenthbilling/node, which has Express and Fastify examples.

The request

Tenth sends a POST with a JSON body and these headers:

HeaderValue
Tenth-Signaturet=<unix timestamp>,v1=<signature>. The signature is HMAC-SHA256, in hex, over <timestamp>.<raw body> with the endpoint's secret.
Tenth-Event-IdThe event's ID. The same on every retry of the event.
Tenth-Event-TypeThe event type, such as subscription.renewed.
Tenth-Delivery-IdThis delivery's ID.

Always check the signature over the raw body before you act on the event. verifyWebhook does that, and rejects timestamps more than 5 minutes off.

The payload

A complete subscription.renewed delivery:

JSON
{
  "id": "0193a6f2-6c1e-7b3a-9d41-2f0c8e5b7a10",
  "type": "subscription.renewed",
  "version": "2026-10-25",
  "created_at": "2026-11-10T14:03:12.000Z",
  "occurred_at": "2026-11-10T14:03:09.000Z",
  "app_id": "0192a1b0-3d5e-7f21-8c44-6a9b0d1e2f33",
  "environment": "live",
  "data": {
    "subject": { "type": "subscription", "id": "0193a6f2-5a07-7c11-b2e3-4d5f6a7b8c90" },
    "before": {
      "status": "active",
      "product_id": "0192a1b4-9e8f-7a6b-8c5d-4e3f2a1b0c9d",
      "current_period_start": "2026-10-10T14:03:09.000Z",
      "current_period_end": "2026-11-10T14:03:09.000Z",
      "auto_renew": true,
      "quantity": 1
    },
    "after": {
      "status": "active",
      "product_id": "0192a1b4-9e8f-7a6b-8c5d-4e3f2a1b0c9d",
      "current_period_start": "2026-11-10T14:03:09.000Z",
      "current_period_end": "2026-12-10T14:03:09.000Z",
      "auto_renew": true,
      "quantity": 1
    },
    "product": "pro_monthly",
    "store": "apple"
  },
  "customer": {
    "customer": {
      "id": "0192c3d4-1a2b-7c3d-9e4f-5a6b7c8d9e0f",
      "app_user_id": "user_2abc123",
      "app_account_token": "6f1c2d3e-4b5a-4c6d-8e7f-9a0b1c2d3e4f",
      "obfuscated_account_id": "a1b2c3d4e5f6",
      "created_at": "2026-09-01T08:00:00.000Z"
    },
    "entitlements": {
      "pro": {
        "active": true,
        "source": "subscription",
        "store": "apple",
        "expires_at": "2026-12-10T14:03:09.000Z",
        "will_renew": true,
        "in_grace": false,
        "billing_issue": false,
        "quantity": null
      }
    },
    "credits": { "ai_credits": { "balance": 120, "available": 100 } },
    "subscriptions": [
      {
        "id": "0193a6f2-5a07-7c11-b2e3-4d5f6a7b8c90",
        "product": "pro_monthly",
        "store": "apple",
        "status": "active",
        "current_period_start": "2026-11-10T14:03:09.000Z",
        "current_period_end": "2026-12-10T14:03:09.000Z",
        "trial_end": null,
        "grace_period_end": null,
        "cancel_at": null,
        "will_renew": true,
        "provisional": false
      }
    ]
  }
}

customer is nested. The top-level customer is the whole CustomerState, and the customer record is inside it, so the app user ID is at customer.customer.app_user_id. customer.customer.id is Tenth's own ID for the customer.

FieldDescription
idThe event's ID. Use it to dedupe.
typeThe event type (see below).
versionThe payload version, currently 2026-10-25.
created_atWhen Tenth recorded the event.
occurred_atWhen it happened.
app_idThe app it belongs to.
environmenttest or live.
dataDetails of the event. Its fields depend on the type; see Event data.
customerThe customer's full state right after the change: entitlements, credits and subscriptions, as GET /v1/customers/{id} returns it. null for test events.

In TypeScript, verifyWebhook returns this as a WebhookEvent. The same body is in the payload field of each entry in the event feed (tenth.events.list).

Check environment against the key your server uses, so a misconfigured test endpoint can't change live records (see Check the environment).

Event data

Every event's data (except test) has the same frame, plus fields for its type:

FieldDescription
subject{ type, id }: what changed. type is subscription, purchase, entitlement, grant, credit_lot, credit_type, revenue_transaction or customer, and id is Tenth's ID for it.
beforeThe subject's relevant fields before the change, or null when it's new. Only on some types.
afterThe same fields after the change. Only on some types.

Amounts and quantities are numbers, and times are ISO 8601 strings. Tenth may add fields to data, so ignore fields you don't know.

Typessubject.typebefore and afterOther fields
subscription.* (except anchor_changed) and trial.*subscription{ status, product_id, current_period_start, current_period_end, auto_renew, quantity }; before is null for a new subscriptionproduct (the catalog key, or null if the store product isn't in the catalog), store
subscription.anchor_changedsubscriptionafter only: { day, month, timezone, first_period, next_billing_at }none
purchase.completedpurchaseafter only: { status, type }product, store
purchase.transferredsubscription or purchasenonedirection (out on the old owner's event, in on the new owner's), and to_customer_id or from_customer_id
purchase.sharedsubscription or purchasenonedirection, and with_customer_id (owner's event) or owner_customer_id (the other customer's)
refund.issuedrevenue_transactionnoneamount (minor units, negative), currency, refunded_transaction_id
dispute.openedsubscription or purchase{ dispute }: null, open, won or lostnone
dispute.closedsubscription or purchase{ dispute }outcome: won or lost
entitlement.granted, entitlement.revokedentitlement{ active, source, store, expires_at, quantity }entitlement (the key)
grant.created, grant.revokedgrantThe grant: { id, entitlement, credit_type, amount, starts_at, expires_at, reason, created_by, revoked_at, created_at }; grant.created has after onlynone
credits.grantedcredit_lotnonecredit_type, amount, source, expires_at, and debt_repaid when part of it paid off a negative balance
credits.debitedcredit_typenonecredit_type, amount, metadata (what the debit was sent with)
credits.expiredcredit_lotnonecredit_type, amount, reason
credits.clawed_backcredit_lotnonecredit_type, amount, owed (what's still owed after the clawback)
customer.aliasedcustomernonealias (the app user ID that now resolves to this customer)
customer.mergedcustomernonealias, and merged_into (on the customer that was merged away) or merged_from (on the one that remains)
customer.deletedcustomernonenone
testnone (no subject)nonemessage

IDs such as product_id and merged_into are Tenth's IDs. Catalog keys, such as product and entitlement, are the keys you set in the dashboard.

Event types

New event types can be added without a new payload version, so ignore types you don't know.

Subscriptions

TypeMeaning
subscription.startedA paid subscription started.
subscription.renewedA subscription renewed for a new period.
subscription.plan_changedThe subscription's quantity changed.
subscription.product_changedThe subscription moved to a different product.
subscription.cancel_scheduledThe subscription is set to end at the end of the period.
subscription.uncanceledA scheduled cancellation was withdrawn.
subscription.billing_issueA payment failed.
subscription.recoveredA failed payment went through.
subscription.pausedThe subscription was paused.
subscription.resumedA paused subscription resumed.
subscription.price_increaseThe provider reported a price increase for the subscription.
subscription.extendedThe current period was extended without a renewal.
subscription.anchor_changedThe subscription's billing day changed.
subscription.revokedThe subscription ended early, such as after a refund.
subscription.expiredThe subscription ended.

Free trials

TypeMeaning
trial.startedA free trial started.
trial.convertedA free trial converted to a paid subscription.
trial.canceledThe customer turned off renewal during a free trial.

Purchases, refunds and disputes

TypeMeaning
purchase.completedA one-time purchase completed.
purchase.transferredA purchase moved from one customer to another.
purchase.sharedA purchase was shared with another customer.
refund.issuedA refund was issued.
dispute.openedA chargeback was opened.
dispute.closedA chargeback was closed.

Access and grants

TypeMeaning
entitlement.grantedThe customer gained an entitlement.
entitlement.revokedThe customer lost an entitlement.
grant.createdA grant was given.
grant.revokedA grant was revoked.

Credits

TypeMeaning
credits.grantedCredits were added.
credits.debitedCredits were spent.
credits.expiredCredits expired.
credits.clawed_backCredits were taken back, such as after a refund.

Customers

TypeMeaning
customer.aliasedAnother app user ID was linked to the customer.
customer.mergedThe customer was merged with another customer.
customer.deletedThe customer's personal data was deleted.

Other

TypeMeaning
testSent from the dashboard's Send test event. customer is null.

The full list is exported from @tenthbilling/node as WEBHOOK_EVENT_TYPES.

Delivery and retries

  • Deliveries are at least once, so the same event can arrive more than once. Dedupe on id (or the Tenth-Event-Id header).
  • Delivery is attempted for 72 hours. An event that still hasn't been acknowledged by then isn't sent again unless you replay it from the endpoint's deliveries in the dashboard, so treat the event feed below as the record and webhooks as the fast path.
  • Respond with any 2xx status to acknowledge. Anything else, a timeout (10 seconds) or a redirect counts as a failure. Redirects aren't followed.
  • A failed delivery is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours and 10 hours, then every 12 hours, until 72 hours after the event.
  • An endpoint that has failed continuously for 72 hours is turned off, and the workspace's owners and admins get an email. Its pending deliveries are dropped. Turning it back on in the dashboard resumes deliveries for new events.
  • Events are never lost when deliveries fail: they stay in the event feed. Read from where you left off with tenth.events.listAll({ after: lastProcessedId }).

Respond quickly and do slow work afterwards, for example by queueing the event, so deliveries don't time out.