For the complete documentation index, see llms.txt. This page is also available as Markdown.

Twinr Push API

Send a push notification to one specific person from your own backend, using their device token.

Campaigns in Engage send to everyone, or to a segment. The Twinr Push API is for the other case: a notification aimed at one person, sent by your own code when something happens — an order ships, a message arrives, a booking is confirmed.

The Push API is included with every premium plan.

What you need to set up

Three things, in this order:

  1. Turn on Personalized push notification in Engage.

  2. Collect device tokens from the app with the JS bridge, and store them against your users.

  3. Send from your backend, authenticating with an account secret.

1. Turn it on in Engage

Open Engage, click + Create campaign, and choose Personalized push notification.

The Personalized push notification panel with its enable toggle and Webhook URL field

Enter your Webhook URL — the endpoint on your own server that receives the app's device IDs — and click Save as draft.

2. Get the device token

Inside the app, ask for the token and save it against the signed-in user:

It returns the token and the platform (android or ios), or nothing if push is not available on that device.

Store tokens against the user, not the session, and allow more than one — a person with a phone and a tablet has a token for each.

See Push Notification - Device Token for more on the bridge call.

3. Send the notification

Create an account secret

The API authenticates with an account secret. Go to My Profile → Account secrets, click Create secret, and scope it to the organization — or to just the apps this server should be able to reach.

Copy the secret before closing the dialog. Twinr shows it once and cannot show it again.

See Account Secrets for the full walkthrough.

Make the call

Pass the secret as a Bearer token:

push_tokens, push_title, push_message and click_action are required. push_image is optional and takes an image URL.

What tapping the notification does

click_action takes one of exactly three shapes.

Opens the app wherever the person left it.

Opens a specific tab. tab_name must match the tab's name in your Twinr dashboard exactly, capitalisation included — a name that does not match simply opens the app.

Opens a URL inside the app. Use this for anything about a specific order or record — it is the only shape that can carry an identifier.

Example

Sending to one user from a Node backend:

Common Questions

Nothing arrives when I test.

Work through these in order: Personalized push notification must be enabled in Engage, your account secret must be scoped to this app, the person must have allowed notifications on the device, you must have a stored token for them, and the test must run on a real device — push does not work in a browser or the previewer.

A 401 means the secret is wrong, revoked or expired. A 403 means the secret is valid but not scoped to this app.

How many tokens can I send to at once?

push_tokens takes a list, so one call can reach several devices. Send a person's own devices together rather than one call each.

What if someone signs out, or reinstalls?

Tokens change. Save the token each time someone signs in, and remove tokens for a user when they sign out so their notifications do not follow them to a shared device.

Can I use Zapier or a similar tool?

Yes. Anything that can send a POST request with a JSON body and an Authorization header will work.

Is this the same as a campaign?

No. Campaigns are set up in Engage and sent to everyone or to a segment. The Push API is for notifications your own code triggers for one person. See Push.

Last updated