StackupDocs
Stackup

Notifications

Get notified when payments complete via polling or webhooks.

Methods

MethodDescriptionReturns
notifyCheck payment status or handle webhooks{ allowed: boolean } or handler
endpoints.createCreate a webhook endpointEndpoint
endpoints.listList all webhook endpointsEndpoint[]
endpoints.updateUpdate a webhook endpointEndpoint
endpoints.rotateSecretRotate endpoint secretEndpoint

notify

Type (parameters: { mode: "check"; accessToken: string; customerID: string; productID: string }) => Promise<{ allowed: boolean }>

Type (parameters: { mode: "webhook"; secret: string; handler: (event: WebhookEvent) => Promise<void> }) => RequestHandler

Check payment status via polling or create a webhook handler.

// Check mode - poll the API
const { data } = await notify({
  mode: "check",
  accessToken: "sk-...",
  customerID: "cus_01ABC123",
  productID: "prd_01DEF456"
})

if (data?.allowed) {
  // Customer has paid, grant access
}
// Webhook mode - receive real-time notifications
export const handler = notify({
  mode: "webhook",
  secret: process.env.WEBHOOK_SECRET!,
  handler: async (event) => {
    if (event.type === "payment.succeeded") {
      const { customer, payment } = event.payload
      
      await db.orders.update({
        where: { txHash: payment.txHash },
        data: { status: "paid" }
      })
    }
  }
})

endpoints.create

Type (parameters: { name: string; url: string; events: string[] }) => Promise<Endpoint>

Create a new webhook endpoint.

const endpoint = await stackup.webhook.endpoints.create({
  name: "My Webhook",
  url: "https://example.com/webhooks",
  events: ["payment.succeeded"]
})

// Save the secret
console.log("Secret:", endpoint.data.secret)

endpoints.list

Type () => Promise<Endpoint[]>

List all webhook endpoints for the current workspace.

const endpoints = await stackup.webhook.endpoints.list()

endpoints.update

Type (parameters: { id: string; name?: string; url?: string; events?: string[]; status?: "active" | "paused" }) => Promise<Endpoint>

Update an existing webhook endpoint.

await stackup.webhook.endpoints.update({
  id: endpoint.data.id,
  status: "paused"
})

endpoints.rotateSecret

Type (parameters: { id: string }) => Promise<Endpoint>

Rotate the signing secret for a webhook endpoint.

await stackup.webhook.endpoints.rotateSecret({ id: endpoint.data.id })

Event Types

EventDescription
payment.succeededPayment completed successfully

Payload Format

{
  "type": "payment.succeeded",
  "payload": {
    "customer": {
      "walletAddress": "0x...",
      "email": "user@example.com",
      "name": "John Doe"
    },
    "payment": {
      "status": "succeeded",
      "amount": "1000000",
      "tokenAddress": "0x...",
      "txHash": "0x...",
      "blockNumber": 12345678,
      "productID": "prd_..."
    }
  }
}

Security

Webhooks are signed with HMAC-SHA256. The SDK automatically verifies signatures with a default tolerance of 5 minutes.

Retry Behavior

Failed deliveries retry up to 3 times with delays: immediate, 5 minutes, 30 minutes.

Types

Endpoint

PropertyTypeDescription
idstringUnique identifier
workspaceIDstringParent workspace
namestringEndpoint display name
urlstringDestination URL
secretstringSigning secret (whsec_...)
eventsstring[]Enabled event types
status"active" | "paused"Delivery status
timeCreatedDateCreation timestamp
timeUpdatedDateLast modification

WebhookEvent

PropertyTypeDescription
type"payment.succeeded"Event name
payloadWebhookEventPayloadEvent data

WebhookEventPayload

PropertyTypeDescription
customerWebhookCustomerCustomer info
paymentWebhookPaymentPayment info

WebhookCustomer

PropertyTypeDescription
walletAddressstringCustomer wallet address (0x...)
emailstring | nullCustomer email
namestring | nullCustomer name
externalIDstring | nullExternal identifier

WebhookPayment

PropertyTypeDescription
status"succeeded" | "failed"Payment status
amountstringAmount in token's smallest unit
tokenAddressstring | nullToken contract address
txHashstringTransaction hash (0x...)
blockNumbernumberBlock number
productIDstring | nullPurchased product ID

Errors

A list of errors that can be returned by the Notifications API.


EndpointCreateErrors

The endpoint creation request was invalid.

Status: 400 BadRequestError


EndpointUpdateErrors

The endpoint update request was invalid or endpoint not found.

Status: 400 BadRequestError, 404 NotFoundError


EndpointRotateSecretErrors

The endpoint could not be found.

Status: 404 NotFoundError