Skip to content

Commit 36eca38

Browse files
feat(arrays): Add arrays payload support for transactional email api (#13)
Co-authored-by: Dan <dan@loops.so>
1 parent 039f034 commit 36eca38

5 files changed

Lines changed: 24 additions & 17 deletions

File tree

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -621,17 +621,17 @@ Send a transactional email to a contact. [Learn about sending transactional emai
621621

622622
#### Parameters
623623

624-
| Name | Type | Required | Notes |
625-
| --------------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
626-
| `transactionalId` | string | Yes | The ID of the transactional email to send. |
627-
| `email` | string | Yes | The email address of the recipient. |
628-
| `addToAudience` | boolean | No | If `true`, a contact will be created in your audience using the `email` value (if a matching contact doesn’t already exist). |
629-
| `dataVariables` | object | No | An object containing data as defined by the data variables added to the transactional email template.<br />Values can be of type `string` or `number`. |
630-
| `attachments` | object[] | No | A list of attachments objects.<br />**Please note**: Attachments need to be enabled on your account before using them with the API. [Read more](https://loops.so/docs/transactional/attachments) |
631-
| `attachments[].filename` | string | No | The name of the file, shown in email clients. |
632-
| `attachments[].contentType` | string | No | The MIME type of the file. |
633-
| `attachments[].data` | string | No | The base64-encoded content of the file. |
634-
| `headers` | object | No | Additional headers to send with the request. |
624+
| Name | Type | Required | Notes |
625+
| --------------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
626+
| `transactionalId` | string | Yes | The ID of the transactional email to send. |
627+
| `email` | string | Yes | The email address of the recipient. |
628+
| `addToAudience` | boolean | No | If `true`, a contact will be created in your audience using the `email` value (if a matching contact doesn’t already exist). |
629+
| `dataVariables` | object | No | An object containing data as defined by the data variables added to the transactional email template.<br />Values can be of type `string`, `number`, or an array of objects with `string` or `number` values. |
630+
| `attachments` | object[] | No | A list of attachments objects.<br />**Please note**: Attachments need to be enabled on your account before using them with the API. [Read more](https://loops.so/docs/transactional/attachments) |
631+
| `attachments[].filename` | string | No | The name of the file, shown in email clients. |
632+
| `attachments[].contentType` | string | No | The MIME type of the file. |
633+
| `attachments[].data` | string | No | The base64-encoded content of the file. |
634+
| `headers` | object | No | Additional headers to send with the request. |
635635

636636
#### Examples
637637

@@ -770,7 +770,8 @@ const resp = await loops.getTransactionalEmails({ perPage: 15 });
770770

771771
## Version history
772772

773-
- `v6.1.0` (Jan 29, 2026) - Added `rawBody` to `APIError` in the case no JSON is received from the server (thanks to [@leipert](https://github.com/leipert)).
773+
- `v6.2.0` (Feb 9, 2026) - Support for the new arrays feature in sendTransactionalEmail.
774+
- `v6.1.2` (Jan 29, 2026) - Added `rawBody` to `APIError` in the case no JSON is received from the server (thanks to [@leipert](https://github.com/leipert)).
774775
- `v6.0.1` (Oct 15, 2025) - Added `optInStatus` to contact object in [`findContact()`](#findcontact) for the new double opt-in feature.
775776
- `v6.0.0` (Aug 22, 2025) - [`createContact()`](#createcontact) and [`updateContact()`](#updatecontact) now have a single object parameter instead of named parameters (breaking change). This allows support for using either `email` or `userId` when updating contacts.
776777
- `v5.0.1` (May 13, 2025) - Added a `headers` parameter for [`sendEvent()`](#sendevent) and [`sendTransactionalEmail()`](#sendtransactionalemail), enabling support for the `Idempotency-Key` header.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "loops",
3-
"version": "6.1.2",
3+
"version": "6.2.0",
44
"author": "Dan Rowden <dan@loops.so>",
55
"license": "MIT",
66
"main": "./dist/index.cjs",

src/__tests__/LoopsClient.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,10 @@ describe("LoopsClient", () => {
499499
email: "test@example.com",
500500
dataVariables: {
501501
name: "John",
502-
product: "Widgets",
502+
products: [
503+
{ name: "Widget", price: 29.99 },
504+
{ name: "Gadget", price: 49.99 },
505+
],
503506
},
504507
};
505508
const mockResponse = { success: true };

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ type EventProperties = Record<string, string | number | boolean>;
111111

112112
type MailingLists = Record<string, boolean>;
113113

114-
type TransactionalVariables = Record<string, string | number>;
114+
type TransactionalVariables = Record<
115+
string,
116+
string | number | Array<Record<string, string | number>>
117+
>;
115118

116119
interface TransactionalAttachment {
117120
/**

0 commit comments

Comments
 (0)