Loops
Trigger a published Loops transactional email for one recipient, with metadata delivered as dataVariables.
Capabilities
| Repeated headers | Idempotency | Scheduling | Personalized |
|---|---|---|---|
| No | none |
No | expanded |
These values come from the adapter’s exported capabilities declaration. The field support matrix covers normalized message fields.
The Loops adapter calls the Loops transactional API with plain fetch. It triggers a published transactional email by transactionalId for exactly one recipient and hands your message to the template as dataVariables.
Configure
Create an API key in Loops with permission to send transactional email, then publish the transactional email and copy its transactionalId.
import { createEmailClient } from "@opencoredev/email-sdk";
import { loops } from "@opencoredev/email-sdk/loops";
export const email = createEmailClient({
adapters: [
loops({
apiKey: process.env.LOOPS_API_KEY!,
transactionalId: process.env.LOOPS_TRANSACTIONAL_ID!,
}),
],
});
apiKeystring
Loops API key.
stringtransactionalIdstring
Published transactional email to render. Must be non-empty; the adapter throws at construction otherwise.
stringbaseUrl?string
Override the API origin, e.g. for a proxy.
string"https://app.loops.so"fetch?typeof fetch
Custom fetch implementation for tests or special runtimes.
typeof fetchSend
The Loops template renders the email. The adapter merges subject, html, text, from, and every metadata key into dataVariables; your template decides which of them appear. Exactly one to recipient is allowed per send.
const result = await email.send({
from: "Acme <hello@acme.com>",
to: "user@example.com",
subject: "Reset your password",
html: "<p>Use the button below to reset your password.</p>",
metadata: {
firstName: "Ada",
resetUrl: "https://acme.com/reset/abc123",
},
});
console.log(result.id); // Loops id (or transactionalId) from the response
Attachments are supported and sent as { filename, contentType, data } with base64-encoded content.
Verify from the CLI
LOOPS_API_KEY="..." LOOPS_TRANSACTIONAL_ID="cm..." npx email-sdk doctor --adapter loops
LOOPS_API_KEY="..." LOOPS_TRANSACTIONAL_ID="cm..." npx email-sdk send \
--adapter loops \
--from "Acme <hello@acme.com>" \
--to user@example.com \
--subject "Loops smoke test" \
--text "It works" \
--dry-run
Drop --dry-run to trigger one real template send and confirm the API key and published transactional email are live.