Sending Emails via BioT API
To send an email using the BioT API:
- If no attachments are needed, simply call the sendEmail endpoint.
- If you want to include attachments, first upload each file using the addAttachment endpoint, then reference it in the sendEmail request.
Upload the Attachment
Use the Add Attachment endpoint.
Request:
Use multipart/form-data to upload the file. This is similar to how file uploads work in HTML forms. The uploaded file must be passed using the file field.
Response:
A successful upload returns a JSON object that includes a unique key for the uploaded file:
{
"key": "report.pdf"
}Send the Email
Use the Send Email endpoint.
With Attachments (Optional)
Include the attachmentsKeysAndNames field in your payload only if your email includes attachments.
Each attachment requires:
- key: the file key received from the upload step
- value: the desired file name shown to the recipient
{
"addressesTo": ["[email protected]"],
"subject": "Monthly Report",
"body": "Please find the report attached.",
"emailTemplate": {
"templateId": "WelcomeEmailTemplate",
},
"attachmentsKeysAndNames": {
"report.pdf": "attached_report.pdf"
}
}Notes:
- Attachments are optional. Only include the attachmentsKeysAndNames field when needed.
- Uploaded files are deleted after the email is sent. To reuse a file, you must re-upload it.
- Each attachment must be uploaded individually before being referenced in the email request.
- templateId is the name of your HTML file for the email template. It must match the file name uploaded to BioT.
Using Dynamic Parameters (Marking Fields)
You can personalize emails by passing dynamic parameters in the API request and referencing them in your email content. Marking fields are simple placeholders that the service replaces at send time.
You can personalize your emails by adding dynamic parameters. Placeholders that BioT replaces dynamically when sending the message.
Dynamic parameters allow you to inject variable data (like a user’s name or an order ID) into the subject, body, or HTML template of your email.
How It Works
- In your email template or body, add placeholders using double curly braces.
- In your sendEmail request, include those names and their values in a markingFields object.
Example
Email body with placeholders:
<p>Hi {{USER_NAME}},</p>
<p>Your order {{ORDER_ID}} has been processed successfully.</p>API request:
{
"subject": "string",
"locale": "string",
"addressesTo": ["[email protected]"],
"addressesCC": [],
"emailTemplate": {
"templateId": "WelcomeEmailTemplate",
"markingFields": {
"USER_NAME": "Ava Cohen",
"ORDER_ID": "A12345"
}
},
"attachmentsKeysAndNames": {
"report.pdf": "attached_report.pdf"
}
}At send time, BioT automatically replaces the placeholders with the provided values.
Updated about 6 hours ago
