●REST API
With the REST API, you can use mailing for email templating even if most of your app is not written in TypeScript or JavaScript.
Method | Path | Description | Example |
---|---|---|---|
GET, POST | /api/render | render a template with props to HTML | Link |
GET | /api/sendMail | send an email with props |
Note: /api/render is publicly accessible by default. However, if process.env.REQUIRE_API_KEY is set then api/render will 401 unless a valid API key is included in the request. Read more about API keys
Method | Path | Description | Example |
---|---|---|---|
GET | /api/previews | returns the list of previews | Link |
GET | /api/previews/[previewClass]/[previewFunction] | returns the rendered preview | Link |
Method | Path | Description |
---|---|---|
GET | /api/lists | get all lists |
POST | /api/lists | create a new list |
GET | /api/lists/[listId]/members | get the members of a list |
POST | /api/lists/[listId]/members | add a member to a list |
GET | /api/lists/[listId]/members/[memberId] | get a list member's status |
PATCH | /api/lists/[listId]/members/[memberId] | update a list member's status |
Mailing uses API keys to protect endpoints that consume limited resources (e.g. sending email with your transport).
To get an API key, either set up a database and log in (recommended).
Or, make up your own key and assign it to the MAILING_API_KEY
environment variable in your deployment environment.
You then pass your API key in each request with one of these methods:
- Include the API key in the request headers:
X-API-KEY=...
- Include the API key as a query string parameter:
?apiKey=...