Cookbook
Working TypeScript, Python and Java code for common Astrada tasks, copied from example files that the backend SDKs test on every change.
For: developers
Each recipe in this cookbook is one task you build into your backend, with the code for it in TypeScript, Python and Java. The code on each page is copied from an example file in that SDK's repository, and each example file has tests that run with the SDK's own tests, so the code you read is code that runs.
Recipes
The numbers match the example file names in the SDK repositories (01-receive-webhooks.ts, Recipe01ReceiveWebhooks.java and so on), and the comments in the code refer to other recipes by these numbers.
| Recipe | What it does |
|---|---|
| 1. Receive webhooks | An endpoint that checks each delivery came from Astrada, skips repeats, answers straight away and does the work after |
| 2. One webhook per subaccount | Registers a webhook for a new subaccount and saves its secret, safe to run again |
| 3. One subaccount per customer | Finds your customer's subaccount, or makes it the first time, and never makes two |
| 4. A token for the browser enrollment SDK | The backend route that gives SDK v2 a token for one signed-in user |
| 5. Cards and their state | Lists a subaccount's cards with the state of each card's current subscription |
| 6. Transactions and their messages | Pages through a subaccount's transactions and reads each one's messages in order |
| 14. Submit a bulk feed and follow it | Submits a network bulk feed, hears when its state changes and reads its results |
| 15. Spend by subaccount and by card | Totals spend over a date range, per currency, with settled and pending kept apart |
Where to start
Most apps need recipes 1 to 3 first, in this order of calls: make the customer's subaccount (recipe 3), register its webhook straight away (recipe 2), and receive what Astrada sends (recipe 1). To enroll cards in a page of your own, add recipe 4; with enrollment links you make a link for one subaccount and Astrada hosts the page. To show or report what a subaccount holds, recipes 5, 6 and 15 read it when you ask.
Before you start
- Install a backend SDK and log in with it: Backend SDKs.
- Get sandbox credentials to run the recipes against: Sandbox Environment.
- Each recipe names the scopes its calls need. Authentication explains clients and scopes.
Updated 24 minutes ago
