Guest API: Push and notices
Registering a device for pushes, and the inbox of notices PurrCRM keeps.
| What it does | Route |
|---|---|
| Forget a device | DELETE /guest/v1/devices |
| Register a device for pushes | PUT /guest/v1/devices |
| List the user’s notices | GET /guest/v1/notices |
| Mark notices read | POST /guest/v1/notices/read |
Forget a device
Section titled “Forget a device”DELETE /guest/v1/devices
Stops pushes to this device for this user: call it before your own sign-out, while the user’s token still works.
Needs: the app key (X-CRM-App-Key) and the signed-in user’s token (Authorization: Bearer …), or their id for an app with unverified sign-in. See From a website or web app.
Body (application/json): ForgetDeviceBody
| Field | Type | Description |
|---|---|---|
token (always) | string |
Answers
| Status | Body | Meaning |
|---|---|---|
| 204 | none | Done, with nothing to say |
| 400 | problem | The request could not be read: the problem names the field. |
| 401 | problem | No credential, or one that is not right. |
| 403 | problem | Refused: the app is switched off, or this is not allowed. |
| 429 | problem | Too many requests: wait for Retry-After. |
Register a device for pushes
Section titled “Register a device for pushes”PUT /guest/v1/devices
The device’s push token (from Firebase), for the user signed in. Register on every start and whenever the token changes.
Needs: the app key (X-CRM-App-Key) and the signed-in user’s token (Authorization: Bearer …), or their id for an app with unverified sign-in. See From a website or web app.
Body (application/json): DeviceBody
| Field | Type | Description |
|---|---|---|
app_version | string | AppVersion and Locale are what the app is and speaks, for staff to tell devices apart; both may be left out. |
locale | string | |
platform (always) | PushPlatform (one of android, ios, web) | |
token (always) | string |
Answers
| Status | Body | Meaning |
|---|---|---|
| 204 | none | Done, with nothing to say |
| 400 | problem | The request could not be read: the problem names the field. |
| 401 | problem | No credential, or one that is not right. |
| 403 | problem | Refused: the app is switched off, or this is not allowed. |
| 429 | problem | Too many requests: wait for Retry-After. |
List the user’s notices
Section titled “List the user’s notices”GET /guest/v1/notices
The inbox of every push sent to the user, newest first, a page at a time, with the unread count.
Needs: the app key (X-CRM-App-Key) and the signed-in user’s token (Authorization: Bearer …), or their id for an app with unverified sign-in. See From a website or web app.
Parameters
| Name | In | Description |
|---|---|---|
before | query | Where the page starts: the next_before (or before) of the page before it. |
limit | query | How many to answer, at most. |
Answers
| Status | Body | Meaning |
|---|---|---|
| 200 | NoticePage | OK |
| 400 | problem | The request could not be read: the problem names the field. |
| 401 | problem | No credential, or one that is not right. |
| 403 | problem | Refused: the app is switched off, or this is not allowed. |
| 429 | problem | Too many requests: wait for Retry-After. |
Mark notices read
Section titled “Mark notices read”POST /guest/v1/notices/read
Needs: the app key (X-CRM-App-Key) and the signed-in user’s token (Authorization: Bearer …), or their id for an app with unverified sign-in. See From a website or web app.
Body (application/json): NoticesReadBody
| Field | Type | Description |
|---|---|---|
all | boolean | |
ids | array of string |
Answers
| Status | Body | Meaning |
|---|---|---|
| 200 | UnreadCount | OK |
| 400 | problem | The request could not be read: the problem names the field. |
| 401 | problem | No credential, or one that is not right. |
| 403 | problem | Refused: the app is switched off, or this is not allowed. |
| 429 | problem | Too many requests: wait for Retry-After. |