Webhooks
Pymstr sends webhook notifications to your server when payment and payout events occur.
Setup
- Go to Dashboard > Integration > Webhooks
- Enter your endpoint URL.
- Save your webhook secret. It starts with
whsec_and is shown only once.
To replace the secret, use Regenerate signing secret on the same page. Deliveries are signed with the new secret at once, so update your server in the same step. A delivery your server rejects before it has the new secret is retried on the retry schedule.
Event Types
| Event | Description |
|---|---|
payment.* | Payment link events, listed on Payments |
payout.* | Payout events, listed on Payouts |
test | Test event (sent from the dashboard) |
Dashboard-created links only
payment.created and payout.created fire only for links created from the dashboard. Resources you create via the
API (pk_ key) do not emit a .created event, because you already have the resource from the 201 Created response.
A failed payment can be credited later
In very rare cases, you get both payment.failed and payment.completed for the same paymentId, in either
order. Treat completed as final. The same applies to payout.failed and payout.completed. See
Late Credit.
Payload Format
All webhook payloads follow this structure:
{
"event": "payment.completed",
"timestamp": "2026-02-24T10:05:00.000Z",
"data": {
"paymentId": "01234567-89ab-cdef-0123-456789abcdef",
"externalId": "order-123"
}
}Parameter
Type
For payout.* events, data.payoutId replaces data.paymentId (and data.externalId is the payout's reference):
{
"event": "payout.completed",
"timestamp": "2026-02-24T10:05:00.000Z",
"data": {
"payoutId": "01234567-89ab-cdef-0123-456789abcdef",
"externalId": "batch-2026-10"
}
}Signature Verification
Every webhook includes these headers:
| Header | Description |
|---|---|
X-Pymstr-Timestamp | Unix timestamp (seconds), the same value as t in X-Pymstr-Signature |
X-Pymstr-Signature | Format: t=<timestamp>,v1=<signature> |
Content-Type | application/json |
Verification steps
- Extract
t(timestamp) andv1(signature) from theX-Pymstr-Signatureheader - Reject if the timestamp is more than 5 minutes from your server's time, earlier or later (replay protection)
- Compute HMAC-SHA256 of
{timestamp}.{raw_body}using your webhook secret as the key, the whole string with itswhsec_prefix - Compare your computed signature with
v1using constant-time comparison
import express from 'express'
import { createHmac, timingSafeEqual } from 'crypto'
const app = express()
function verifyWebhook(body, signatureHeader, secret, tolerance = 300) {
// Parse signature header
const parts = signatureHeader.split(',')
const timestamp = parts.find(p => p.startsWith('t='))?.slice(2)
const signature = parts.find(p => p.startsWith('v1='))?.slice(3)
if (!timestamp || !signature) {
throw new Error('Invalid signature format')
}
// Reject a timestamp more than 5 minutes from now, earlier or later
const now = Math.floor(Date.now() / 1000)
if (Math.abs(now - parseInt(timestamp)) > tolerance) {
throw new Error('Timestamp outside tolerance')
}
// Compute expected signature
const signedPayload = `${timestamp}.${body}`
const hmac = createHmac('sha256', secret)
hmac.update(signedPayload)
const expected = hmac.digest('hex')
// Constant-time comparison
const sigBuffer = Buffer.from(signature, 'hex')
const expectedBuffer = Buffer.from(expected, 'hex')
if (sigBuffer.length !== expectedBuffer.length) {
return false
}
return timingSafeEqual(sigBuffer, expectedBuffer)
}
// Express example
app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
const signature = req.headers['x-pymstr-signature'] ?? ''
const body = req.body.toString()
try {
if (!verifyWebhook(body, signature, process.env.PYMSTR_WEBHOOK_SECRET)) {
return res.status(401).send('Invalid signature')
}
} catch {
return res.status(401).send('Invalid signature')
}
try {
const { event, data } = JSON.parse(body)
if (event === 'payment.completed') {
// Events can arrive out of order: fetch the current state before acting
const response = await fetch(`https://api.pymstr.com/v1/payments/${data.paymentId}`, {
headers: { 'Authorization': `Bearer ${process.env.PYMSTR_API_KEY}` },
})
if (!response.ok) throw new Error(`Get Payment answered ${response.status}`)
const payment = await response.json()
if (payment.status === 'SUCCESSFUL') {
// Mark the order for payment.externalId as paid. The same event can arrive twice.
}
}
} catch {
// Any answer other than 2xx makes Pymstr send the event again
return res.status(500).send('Try again')
}
// Answer 2xx only after the work is done
res.status(200).send('OK')
})Source IP Addresses
Webhooks are sent from these addresses: 34.27.107.78, 136.119.23.57. If your endpoint sits behind a firewall or an
IP allowlist, allow every one of them. An address check does not replace signature verification.
Retry Schedule
Failed deliveries are retried with exponential backoff:
| Attempt | Delay | Cumulative |
|---|---|---|
1 | Immediate | 0 |
2 | 1 minute | 1 minute |
3 | 5 minutes | 6 minutes |
4 | 30 minutes | 36 minutes |
5 | 2 hours | 2h 36m |
6 | 8 hours | 10h 36m |
7 | 24 hours | 34h 36m |
After 7 attempts, the delivery is marked as failed. Total retry window: ~34.5 hours.
A delivery is considered successful on any HTTP 2xx response. All other responses (4xx, 5xx, timeouts, connection errors) trigger a retry. Each attempt carries a new timestamp and signature.
Test Webhook
To verify your endpoint, use Dashboard > Integration > Webhooks > Send test event. Pymstr sends a test event to
your saved webhook URL and shows whether your endpoint answered with a 2xx. The test event has no data field:
{
"event": "test",
"timestamp": "2026-02-24T10:05:00.000Z"
}Best Practices
- Answer after the work is done. Return a
2xxonly once you have handled or stored the event, because a failure after a2xxis never retried. The request times out after 10 seconds, so store the event and finish longer work from your own queue. - Verify signatures. Always validate
X-Pymstr-Signatureand check the timestamp is within 5 minutes. - Be idempotent. Use
paymentId(orpayoutId) +eventas a deduplication key. While Pymstr deduplicates on its end, network issues can cause duplicate deliveries. - Fetch current state. Events may arrive out of order. Always call
GET /v1/payments/:id(orGET /v1/payouts/:id) to get the authoritative status before acting on an event. Mark an order paid only whenstatusisSUCCESSFUL. - Use HTTPS. Pymstr only delivers to an
https://URL.