Notifications are off by default. To get a notification, turn on its channel in the master preference and for its notification type. See Preferences.
- Register Expo device: This endpoint allows users to register an Expo push token so that the mobile app receives push notifications.
- Unregister Expo device: This endpoint allows users to stop push notifications to an Expo push token or app installation.
- Get Web Push config: This endpoint allows users to check if Web Push is available and to get the VAPID public key.
- Register Web Push subscription: This endpoint allows users to register a browser’s Web Push subscription.
- Get Web Push subscription status: This endpoint allows users to check if a browser installation gets Web Push notifications.
- Unregister Web Push subscription: This endpoint allows users to stop Web Push notifications to a browser installation.
- List notification preferences: This endpoint allows users to get the notification channels that are on for an account.
- Set notification preference: This endpoint allows users to turn a channel on or off for one or more notification types.
- Set notification master preference: This endpoint allows users to turn a channel on or off with the account’s master switch.
- Send test notification: This endpoint allows users to send a test notification on the account’s enabled channels.
- Get notification history: This endpoint allows users to get an account’s recent in-app notifications and unread count.
- Mark notifications seen: This endpoint allows users to mark notifications as seen.
Notification types
Each notification has anotification_type. You set preferences for these types:
Orders that an order strategy places also send order notifications.
Send test notification sends the
test type. You can’t set preferences for test.
The API schema also lists account, trading, risk, price_alert, and announcement. Pacifica doesn’t send these types now, and you can’t set preferences for them.
Strategy updates
A strategy_update notification has an outcome in its data:
Pacifica doesn’t send a notification when a strategy starts, pauses, or resumes, or when you cancel it.
Notification data
Each notification has atitle, a body, and a data object. The title and body are English text for display. Use data to route a tap or click in your app.
data always contains notification_type and kind. Both are set to the notification type. The other fields depend on the type. Decimal values are strings. IDs are strings.
Orders (order_filled, order_partially_filled, order_canceled, tp_sl_triggered)
| Field | Type | Description |
|---|---|---|
”order_id” | string | Order ID |
”symbol” | string | Market symbol |
”base_symbol” | string | Same as “symbol" |
"side” | string | ”buy” or “sell" |
"order_type” | string | ”limit""market""stop limit""stop market""take profit""stop loss" |
"price” | decimal string | Order price |
”initial_amount” | decimal string | order_partially_filled only. Order amount |
”filled_amount” | decimal string | order_partially_filled and order_filled only. Amount filled |
”last_filled_price” | decimal string | order_filled only. Price of the last fill |
”cancel_reason” | string | order_canceled only:“canceled""force_canceled""expired" |
"stop_price” | decimal string | tp_sl_triggered only. Trigger price. Omitted when the order has no stop price |
”trigger_kind” | string | tp_sl_triggered only. “take_profit” or “stop_loss” |
liquidation)
| Field | Type | Description |
|---|---|---|
”history_id” | string | Trade history ID |
”order_id” | string or null | Order ID of the liquidation |
”symbol” | string | Market symbol |
”base_symbol” | string | Same as “symbol" |
"position_side” | string | ”long” or “short" |
"amount” | decimal string | Amount liquidated |
”price” | decimal string | Liquidation price |
”entry_price” | decimal string | Entry price of the position |
”pnl” | decimal string | Realized PnL |
”cause” | string | ”market_liquidation""backstop_liquidation""insolvency_liquidation” |
deposit_success, withdraw_success)
| Field | Type | Description |
|---|---|---|
”history_id” | string | deposit_success only. Deposit history ID |
”signature” | string | deposit_success only. Deposit transaction signature |
”withdraw_id” | string | withdraw_success only. Withdrawal ID |
”tx_hash” | string | withdraw_success only. Withdrawal transaction hash |
”asset” | string | ”USDC”, or the spot asset |
”symbol” | string | Spot deposits and withdrawals only. Spot asset symbol |
”amount” | decimal string | Amount |
strategy_update)
| Field | Type | Description |
|---|---|---|
”strategy_id” | UUID | Strategy ID |
”type” | string | Strategy type, for example “twap" |
"symbol” | string | Market symbol that the strategy trades |
”base_symbol” | string | Same as “symbol" |
"lifecycle” | string | The strategy’s lifecycle after the change |
”outcome” | string | What happened. See Strategy updates above |
”terminal_reason” | string or null | Why the strategy ended, for example “insufficient_balance”. Show your own label for this code |
Preferences
An account has a master preference and a preference for each notification type. Each preference is a set of channels.- Pacifica uses a channel only when the channel is on in the master preference and in the type’s preference.
- All channels start off. A missing preference counts as off.
- The master preference doesn’t change the type preferences. You can turn a channel off in the master preference to pause it, and turn it on again later.
- Pacifica picks the channels when it creates a notification. A later preference change doesn’t change notifications that already exist.
- Turning on a type doesn’t backfill notifications for older events.
- The
testtype uses only the master preference.
mobile_push and in_app with Set notification master preference. Then turn on the same channels for order_filled with Set notification preference.
Mobile push (Expo)
- On the first install, generate at least 128 random bits. Encode them as a string, for example hexadecimal. Keep this installation key in the device’s secure storage.
- Get the Expo push token from the Expo SDK.
- Call Register Expo device with the token, the
platform, and the installation key asdevice_id. - Turn on
mobile_pushin the master preference and for the types that you want. - When the user signs out, call Unregister Expo device.
data is the notification’s data object. Route a tap by data.notification_type.
Web Push
- Call Get Web Push config. If
enabledisfalse, hide Web Push in your app. Otherwise, readvapid_public_key. - Generate an
installation_idof 32 to 64 characters fromA-Z,a-z,0-9,-, and_. Store it where the page and the service worker can both read it, for example IndexedDB. - In the browser, call
pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: vapid_public_key }). - Call Register Web Push subscription with the subscription’s endpoint and keys.
- Turn on
web_pushin the master preference and for the types that you want. - In the service worker, show each push with
showNotification. Usenotification_idas thetag. - When the page loads, call Get Web Push subscription status. If
stateisexpiredorkey_rotated, subscribe again and register again. - When the user signs out or switches account, call Unregister Web Push subscription.
notification_id is the id that Get notification history returns. Route a click by data.notification_type.
History and seen
- Get notification history returns only notifications that Pacifica created with the
in_appchannel on. Push-only notifications aren’t in the history. - It returns the 100 newest notifications, newest first. It has no pagination.
unread_countcounts all in-app notifications that aren’t seen. It can be more than 100.- Mark notifications seen marks the IDs that you send. There is no “mark all” call. Send the IDs that you show.
- Seen state belongs to the account. All the account’s devices and browsers see the same state.
Delivery
- Pacifica sends a push only in the first 15 minutes after it creates the notification. After that, it drops the push. The notification stays in the history if
in_appwas on. - Pacifica sends a
mobile_pushnotification to every active Expo token on the account. It turns off a token when Expo reports that the device is no longer registered. - Pacifica sends a
web_pushnotification to every active Web Push subscription on the account. It turns off a subscription when the push service reports that the subscription is gone. - A push service accepting a push doesn’t mean the device showed it.
Signing and limits
- An account keeps up to 10 active Web Push subscriptions. When you register one more, Pacifica turns off the subscription that was registered longest ago.
- An app installation has one active Expo token for each account. When you register a new token with the same
device_id, Pacifica turns off the old token. - The account must exist. An account exists after its first deposit. Other accounts get status 403.
- The standard rate limits apply.