Email endpoints
Email endpoints allow you to send emails to your users by doing a POST request to our service. These are created under the project view.
To be able to send emails you need to add an email configuration to your project - the configuration is stored as a JSON with your email provider settings. RESTED_DEV uses nodemailer internally, the provided options need to be compatible with nodemailer transporter. This is done in the project view, under configuration.
The email endpoint also supports GET requests to read the emails sent, and DELETE requests requests to delete emails. It does not support PUT requests as the data stored for emails cannot be modified.
Request data
HTTP method: POST
URL format: https://baseUrl/versionNumber/customEndpointRoute/userEndpoint?key=apiKey
Example: https://app.rested.dev/api/1/ce/project/email-endpoint?key=d59eb2859c284168..
Request Parameters
The following table describes the Request parameters.
Parameter | Description | Required |
baseUrl | Base url for calling the API Value: app.rested.dev/api | Yes |
versionNumber | Service version. Value: The current value is 1. | Yes |
customEndpointRoute | The route which identifies custom endpoints. Default value: ce | Yes |
userEndpoint | The endpoint name generated by the user. Value: the name created at https://app.rested.dev | Yes |
key | The API Key of the project. | Yes |
masterKey | Overrides the need for Access tokens or restrictions applied to secure endpoints. Don't use this key in your client application. For more information please refer to projects. Value: the masterKey created at https://app.rested.dev. | No |
Request Cookies
Header | Description | Required |
__Secure-rested-access-token | The Access token is required for secure endpoints. It is obtained when doing a login and it is stored in an httpOnly cookie. To automatically include it in the request you need to set the following property:
Alternatively you can also use the Authorization header. For more information please refer to the login documentation and Secure Endpoints documentation. | Yes - if endpoint is secure and Authorization header is not used |
Request Headers
Header | Description | Required |
Content-Type | Specifies the MIME type of the body of the Request. Options:
| Yes |
POST body
Parameter | Description | Required |
The recepient of the email. | Yes | |
body | The body of the email. This can be plain text or HTML. | Yes |
subject | The subject of the email. | No |
from | The sender of the email | No |
Response data
Error codes
Error code | Description |
400 | Possible reasons:
|
412 | Email configuration not set in the project. |
424 | There was a problem sending the email, this error is thrown by nodemailer. The reason could be wrong email configuration. |
Successful response
If the email is sent successfully the service will respond with 200.