Set up your endpoint
- Create an HTTPS endpoint on your server that accepts
POSTrequests. - Email [email protected] with its URL and your partner name.
- We’ll send you a signing secret, starting with
whsec_. You’ll only receive it once, so store it as carefully as an API key.
What Tern sends
Handle a request
- Check the signature, as shown below. If it doesn’t match, reject the request.
- Respond with any
2xxstatus within 10 seconds. - Do any slow work after responding, or add it to a queue. Requests that take too long are retried.
Check the signature
tern-signature looks like t=<unix time>,v1=<signature>.
- Split it on
,and readtandv1. - Join
t, a., and the raw request body exactly as you received it, before parsing the JSON. - Compute the HMAC-SHA256 of that string using your signing secret, as lowercase hex.
- Compare it with
v1using a constant-time comparison. Reject the request if they differ, or iftis more than 5 minutes away from now.
Delivery and retries
- You may get the same update twice. Tern keeps retrying until you respond with
2xx. Ignore repeats by checking the body’sidandstatus. - Updates arrive in order for each swap. A later update waits while an earlier one is being retried. Different swaps don’t wait for each other.
- What counts as a failure: any status other than
2xx, no response within 10 seconds, or a redirect. - When Tern retries: 10 seconds after a failure, then doubling each time, up to an hour apart. After 15 attempts, about 6.5 hours, the delivery is marked as failed. Once your endpoint is back up, email [email protected] and we’ll resend failed deliveries.
- Changing your URL or secret takes effect from the next attempt. A new secret replaces the old one immediately, so update your endpoint right away.