|
| 1 | +--- |
| 2 | +title: Inbox API |
| 3 | +description: Learn about Notesnook's Inbox API. |
| 4 | +--- |
| 5 | + |
| 6 | +# Inbox API |
| 7 | + |
| 8 | +Notesnook's Inbox API allows a user to send data to their NN account from third party services. The inbox server exposes a public endpoint which accepts data, encrypts it, and adds it to the user's Notesnook account. |
| 9 | + |
| 10 | +## When to use Inbox API |
| 11 | + |
| 12 | +It is up to the user to decide when to use the Inbox API. Some common use-cases include: |
| 13 | +- Setting up a Zapier automation to send inbound emails to Notesnook as notes. |
| 14 | +- Integrating to a custom server. |
| 15 | +- Automating sending data from other apps to Noetesnook. |
| 16 | + |
| 17 | +## How to use Inbox API |
| 18 | + |
| 19 | +### 1. Enable Inbox API from settings. |
| 20 | + |
| 21 | +# [Desktop/Web](#/tab/web) |
| 22 | + |
| 23 | +`Settings > Inbox > Enable Inbox API`. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +### 2. Get your Inbox API Key. |
| 28 | + |
| 29 | +One API key should be created by default. You can create multiple API keys if needed. |
| 30 | + |
| 31 | +# [Desktop/Web](#/tab/web) |
| 32 | + |
| 33 | +`Settings > Inbox > Create Key`. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +### 3. Post data to Inbox API endpoint. |
| 38 | + |
| 39 | +**Endpoint**: `POST https://inbox.notesnook.com/` |
| 40 | + |
| 41 | +#### Headers |
| 42 | + |
| 43 | +| Header | Type | Status | Description | |
| 44 | +|--------|------|--------|-------------| |
| 45 | +| `Content-Type` | string | **Required** | Must be `application/json` | |
| 46 | +| `Authorization` | string | **Required** | Your inbox API key | |
| 47 | + |
| 48 | +#### Request Body |
| 49 | + |
| 50 | +| Field | Type | Status | Description | |
| 51 | +|-------|------|--------|-------------| |
| 52 | +| `title` | string | **Required** | Title. Minimum 1 character. | |
| 53 | +| `type` | string | **Required** | Entity type. Currently only `"note"` supported. | |
| 54 | +| `source` | string | **Required** | Source identifier (e.g., `"Zapier"`, `"Custom App"`). | |
| 55 | +| `version` | number | **Required** | Schema version. Currently `1`. | |
| 56 | +| `content` | object | Optional | Note content object | |
| 57 | +| `content.type` | string | **Required** (if content provided) | Content format. Currently only `"html"` supported. | |
| 58 | +| `content.data` | string | **Required** (if content provided) | HTML content as a string. | |
| 59 | +| `pinned` | boolean | Optional | Pin the note. Default: `false`. | |
| 60 | +| `favorite` | boolean | Optional | Mark as favorite. Default: `false`. | |
| 61 | +| `readonly` | boolean | Optional | Make note read-only. Default: `false`. | |
| 62 | +| `archived` | boolean | Optional | Archive the note. Default: `false`. | |
| 63 | +| `notebookIds` | string[] | Optional | Array of notebook IDs to assign note to. | |
| 64 | +| `tagIds` | string[] | Optional | Array of tag IDs to apply to note. | |
| 65 | + |
| 66 | +#### Response |
| 67 | + |
| 68 | +On success, the API returns a `200 OK` status. |
| 69 | + |
| 70 | +On failure, appropriate HTTP status codes (4xx, 5xx) are returned with error details. |
| 71 | + |
| 72 | +#### Example Request |
| 73 | + |
| 74 | +```bash |
| 75 | +curl -X POST https://inbox.notesnook.com/ \ |
| 76 | + -H "Content-Type: application/json" \ |
| 77 | + -H "Authorization: <your-inbox-api-key-here>" \ |
| 78 | + -d '{ |
| 79 | + "title": "My Important Note", |
| 80 | + "type": "note", |
| 81 | + "source": "zapier-email-forwarding", |
| 82 | + "version": 1, |
| 83 | + "content": { |
| 84 | + "type": "html", |
| 85 | + "data": "<h1>Meeting Notes</h1><p>Discussed Q4 roadmap</p>" |
| 86 | + }, |
| 87 | + "favorite": true, |
| 88 | + "tagIds": ["67aecf3b9e1398484554bc90"] |
| 89 | + }' |
| 90 | +``` |
| 91 | + |
| 92 | +> info |
| 93 | +> |
| 94 | +> Notebook and Tag IDs can be found by right-clicking on a notebook/tag and selecting `Copy ID`. |
| 95 | +
|
| 96 | +## How it works |
| 97 | + |
| 98 | +Inbox uses a hybrid symmetric and asymmetric encryption (public/private key pairs) scheme to ensure all data is encrypted on the inbox server and decrypted on the user's clients (web or desktop, mobile isn't supported yet). The flow looks like this: |
| 99 | + |
| 100 | +1. When user enables inbox from the settings: |
| 101 | + - The client generates a public/private encryption key pair. The public key is stored as-is on NN's servers. The private key is encrypted again with the user's encryption key and then stored on server. |
| 102 | + - User is also now able to generate API keys for the inbox endpoint. The API keys allow NN to authenticate the user for the inbox API. |
| 103 | +2. When user sends data to the inbox API: |
| 104 | + - The inbox endpoint is served from an inbox server separate from NN's servers. The data is encrypted using a random key. The random key itself is encrypted using the user's inbox public key. The entire payload is sent to the NN's servers where it is stored in the database. |
| 105 | +3. The inbox data is then synced to the web or desktop app. Using the private key, the data is decrypted on the client and then pushed into the user's database. |
0 commit comments