How to add attachments in email

In this document, we will explain how to add a single or multiple attachments in your email.

You can add static as well as dynamic attachments to emails

There is no limit to the number of attachments. However, maximum size of the attachment(s) should be 10MB. We support the following file extensions: .jpg, .jpeg, .png, .gif, .pdf, .mp4, .doc, .docx, .xls and .xlsx

On clicking on the attach button (highlighted below) on the to right corner of the either Email editor, you will see:

  • Upload Files: Allows you to attach files from the system. This then stays as a static attachment in the body of the email and is sent along with the email as an attachment every time it’s triggered.

  • Dynamic Placeholders: Allows you to include dynamic files within the email, when the notification event is triggered. You can use placeholders to specify the:

    • Filename - provide a static value like ‘Invoice.pdf’ (if you are testing it manually) or a placeholder like {{attachment.filename}}(if your are triggering notification event via API)
    • File type - provide a static value like ‘application/pdf’ (for pdf) or ‘image/jpg’ (for jpg image) etc. (if you are testing it manually) or a placeholder like {{attachment.filetype}}(if your are triggering notification event via API). File type should be MIME type. You can get all the MIME types here
    • Content - provide the Presigned URL link here using a placeholder like {{attachment.presigned_url}}. You can provide a Public URL instead of Presigned URL. You can also provide base64 content, but its not recommended as it will increase your payload size.
Please note that if you are using Presigned S3 URL, then the URL should trigger a download of the file immediately when opened.

Placeholders should be used if the attachment information is dynamic (for instance, a personalized attachment depending on the recipient). Typically such attachments are sent via an API call. To send dynamic attachments in the event payload, make sure that the data section of the payload has an object called attachment as shown below.

For file type, use MIME types depending on your attachment’s file type
Send Attachment via Email
1curl -X POST 'https://api.fyno.io/v1/<WorkspaceID>/event' \
2-H 'Authorization: Bearer <API_KEY>' \
3-H 'Content-Type: application/json' \
4-d '{
5 "event": "EmailWithAttachments",
6 "to": {
7 "email": "xyz@gmail.com"
8 },
9 "data": {
10 "attachment":
11 {
12 "presigned_URL": "<presigned_URL>",
13 "filename": "<attachment_file_name>",
14 "filetype": "application/pdf"
15 }
16 }
17}'

In the above command:

1Replace <WorkspaceID> with your actual Workspace ID.
2Replace <API_KEY> with your actual API key.
3Replace <presigned_URL> with the Presigned URL of your file.
4Replace <filename> with the name of the file attached.

Ensure to provide the correct filename and filetype for the attachment.

When sending dynamic attachments in the payload, we need to configure the dynamic placeholders as shown below.

You cannot use only numeric values as placeholder keys!

How to add multiple attachments?

To add multiple attachments in email, add them in the placeholders as shown below.

1For file 1, you can give the below placeholders,
  • Filename - {{attachment.0.filename}}
  • File Type - {{attachment.0.filetype}}
  • Content - {{attachment.0.presigned_URL}}
2Click ‘Add Key’
3For file 2, you can give the below placeholders
  • Filename - {{attachment.1.filename}}
  • File Type - {{attachment.1.filetype}}
  • Content - {{attachment.1.presigned_URL}}
4You can keep adding as many files. The total file size should not exceed 10MB.
Please note that the content can be base64-encoded content or a Presigned URL