Send with fetch

Send emails without the npm package, straight against the REST API with an API key.

If the npm package isn't available, you can send directly against the REST API. The endpoint expects multipart/form-data and an API key in the x-api-key header.

Endpoint

POST {API_BASE_URL}/api/applications/{applicationId}/emails/send

Example

const form = new FormData()
form.append('to', '[email protected]')
form.append('templateUUID', 'YOUR_TEMPLATE_UUID')
form.append('data', JSON.stringify({ name: 'Jane' }))
 
await fetch(`${API_BASE_URL}/api/applications/YOUR_APPLICATION_ID/emails/send`, {
    method: 'POST',
    headers: {
        'x-api-key': process.env.TUIX_EMAIL_API_KEY,
    },
    body: form,
})

A private API key belongs on the server only; a public key may be used in the frontend. Do not set Content-Type manually: with FormData the browser adds the correct multipart/form-data boundary automatically.

Optional fields: body (inline content) and file (attachment). See Email parameters.

On this page