> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pacifica.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Register Expo Device

> This endpoint allows users to register an Expo push token so that the mobile app receives push notifications.

```http theme={null}
POST /api/v1/account/notifications/expo/device
```

This endpoint registers or refreshes an Expo push token for your account. Pacifica sends `mobile_push` [notifications](https://docs.pacifica.fi/api-documentation/api/rest-api/notifications) to every active token on the account.

#### Operation Type (for Signing)

| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"register_expo_device"` |

#### Request Body

<table><thead><tr><th width="200">Field</th><th width="98">Type</th><th width="95">Need</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>`"account"`</td><td>string</td><td>required</td><td>User's wallet address</td><td>`42trU9A5...`</td></tr><tr><td>`"signature"`</td><td>string</td><td>required</td><td>Cryptographic signature</td><td>`5j1Vy9Uq...`</td></tr><tr><td>`"timestamp"`</td><td>integer</td><td>required</td><td>Current timestamp in milliseconds</td><td>`1716200000000`</td></tr><tr><td>`"expo_push_token"`</td><td>string</td><td>required</td><td>Expo push token from the Expo SDK. It must have the form `ExponentPushToken[...]` or `ExpoPushToken[...]`, and up to 512 characters</td><td>`ExponentPushToken[xxxx]`</td></tr><tr><td>`"platform"`</td><td>string</td><td>required</td><td>`"ios"` or `"android"`</td><td>`ios`</td></tr><tr><td>`"device_id"`</td><td>string</td><td>required</td><td>Secret installation key that your app generates once and keeps. 16 to 256 characters</td><td>`b7f3c1a9...`</td></tr><tr><td>`"expiry_window"`</td><td>integer</td><td>optional</td><td>Signature expiry in milliseconds</td><td>`30000`</td></tr></tbody></table>

```json theme={null}
{
  "account": "42trU9A5...",
  "signature": "5j1Vy9Uq...",
  "timestamp": 1716200000000,
  "expo_push_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
  "platform": "ios",
  "device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8",
  "expiry_window": 30000
}
```

You must sign this request with the account key. An [agent wallet](https://docs.pacifica.fi/api-documentation/api/signing/api-agent-keys.md) can't sign it.

`device_id` identifies one installation of your app. Generate at least 128 random bits on the first install, and keep them in the device's secure storage. Don't use a hardware ID or a user ID. The length check doesn't make a weak key safe.

* When you register again with the same `device_id`, Pacifica refreshes the registration. If the token changed, Pacifica turns off the old token.
* A token belongs to one installation. If a different `device_id` already holds the token, the request fails with status 409. This is also true after that installation unregisters the token.
* If the same installation registers under another account, the token moves to that account. The previous account stops sending to it.

After you register, turn on `mobile_push` with [Set notification master preference](https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/set-notification-master-preference.md) and [Set notification preference](https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/set-notification-preference.md).

#### Response

* Status 200: Device registered

```json theme={null}
{
  "success": true,
  "data": {
    "expo_push_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
    "platform": "ios",
    "device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8",
    "enabled": true
  },
  "error": null,
  "code": null
}
```

<table><thead><tr><th width="208">Field</th><th width="186">Type</th><th>Description</th></tr></thead><tbody><tr><td>`"expo_push_token"`</td><td>string</td><td>Registered Expo push token</td></tr><tr><td>`"platform"`</td><td>string</td><td>`"ios"` or `"android"`</td></tr><tr><td>`"device_id"`</td><td>string</td><td>Installation key that holds the token</td></tr><tr><td>`"enabled"`</td><td>boolean</td><td>`true` when Pacifica sends to this token</td></tr></tbody></table>

* Status 400: Invalid request parameters or signature. A bad token returns `error_id` `invalid_expo_push_token`. A missing or bad `device_id` returns `invalid_notification_device_id`
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 409: Another installation holds this token

```json theme={null}
{
  "success": false,
  "data": null,
  "error": "Expo push token is registered to another device",
  "code": 409,
  "error_id": "expo_push_token_conflict"
}
```

* Status 429: Rate limit exceeded
* Status 500: Internal server error

#### Code Example (Python)

```python theme={null}
import requests

payload = {
    "account": "42trU9A5...",
    "signature": "5j1Vy9Uq...",
    "timestamp": 1716200000000,
    "expo_push_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
    "platform": "ios",
    "device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8"
}

response = requests.post(
    "/api/v1/account/notifications/expo/device",
    json=payload,
    headers={"Content-Type": "application/json"}
)

data = response.json()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.