Webhooks
Get card and bank transactions pushed to your server, for finance agents and month-end close: create a webhook, handle retries and verify signatures.
Introduction
Astrada uses webhooks to automatically notify your application when relevant events occur in your account. Webhooks can be used as an alternative or complement to direct API requests, in situations where you would prefer to programmatically receive information pushed to you in real-time.
In order to receive webhooks, you must select the webhook event types (Event Types) for which you want to receive webhook events, create the webhook and register webhook endpoints where you desire webhooks to be sent.
Creating webhooks
Once you have decided on the appropriate webhook event types for your use case, you can create webhooks using our Create Webhook endpoint. Each webhook requires an HTTPS URL to be registered.
Register the webhook before you enroll cards or link banks on a subaccount: events from before the subaccount's first webhook are not delivered later.
Limitations
There is no limit to the total number of webhook subscriptions across an account.
Addition of new fields
The addition of new fields to the webhook payload is not considered a breaking change. Therefore, we do not recommend that consumers perform strict validation on the payload (i.e., disallowing unknown fields).
Management and behavior
Astrada will notify your registered webhook URLs as the event happens via an HTTP POST request.
The HTTP request payload contains the event object in JSON format. The HTTP headers contain information such as:
- the event type under the header
webhook-event-type(the body carries the same value aseventType) - the
subaccountIdthe event relates to underwebhook-subaccount-id
At present, we only support API-based webhook management.
To confirm receipt of a webhook event, your server endpoint answers with any 2xx status. Answer each delivery promptly: check its signature, record it, answer 2xx, and do the work after answering. A delivery that is correctly signed but whose body does not fit its event type is kept, then answered 2xx, because a retry would send the same bytes. Answer 400 only for a bad signature or a stale timestamp. Any other answer, or none, is a failure, and Astrada sends the event again on the schedule below:
| Attempt | Delay | Cumulative Time |
|---|---|---|
| 1 | NA (initial attempt) | -- |
| 2 | 5s | 5s |
| 3 | 5m | 5m 5s |
| 4 | 30m | 35m 5s |
| 5 | 2h | 2h 35m 5s |
| 6 | 5h | 7h 35m 5s |
| 7 | 10h | 17h 35m 5s |
| 8 | 10h | 27h 35m 5s |
After the last attempt the event is dropped: it is not sent again and cannot be replayed. Read what you missed from the API, for example GET /transactions, or GET /bank-links/{bankLinkId} for bank events.
Semantics
Webhook event delivery follows at-least-once semantics. This means that our system does not guarantee each event will be delivered exactly once, and subscribers should build with that assumption in mind.
Security and Verification
Each webhook call includes three headers with additional information that are used for verification:
webhook-id: the unique message identifier for the webhook message. This identifier is unique across all messages but will be the same when the same webhook is being resent.webhook-timestamp: timestamp in seconds since epoch.webhook-signature: the Base64 encoded signature composed by concatenating the webhook-id, webhook-timestamp, and body, separated by the full-stop character (.).
The body is the raw content of the request. The signature is sensitive to any changes, so do not change the body in any way before verifying, as it will cause the signature to be completely different.
The body also carries the event type as a top-level eventType field, for example "eventType": "transaction.created". The signature covers webhook-id, webhook-timestamp and the body, but not the webhook-event-type header. So after verifying the signature, check that eventType matches the header. If it does not, do not process the delivery. Keep it for inspection and replay (the raw body, the headers and the reason you refused it), then answer 2xx. A mismatch does not go away on a retry, and any other status only makes us send the same delivery again, as in the table above. After a 2xx we never send that delivery again, so the copy you kept is the only one: if the mismatch turns out to be your own check's mistake (for example after an API change), replay it from that copy.
Signature Verification
With a backend SDK, one call checks the signature and the five-minute timestamp window: see Backend SDKs: Verify a webhook. Without one, compute it as below, compare in constant time, and refuse a webhook-timestamp more than five minutes from now.
Astrada uses an HMAC with SHA-256 to sign its webhooks.
The signing secret is only obtained at the creation of the webhook and must be secured as it won’t be visible afterward. For any reason, if you lose access to the secret, we recommend creating a new webhook and deleting the previous one.
To verify the authenticity of the request you should calculate the expected signature and compare it to the one received on the webhook-signature header. For this, you should HMAC the ${webhook-id}.${webhook-timestamp}.${body} using your base64 decoded signing secret.
For example, this is how you can calculate the signature in Node.js
const crypto = require('crypto');
const body = '{"id":"random-id","other":"test"}';
const headers = {
'webhook-id': 'msg_2edtk77s2IbiV6pH2K8KeV2BBza',
'webhook-timestamp': '1712246422',
'webhook-signature': 'v1,qDejq/phQBZBCaw+5Oy/THT0/Xaj8l88JEqPnIqM/aE=',
};
const secret = 'N2ViZDU2ZWMtMGMxYi00NDc5LTgyMTAtZTdjZWUzNmRlZTNh';
const decodedSecret = Buffer.from(secret, 'base64'); // the key's bytes, not a string
const signature = crypto
.createHmac('sha256', decodedSecret)
.update(`${headers['webhook-id']}.${headers['webhook-timestamp']}.${body}`)
.digest('base64');
console.log(signature)
// qDejq/phQBZBCaw+5Oy/THT0/Xaj8l88JEqPnIqM/aE=This generated signature should match the one sent in the webhook-signature header.
Make sure to remove the prefix and delimiter (e.g. v1,) before verifying the signature.
Signature Verification Flow
- Your serviceAstradaCalls create webhook.
- AstradaCreates the webhook with a generated secret.
- AstradaYour serviceReturns the webhook with its secret.
- AstradaYour serviceDispatches a signed webhook message.
- Your serviceValidates the signature with the returned secret.
Source IPs
In case your webhook receiving endpoint is behind a firewall or NAT, you may need to allow traffic from Astrada's IP addresses.
This is the full list of IP addresses that webhooks may originate from grouped by the region of the sender.
| Region | IP Address |
|---|---|
| EU | 52.215.16.239 |
| EU | 54.216.8.72 |
| EU | 63.33.109.123 |
Updated about 17 hours ago
