Skip to main content

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.

ParameterDescriptionRequired
baseUrl

Base url for calling the API

Value: app.rested.dev/api
Yes
versionNumber

Service version.

Value: The current value is 1.
Yes
customEndpointRouteThe route which identifies custom endpoints. Default value: ceYes
userEndpointThe endpoint name generated by the user. Value: the name created at https://app.rested.devYes
keyThe 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

HeaderDescriptionRequired
__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:

// using fetch { credentials: 'include' } // using axios { withCredentials: true }

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

HeaderDescriptionRequired
Content-Type

Specifies the MIME type of the body of the Request. Options:

  • application/json
  • text/plain
Yes

POST body

ParameterDescriptionRequired
emailThe recepient of the email.Yes
bodyThe body of the email. This can be plain text or HTML.Yes
subjectThe subject of the email.No
fromThe sender of the emailNo

Response data

Error codes

Error codeDescription
400

Possible reasons:

  • email not provided or not valid;
  • body of the email not provided.
412Email configuration not set in the project.
424There 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.