Push and pull
You can keep up in two ways:
- Push: Shift notifies your system the moment something happens. This keeps you in step with us in real time.
- Pull: you request what is new or changed yourself. That always works, also without push.
Pull is always available, push is a choice. If you want push, give us the URL at which your system receives the notifications. We advise using both: push to know immediately that something is there, pull to catch up on everything after an outage.
What a push contains
Section titled “What a push contains”A push contains no personal data. Only what happened, to which record, and which version that record now has:
{ "event_id": "01JH3Q8Z6T4N2V5K7R9B0C1D2E", "type": "pledge.created", "record_id": "PL00012345", "version": 1, "occurred_at": "2027-01-04T13:05:00Z"}After a push you fetch the record with GET /v1/pledges/{record_id}.
Why without personal data
Section titled “Why without personal data”This is a deliberate choice, for security and the protection of your donors’ personal data.
- A push goes to an address on the internet. If that address is ever set up wrongly, or falls into someone else’s hands, nothing leaks: it only holds a record ID and a version.
- Personal data and bank account numbers therefore only travel over the API itself, where all the locks are: your secret, a short-lived token, your fixed IP addresses and your rights.
- Pushes may arrive in a different order than they were sent. Because you fetch the latest version after every push, an old notification can never overwrite a newer state.
The kinds of notification
Section titled “The kinds of notification”type |
When |
|---|---|
pledge.created |
There is a new pledge, with the status pending. |
pledge.updated |
A detail of the pledge has changed. |
pledge.no_show |
The pledge lapsed before it became final. |
pledge.confirmed |
The pledge is final (day 9). |
pledge.cancelled |
The donor stopped after day 9. |
More kinds may be added later. Ignore a type you do not know.
Verifying a push
Section titled “Verifying a push”Every push is signed, so that you know it comes from Shift and was not forged or replayed. When you connect, you receive your own signing secret. Every push has two headers:
| Header | Content |
|---|---|
Shift-Timestamp |
The moment of sending, in seconds since 1970 (Unix time) |
Shift-Signature |
sha256= followed by the HMAC-SHA256 of <timestamp>.<body> with your secret, in hexadecimal |
Check on every push:
- Compute the signature yourself over the timestamp, a dot and the raw body as you received it.
- Compare it with
Shift-Signatureusing a constant-time comparison (for examplehash_equalsin PHP orhmac.compare_digestin Python). - Refuse the push if the timestamp is more than 5 minutes off your clock.
- If you have already processed this
event_id, answer200and do nothing else.
Answer within a few seconds with a 2xx status. If a push fails, we retry for
a while with ever longer pauses (how long: to follow). If it keeps failing,
we switch push off for you and contact you. You miss nothing: with pull you
catch up on everything.
A push always comes over HTTPS and from Shift’s fixed IP addresses, which you receive when you connect.
GET /v1/pledges?updated_since=<date and time> returns the pledges that are new
or changed since that moment, oldest change first, in pages.
How to keep up:
- Remember the moment you start fetching.
- Fetch with
updated_sinceset to the start of your previous round. - Page through with
cursor(thenext_cursorfrom the previous answer) untilhas_moreisfalse. - Process every record as an update based on
record_idandversion.
updated_since may lie at most one month back, even though a status
record stays fetchable for 13 months. So fetch at least once a month. From 7 days after confirmed, and straight away with
no_show, a record holds only the status (see What you can
fetch).
pace-api staging · a79cbe01e4c5