Developers
Webhooks
Receive a signed JSON request in your own systems whenever a payment is coming up, goes overdue, or is marked paid, failed or skipped.
Overview
A webhook channel sends an HTTP POST with a JSON body to a URL you choose whenever one of your notification rules fires. Use it to bring renewals and payment changes into finance tools, ticketing, data warehouses, automation platforms or your own services.
- Five events: upcoming, overdue, paid, failed and skipped payments.
- One stable JSON body with raw values for machines, or a template you write.
- Signed with HMAC-SHA256 following the Standard Webhooks specification, so off-the-shelf libraries verify it.
- Retried on server errors, rate limiting and network failures, with every attempt in the delivery log.
Workspace admins and owners create channels and rules, send tests and rotate signing secrets. A webhook counts as one channel on your plan.
Quick start
Create the channel
In SysCost, open Notifications, then Channels, and choose + Channel. Pick Webhook, name it, and paste your endpoint’s URL (see the URL requirements). Custom headers and a payload template are optional. Choose Create.
Store the signing secret
SysCost shows the channel’s signing secret,
whsec_…, once. Put it in your secret manager: your endpoint uses it to verify every delivery. Afterwards the channel shows only its last four characters.Send a test
On the channel, choose a sample (Upcoming payment, Overdue payment, Marked paid, Marked failed or Skipped) and select Send test. The result appears at once and in the delivery log. Test deliveries carry
"is_test": true.Attach it to a rule
Open Rules and choose + Rule. Pick what it applies to (all subscriptions, one category or one subscription), the events, and for upcoming payments how many days before the due date. Under Send to, tick your webhook channel.
Events
The event field says what happened. A rule sends only the events it lists.
| Event | Shown in the app as | When it is sent |
|---|---|---|
upcoming_payment | Upcoming payment | A set number of days before a payment is due, once for each lead time on the rule (0 to 365 days; 0 is the due date itself). Only for payments still waiting to be paid. |
payment_overdue | Overdue payment | When a payment is past its due date and nobody has recorded it. One alert per subscription covers all its unpaid payments from the last 30 days, and repeats at the rule’s frequency. |
payment_paid | Marked paid | The moment someone marks a payment paid. |
payment_failed | Marked failed | The moment someone marks a payment failed. A payment that fails again after a retry is announced again. |
payment_skipped | Skipped | The moment someone marks a payment skipped. |
- Reminders (upcoming and overdue) go out from 9:00 in the workspace’s timezone. Dates in the payload are calendar dates in that timezone.
- Overdue alerts repeat at the rule’s frequency: every 12 hours, every day, every 3 days or once. Every day is the default; every 12 hours sends from 9:00 and again from 21:00. They stop when the payment is recorded, the subscription is paused, or the payment is more than 30 days late. A payment that newly becomes overdue is announced at once.
- Payment updates are sent as soon as the status changes. Recording the same status again sends nothing.
- Each notification is one delivery per channel, with its own
webhook-id. A repeated overdue alert and every payment update are new notifications.
Which rules apply
A rule applies to all subscriptions, one category or one subscription. For each subscription the most specific level that has an enabled rule wins: the subscription’s own rules, then its category’s, then the workspace-wide ones. All enabled rules at that level apply together.
Disabled rules and disabled channels send nothing, and SysCost doesn’t fall back to a broader rule when the winning level has no enabled channel. Test sends work on a disabled channel.
The request
Every delivery is a POST to your URL with these headers:
| Header | Value |
|---|---|
Content-Type | application/json, also when a template renders plain text. |
webhook-id | This delivery’s unique ID, such as msg_0b9c…. It stays the same on every retry of the delivery. Treat it as an opaque string. |
webhook-timestamp | When this attempt was signed, in Unix seconds. Every attempt gets a new one. |
webhook-signature | v1, followed by the base64 HMAC-SHA256 signature. For 24 hours after a secret rotation it holds two signatures, separated by a space. |
| Your custom headers | Exactly as configured on the channel. |
The body is the default JSON payload (UTF-8, compact) or, when the channel has one, your rendered template. SysCost waits up to 10 seconds for a response and does not follow redirects.
POST /hooks/syscost HTTP/1.1
Host: example.com
Content-Type: application/json
webhook-id: msg_0b9c4f7e-2d1a-4c3b-9e8f-7a6b5c4d3e2f
webhook-timestamp: 1794214800
webhook-signature: v1,L7mBZzIvEfsmA79rNC8uZ3y39hnkeOWZnJxH5L+hSDg=
{"event":"upcoming_payment","subscription_id":"8c0f6a2e-3b1d-4f5a-9e7c-2d4b6a8f1e03","subscription_name":"Figma Organization","amount":"540.00","currency":"USD","due_date":"2026-11-12","is_test":false,"title":"Figma Organization is due in 3 days","summary":null,"days_until_due":3,"billing_cycle":"monthly","category":"Design","provider":{"name":"Figma","domain":"figma.com","logo_url":"https://syscost.app/logos/tile/figma.png"},"workspace":"Acme Inc","url":"https://syscost.app/subscriptions/timeline/?id=8c0f6a2e-3b1d-4f5a-9e7c-2d4b6a8f1e03","overdue_payments":[],"payment":null,"next_payment":{"due_date":"2026-12-12","amount":"540.00","currency":"USD"}}The payload
Without a template, every delivery carries the same JSON object, whatever the event. Values are raw so machines can read them: amounts are strings with two decimals (read them as decimals, not floats), dates are YYYY-MM-DD calendar dates with no time or timezone, and events are stable codes. Amounts are never converted: each comes with its own currency.
| Field | Type | Nullable | Description |
|---|---|---|---|
| event | string | No | What happened: upcoming_payment, payment_overdue, payment_paid, payment_failed or payment_skipped. |
| subscription_id | string (UUID) | Yes | The subscription’s ID. null in test sends. |
| subscription_name | string | No | The subscription’s name in SysCost. |
| amount | string | No | The payment’s amount. A decimal string with exactly two decimals and no thousands separator, such as "1234.50". On payment updates, the amount recorded; on overdue alerts, the oldest unpaid payment. |
| currency | string | No | The ISO 4217 code of amount, such as USD. |
| due_date | string (date) | No | The payment’s due date as YYYY-MM-DD. On overdue alerts, the oldest unpaid payment’s due date. |
| is_test | boolean | No | true for test sends from the app, false for real notifications. |
| title | string | No | A one-line headline in English, such as “Figma Organization is due in 3 days”. For people: the wording can change, so don’t parse it. |
| summary | string | Yes | More sentences in English: who made a change, or when the next reminder comes. null when there is nothing to add. Test sends start with “This is a test from SysCost.” |
| days_until_due | integer | Yes | Whole days from the workspace’s current date to due_date: 0 on the due date, negative once it has passed. |
| billing_cycle | string | Yes | monthly, quarterly or yearly. |
| category | string | Yes | The name of the subscription’s category. |
| provider | object | Yes | The company the subscription is with, or null when none is set. |
| provider.name | string | No | The provider’s name, such as Figma. |
| provider.domain | string | Yes | The provider’s website domain, such as figma.com. |
| provider.logo_url | string (URL) | Yes | A 128 px PNG of the provider’s logo on a white tile. null for providers your team added. |
| workspace | string | Yes | The name of the workspace that sent the notification. |
| url | string (URL) | Yes | A link to the subscription in SysCost. Test sends link to the subscriptions list. |
| overdue_payments | array of objects | No | Every unpaid payment of the subscription that fell due in the last 30 days, oldest first. Empty when there are none. Present on every event, not only overdue alerts. |
| overdue_payments[].due_date | string (date) | No | When it was due, as YYYY-MM-DD. |
| overdue_payments[].amount | string | No | A decimal string with exactly two decimals and no thousands separator, such as "1234.50". |
| overdue_payments[].currency | string | No | ISO 4217 currency code. |
| overdue_payments[].days_late | integer | Yes | Whole days since it was due. |
| payment | object | Yes | What was recorded, on payment updates (payment_paid, payment_failed, payment_skipped). null on reminders. |
| payment.paid_on_date | string (date) | Yes | The day it was paid. null unless the payment is paid. |
| payment.amount | string | No | The amount recorded. A decimal string with exactly two decimals and no thousands separator, such as "1234.50". |
| payment.currency | string | No | ISO 4217 currency code. |
| payment.changed_by | string | Yes | The email address of the teammate who made the change; in test sends, whoever sent the test. null when no person made it. |
| next_payment | object | Yes | The next payment after this one, when one is scheduled. |
| next_payment.due_date | string (date) | No | When it is due, as YYYY-MM-DD. |
| next_payment.amount | string | No | A decimal string with exactly two decimals and no thousands separator, such as "1234.50". |
| next_payment.currency | string | No | ISO 4217 currency code. |
The first seven fields (event, subscription_id, subscription_name, amount, currency, due_date, is_test) are the original contract and never change. Fields appear in the order above, but read them by name. title and summary are written for people and their wording can change.
Example payloads
One complete body per event, pretty-printed for reading. Deliveries are sent compact, as in the example request.
upcoming_payment
A reminder three days before a monthly payment. next_payment is the one after it.
{
"event": "upcoming_payment",
"subscription_id": "8c0f6a2e-3b1d-4f5a-9e7c-2d4b6a8f1e03",
"subscription_name": "Figma Organization",
"amount": "540.00",
"currency": "USD",
"due_date": "2026-11-12",
"is_test": false,
"title": "Figma Organization is due in 3 days",
"summary": null,
"days_until_due": 3,
"billing_cycle": "monthly",
"category": "Design",
"provider": {
"name": "Figma",
"domain": "figma.com",
"logo_url": "https://syscost.app/logos/tile/figma.png"
},
"workspace": "Acme Inc",
"url": "https://syscost.app/subscriptions/timeline/?id=8c0f6a2e-3b1d-4f5a-9e7c-2d4b6a8f1e03",
"overdue_payments": [],
"payment": null,
"next_payment": {
"due_date": "2026-12-12",
"amount": "540.00",
"currency": "USD"
}
}payment_overdue
An overdue alert on a rule that repeats every day. due_date and amount describe the oldest unpaid payment; overdue_payments lists every one.
{
"event": "payment_overdue",
"subscription_id": "3e9b1c47-5a2d-4e8f-b6c1-9d0a7f2e4b58",
"subscription_name": "Vercel Pro",
"amount": "20.00",
"currency": "USD",
"due_date": "2026-10-28",
"is_test": false,
"title": "Vercel Pro is 12 days overdue",
"summary": "Not marked paid yet. SysCost will remind you again tomorrow.",
"days_until_due": -12,
"billing_cycle": "monthly",
"category": "Infrastructure",
"provider": {
"name": "Vercel",
"domain": "vercel.com",
"logo_url": "https://syscost.app/logos/tile/vercel.png"
},
"workspace": "Acme Inc",
"url": "https://syscost.app/subscriptions/timeline/?id=3e9b1c47-5a2d-4e8f-b6c1-9d0a7f2e4b58",
"overdue_payments": [
{
"due_date": "2026-10-28",
"amount": "20.00",
"currency": "USD",
"days_late": 12
}
],
"payment": null,
"next_payment": {
"due_date": "2026-11-28",
"amount": "20.00",
"currency": "USD"
}
}payment_paid
Recorded two days after the due date. payment holds what was recorded and who recorded it.
{
"event": "payment_paid",
"subscription_id": "b7d2e9f0-1c3a-4b5d-8e6f-0a9c2d4e6f81",
"subscription_name": "GitHub Enterprise",
"amount": "2100.00",
"currency": "USD",
"due_date": "2026-11-07",
"is_test": false,
"title": "GitHub Enterprise was paid",
"summary": "Marked paid by [email protected].",
"days_until_due": -2,
"billing_cycle": "monthly",
"category": "Engineering",
"provider": {
"name": "GitHub",
"domain": "github.com",
"logo_url": "https://syscost.app/logos/tile/github.png"
},
"workspace": "Acme Inc",
"url": "https://syscost.app/subscriptions/timeline/?id=b7d2e9f0-1c3a-4b5d-8e6f-0a9c2d4e6f81",
"overdue_payments": [],
"payment": {
"paid_on_date": "2026-11-09",
"amount": "2100.00",
"currency": "USD",
"changed_by": "[email protected]"
},
"next_payment": {
"due_date": "2026-12-07",
"amount": "2100.00",
"currency": "USD"
}
}payment_failed
A yearly payment marked failed. paid_on_date stays null.
{
"event": "payment_failed",
"subscription_id": "4a6c8e0f-2b4d-4f6a-9c8e-1d3f5a7b9c02",
"subscription_name": "Slack Business+",
"amount": "4500.00",
"currency": "USD",
"due_date": "2026-11-08",
"is_test": false,
"title": "Slack Business+ payment failed",
"summary": "Marked failed by [email protected]. Update the card or retry the charge, then mark it paid.",
"days_until_due": -1,
"billing_cycle": "yearly",
"category": "Communication",
"provider": {
"name": "Slack",
"domain": "slack.com",
"logo_url": "https://syscost.app/logos/tile/slack.png"
},
"workspace": "Acme Inc",
"url": "https://syscost.app/subscriptions/timeline/?id=4a6c8e0f-2b4d-4f6a-9c8e-1d3f5a7b9c02",
"overdue_payments": [],
"payment": {
"paid_on_date": null,
"amount": "4500.00",
"currency": "USD",
"changed_by": "[email protected]"
},
"next_payment": {
"due_date": "2027-11-08",
"amount": "4500.00",
"currency": "USD"
}
}payment_skipped
A payment skipped on its due date, in euros.
{
"event": "payment_skipped",
"subscription_id": "e1f3a5b7-9c0d-4e2f-8a4b-6c8d0e2f4a63",
"subscription_name": "Notion Business",
"amount": "180.00",
"currency": "EUR",
"due_date": "2026-11-09",
"is_test": false,
"title": "Notion Business payment skipped",
"summary": "Marked skipped by [email protected]. Nothing is owed for this one.",
"days_until_due": 0,
"billing_cycle": "monthly",
"category": "Productivity",
"provider": {
"name": "Notion",
"domain": "notion.com",
"logo_url": "https://syscost.app/logos/tile/notion.png"
},
"workspace": "Acme Inc",
"url": "https://syscost.app/subscriptions/timeline/?id=e1f3a5b7-9c0d-4e2f-8a4b-6c8d0e2f4a63",
"overdue_payments": [],
"payment": {
"paid_on_date": null,
"amount": "180.00",
"currency": "EUR",
"changed_by": "[email protected]"
},
"next_payment": {
"due_date": "2026-12-09",
"amount": "180.00",
"currency": "EUR"
}
}Test sends
Send test delivers a fixed sample for the event you pick, signed like any other delivery but sent once, with no retries. Its is_test is true, subscription_id is null, summary starts with “This is a test from SysCost.”, url points to the subscriptions list, and its webhook-id starts with msg_test_. Check is_test so tests never reach your production data.
{
"event": "upcoming_payment",
"subscription_id": null,
"subscription_name": "Figma Organization",
"amount": "540.00",
"currency": "USD",
"due_date": "2026-11-12",
"is_test": true,
"title": "Figma Organization is due in 3 days",
"summary": "This is a test from SysCost. Real notifications look like this.",
"days_until_due": 3,
"billing_cycle": "monthly",
"category": "Design",
"provider": {
"name": "Figma",
"domain": "figma.com",
"logo_url": "https://syscost.app/logos/tile/figma.png"
},
"workspace": "Acme Inc",
"url": "https://syscost.app/subscriptions/",
"overdue_payments": [],
"payment": null,
"next_payment": null
}Payload templates
Leave the template empty to receive the default JSON payload. Set one when the receiving tool expects its own format, such as a chat app’s incoming webhook. The rendered text becomes the whole body.
- Write placeholders as
{{token}}. Spaces inside the braces are allowed:{{ title }}. - A value that is missing (such as
changed_byon a reminder) becomes empty text. An unknown token is left exactly as written. - When the template’s first non-blank character is
{or[, SysCost treats it as JSON and escapes every value for use inside a JSON string (quotes, backslashes, line breaks). It doesn’t add quotes: put text tokens inside quotes yourself. A plain-text template that begins with a token also starts with{, so begin plain text with a word, as in the last example below. - The body is sent exactly as rendered, signed like any other delivery, with
Content-Type: application/json. - Tokens are flat values. Lists and objects (
overdue_payments,payment,next_payment, and the provider’s domain and logo) exist only in the default payload.
| Token | Value |
|---|---|
{{event}} | event |
{{subscription_id}} | subscription_id (empty in test sends) |
{{subscription_name}} | subscription_name |
{{amount}} | amount, such as 540.00 |
{{currency}} | currency |
{{due_date}} | due_date |
{{is_test}} | true or false |
{{title}} | title |
{{summary}} | summary (empty when there is none) |
{{days_until_due}} | days_until_due |
{{billing_cycle}} | billing_cycle |
{{category_name}} | category |
{{provider_name}} | provider.name |
{{workspace_name}} | workspace |
{{url}} | url |
{{changed_by}} | payment.changed_by (empty on reminders) |
A chat tool that takes a text field
{"text": "{{title}}: {{amount}} {{currency}} on {{due_date}}. {{url}}"}{"text": "Figma Organization is due in 3 days: 540.00 USD on 2026-11-12. https://syscost.app/subscriptions/timeline/?id=8c0f6a2e-3b1d-4f5a-9e7c-2d4b6a8f1e03"}Your own JSON shape
{
"type": "{{event}}",
"vendor": "{{provider_name}}",
"amount": "{{amount}}",
"currency": "{{currency}}",
"due": "{{due_date}}",
"test": {{is_test}}
}{
"type": "upcoming_payment",
"vendor": "Figma",
"amount": "540.00",
"currency": "USD",
"due": "2026-11-12",
"test": false
}Plain text
SysCost: {{title}} ({{amount}} {{currency}})SysCost: Figma Organization is due in 3 days (540.00 USD)Verifying a plain-text body
The Standard Webhooks libraries parse the body as JSON after checking the signature. For a template that doesn’t render JSON, pass { jsonParse: false } to verify in JavaScript or json_parse=False in Python.
Custom headers
Add the headers your endpoint needs, such as an API key or Authorization: Bearer …. They go with every delivery and every test.
- Header values are stored as secrets: hidden once you save. When you edit the channel, leave a value blank to keep it.
HostandContent-Lengthcan’t be set. Names and values can’t contain line breaks.- SysCost sets
Content-Type,webhook-id,webhook-timestampandwebhook-signatureon every delivery, so those names can’t be used for custom headers, in any letter case. - Headers are not covered by the signature, which signs the ID, the timestamp and the body. Verify the signature in any case; a shared header token is an extra layer, not a replacement.
Verifying signatures
Every delivery is signed with the channel’s secret, following the Standard Webhooks specification. Verify each request before you trust it: anyone who learns your URL can send it data.
Build the signed content
Join the
webhook-idheader, thewebhook-timestampheader and the raw request body with dots:{webhook-id}.{webhook-timestamp}.{raw request body}.Compute the signature
Take the part of your secret after
whsec_and base64-decode it: those bytes are the key. Compute HMAC-SHA256 of the signed content and base64-encode the result.Compare
webhook-signatureholds one or more space-separated entries likev1,<signature>. Compare yours with eachv1entry in constant time. One match is enough.Check the timestamp
Reject the request if
webhook-timestampis more than 5 minutes away from your clock. See replays and duplicates.
Use the raw body
The signature covers the exact bytes SysCost sent. Parsing the JSON and serializing it again changes them. Read the raw body: express.raw() in Express, request.get_data() in Flask.
Node.js
With the built-in crypto module and Express. timingSafeEqual compares in constant time.
npm install expressimport { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';
const SECRET = process.env.SYSCOST_WEBHOOK_SECRET; // whsec_...
const TOLERANCE_SECONDS = 5 * 60;
export function verifySysCostWebhook(rawBody, headers, secret) {
const id = headers['webhook-id'];
const timestamp = headers['webhook-timestamp'];
const signatures = headers['webhook-signature'];
if (!id || !timestamp || !signatures) throw new Error('Missing webhook headers');
// Replay protection: refuse deliveries signed more than 5 minutes away from now.
const sentAt = Number(timestamp);
if (!Number.isInteger(sentAt) || Math.abs(Date.now() / 1000 - sentAt) > TOLERANCE_SECONDS) {
throw new Error('Timestamp outside the tolerance window');
}
// HMAC-SHA256 of "id.timestamp.body", keyed with the base64-decoded secret.
const key = Buffer.from(secret.slice('whsec_'.length), 'base64');
const expected = createHmac('sha256', key).update(`${id}.${timestamp}.`).update(rawBody).digest();
// The header can hold several space-separated signatures (during a rotation).
const isValid = signatures.split(' ').some((entry) => {
const [version, signature] = entry.split(',');
if (version !== 'v1' || !signature) return false;
const received = Buffer.from(signature, 'base64');
return received.length === expected.length && timingSafeEqual(received, expected);
});
if (!isValid) throw new Error('No valid signature');
}
const app = express();
// express.raw keeps the exact bytes: the signature covers the raw body.
app.post('/hooks/syscost', express.raw({ type: 'application/json' }), (req, res) => {
try {
verifySysCostWebhook(req.body, req.headers, SECRET);
} catch {
return res.status(400).send('Invalid signature');
}
const event = JSON.parse(req.body.toString('utf8'));
res.sendStatus(204); // Acknowledge first...
void handleEvent(event); // ...then do the work.
});
async function handleEvent(event) {
// Your logic here. In production, put the event on a durable queue first.
console.log(`${event.event}: ${event.title}`);
}
app.listen(3000);
Python
With the standard library’s hmac module and Flask. hmac.compare_digest compares in constant time. Python 3.9 or later.
pip install flaskimport base64
import hashlib
import hmac
import json
import os
import time
from flask import Flask, request
SECRET = os.environ["SYSCOST_WEBHOOK_SECRET"] # whsec_...
TOLERANCE_SECONDS = 5 * 60
app = Flask(__name__)
class InvalidWebhook(Exception):
pass
def verify_syscost_webhook(body: bytes, headers, secret: str) -> None:
msg_id = headers.get("webhook-id")
timestamp = headers.get("webhook-timestamp")
signatures = headers.get("webhook-signature")
if not (msg_id and timestamp and signatures):
raise InvalidWebhook("missing webhook headers")
# Replay protection: refuse deliveries signed more than 5 minutes away from now.
try:
sent_at = int(timestamp)
except ValueError:
raise InvalidWebhook("invalid timestamp")
if abs(time.time() - sent_at) > TOLERANCE_SECONDS:
raise InvalidWebhook("timestamp outside the tolerance window")
# HMAC-SHA256 of "id.timestamp.body", keyed with the base64-decoded secret.
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{timestamp}.".encode() + body
expected = hmac.new(key, signed, hashlib.sha256).digest()
# The header can hold several space-separated signatures (during a rotation).
for entry in signatures.split(" "):
version, _, signature = entry.partition(",")
if version != "v1":
continue
try:
received = base64.b64decode(signature, validate=True)
except ValueError:
continue
if hmac.compare_digest(received, expected):
return
raise InvalidWebhook("no valid signature")
@app.post("/hooks/syscost")
def syscost_webhook():
body = request.get_data() # the raw bytes: the signature covers them
try:
verify_syscost_webhook(body, request.headers, SECRET)
except InvalidWebhook:
return "invalid signature", 400
event = json.loads(body)
handle_event(event) # keep this fast: hand slow work to a queue
return "", 204
def handle_event(event: dict) -> None:
print(f"{event['event']}: {event['title']}")
if __name__ == "__main__":
app.run(port=3000)
Standard Webhooks libraries
The official libraries do all four steps, timestamp check included, and accept the secret with its whsec_ prefix. Libraries for other languages are listed in the Standard Webhooks repository.
npm install express standardwebhooksimport express from 'express';
import { Webhook } from 'standardwebhooks';
// The library accepts the secret with its whsec_ prefix.
const webhook = new Webhook(process.env.SYSCOST_WEBHOOK_SECRET);
const app = express();
app.post('/hooks/syscost', express.raw({ type: 'application/json' }), (req, res) => {
let event;
try {
// Checks the signature and refuses timestamps more than 5 minutes off.
event = webhook.verify(req.body, req.headers);
} catch {
return res.status(400).send('Invalid signature');
}
res.sendStatus(204);
console.log(`${event.event}: ${event.title}`);
});
app.listen(3000);
pip install flask standardwebhooksimport os
from flask import Flask, request
from standardwebhooks import Webhook, WebhookVerificationError
# The library accepts the secret with its whsec_ prefix.
webhook = Webhook(os.environ["SYSCOST_WEBHOOK_SECRET"])
app = Flask(__name__)
@app.post("/hooks/syscost")
def syscost_webhook():
try:
# Checks the signature and refuses timestamps more than 5 minutes off.
event = webhook.verify(request.get_data(), dict(request.headers))
except (WebhookVerificationError, ValueError): # ValueError: a malformed header
return "invalid signature", 400
print(f"{event['event']}: {event['title']}")
return "", 204
if __name__ == "__main__":
app.run(port=3000)
Test your implementation
The example request is signed with the demo secret below. Your code should accept it and produce the same signature. Its timestamp is fixed, so skip the timestamp check while you test.
| Input | Value |
|---|---|
| Secret | whsec_c3lzY29zdC1kb2NzLWV4YW1wbGUtc2VjcmV0LTAwMDE= |
webhook-id | msg_0b9c4f7e-2d1a-4c3b-9e8f-7a6b5c4d3e2f |
webhook-timestamp | 1794214800 |
| Body | The last line of the example request, exactly as shown. |
webhook-signature | v1,L7mBZzIvEfsmA79rNC8uZ3y39hnkeOWZnJxH5L+hSDg= |
Replays and duplicates
A valid signature proves SysCost sent the body. It doesn’t prove this is the first time you see it. Guard against both replays and retries:
- Reject old timestamps. Refuse deliveries whose
webhook-timestampis more than 5 minutes from your clock, and keep your clock synchronised. SysCost signs every attempt as it sends it, so retries arrive with a fresh timestamp. - Deduplicate on
webhook-id. A retry carries the same ID as the first attempt. Record each ID you accept and skip ones you have already handled; keep them for at least a day. - Never deduplicate on the body. Each attempt is built from the subscription as it is at that moment, so a retry can carry newer details, such as a renamed subscription.
- Group by payment, not by delivery. To relate notifications about the same payment, use
subscription_idanddue_date.
-- PostgreSQL: one row per delivery you have accepted.
CREATE TABLE syscost_webhook_deliveries (
webhook_id text PRIMARY KEY,
received_at timestamptz NOT NULL DEFAULT now()
);
-- Run in the same transaction as your own changes. If it inserts no row,
-- you have already handled this delivery: respond 2xx and stop.
INSERT INTO syscost_webhook_deliveries (webhook_id)
VALUES ($1)
ON CONFLICT (webhook_id) DO NOTHING;
Rotating the secret
Rotate the secret if it may have leaked, when someone with access leaves, or on a schedule. Admins and owners choose Rotate secret on the channel.
Rotate in SysCost
The new secret is shown once. Copy it.
Both secrets sign for 24 hours
Every delivery carries two signatures, the new one first. A receiver that still has the old secret keeps working.
Signature header during a rotation webhook-signature: v1,<signature with the new secret> v1,<signature with the previous secret>Update your receiver
Switch your endpoint to the new secret within 24 hours. After that, only the new secret signs.
The channel shows the current secret’s last four characters (whsec_…abcd) and, during the overlap, when the previous secret stops signing. Rotating again within those 24 hours retires the oldest secret at once: only the current secret and the one before it sign.
Responding
Respond with any 2xx status within 10 seconds. SysCost ignores the response body. Acknowledge first and work later: store the event or put it on a queue, respond, then process it. Slow work inside the request risks the timeout, and a timeout means a retry.
| Your response | What SysCost does |
|---|---|
2xx | Delivered. The delivery is marked sent. |
3xx | Failed, not retried. Redirects are not followed: use the final URL. |
429 | Retried. |
Any other 4xx | Failed, not retried. Use it for requests you reject for good, such as a bad signature. |
5xx | Retried. |
| No response within 10 seconds | Retried. |
| Connection refused or host not found | Retried. |
Asking for a retry
If you can’t take a delivery right now, answer 503 (or another 5xx, or 429). Any other 4xx stops the retries. SysCost doesn’t read Retry-After: a 429 is retried on the usual schedule.
Retries and the delivery log
A delivery gets up to 4 attempts: the first, then 3 retries with exponential backoff.
| Attempt | When |
|---|---|
| 1 | When the notification goes out. |
| 2 | About 2 seconds after attempt 1 fails. |
| 3 | About 4 seconds after attempt 2 fails. |
| 4 | About 8 seconds after attempt 3 fails. |
- Each attempt can wait up to 10 seconds for your response, so all four are over within about a minute. If the last one fails, the delivery is marked failed and is not sent again. Plan for that: an endpoint that is down for longer misses those notifications.
- Every retry keeps the
webhook-idand gets a new timestamp and signature. - Each workspace sends at most 300 notifications an hour, across all its channels. Past that, deliveries wait for the next hour: nothing is dropped and no attempt is used up. Test sends don’t count.
- Test sends go out once, straight away, with no retries.
Notifications → Delivery log lists recent deliveries: its event, channel, status (queued, retrying, sent or failed) and each attempt with its time and error. Errors give the status code your endpoint returned, such as “Destination responded with status 503.”, or the kind of network problem. Your response body isn’t shown.
URL requirements
- The URL starts with
https://orhttp://. Use HTTPS: the payload is business data. - It resolves to a public internet address.
- It uses port 443 for HTTPS or port 80 for HTTP, the default ports. A URL with another port, such as
:8443, isn’t delivered to. - It answers the
POSTitself, without redirecting.
SysCost checks these rules each time it delivers. A delivery to a URL that breaks them fails at once, without retries, so send a test after you save. The URL is stored as a secret and hidden once saved, so a token in its query string stays private; to change it, type the new one when you edit the channel.
Best practices
- Verify every signature, on the raw body, and reject timestamps more than 5 minutes off.
- Deduplicate on
webhook-id. - Respond
2xxquickly and do the work asynchronously. - Answer
5xxor429for temporary problems, and other4xxonly for requests you reject for good. - Read fields by name, and ignore fields you don’t know.
- Check
is_testso test deliveries stay out of your production data. - Read amounts as decimals, and never add up amounts in different currencies.
- Keep the signing secret in a secret manager, and rotate it when someone with access leaves.
- Use HTTPS.
- Watch the delivery log: a delivery that fails four times is not sent again.
Versioning
The notification payload has one version, and it changes only by adding:
- The first seven fields,
event,subscription_id,subscription_name,amount,currency,due_date,is_test, are the original contract. Their names, types and meanings never change. - New fields may be added at any time, at the top level or inside objects. Ignore fields you don’t know.
titleandsummaryare prose for people. Their wording can change; don’t parse them.- New events may be added. A rule sends only the events it lists, so a new event never reaches you until someone adds it to a rule. Handle unknown
eventvalues gracefully anyway.
| Change | What it added |
|---|---|
| Original contract | The seven fields above, for upcoming, overdue, paid and failed payments. |
| Signing | The webhook-id, webhook-timestamp and webhook-signature headers, and secret rotation. |
| Richer notifications | title, summary, days_until_due, billing_cycle, category, provider, workspace, url, overdue_payments, payment and next_payment; the payment_skipped event; the matching template tokens. |