Skip to main content

How to test? Create an account

To access the API and try its email features, follow these steps:
  1. Sign up for PigeonPost. We create your workspace, with its own API server, database and dashboard.
  2. Log in to your dashboard and get your DSN. Your DSN is your workspace’s API address, for example https://mail-api.example.com. Use it for every request: https://mail-api.example.com/api/v1/...
  3. Generate an access token. In the dashboard, open API keys and create one. It’s shown only once, so copy it right away. Send it in the X-API-KEY header.
  4. Connect an email account. In the dashboard, open Accounts → Add account and connect a mailbox with an email address and password (for Gmail use an app password). It then appears under Accounts, so you can test API calls without building the connection flow first.
  5. Try the API. Open the API reference tab, enter your DSN and access token, pick a route, fill in the parameters and send the request. No code needed.

Your first calls

Set your DSN and access token as environment variables for the examples below:
Check that they work, and find the account you connected in the dashboard:
Response
Every id starts with its type: acc_ for an account, email_ for an email, and so on. See Core concepts.

Connect your users’ accounts from your app

1

Connect the user's mailbox

Show a form in your app where the user enters their email address and password (an app password for Gmail). Send them to the engine:
For Gmail, Yahoo, iCloud and other well-known providers, the servers are filled in for you. For other mailboxes, also send the IMAP and SMTP servers. The engine signs in to both servers before saving the account.
Response 201
Save the account’s id with your user. state is your own value, for example your user’s id. If you have a webhook endpoint for account.add, it also receives the new account with your state. A wrong password answers 401 errors/invalid_credentials: see Connect a mailbox for every setting and error.
2

List the user's emails

The account syncs every email that arrives from now on. Mail already in the mailbox isn’t imported (unless you turn on initial sync, up to the last 30 days), so send it a test email first.
Response (shortened)
3

Send an email

Response 201
The email is sent from the user’s own address, through their provider.
4

Receive webhooks

Register a URL of your app, and choose the events it receives:
Keep the secret from the response: it signs every call. When an email arrives, your URL receives an email.new event with the full email in data.email. See Events and Verify signatures.

What’s next

Replies and threads

Answer emails so they stay in the same conversation.

Attachments

Download received files and send your own.

Account status

Handle expired passwords and revoked access.

Errors

What each error means and how to handle it.