由 Tia 出售

Official Node.js and TypeScript SDK for the Brevo API, enabling transactional email sending, contact management, deals, and full CRM integration from backend applications.
@getbrevo/brevo)This block provides the complete Brevo (formerly Sendinblue) Node.js/TypeScript SDK v3, exposing typed API clients for transactional email, SMS, contacts, campaigns, webhooks, ecommerce, and more. It targets backend services—Express apps, serverless functions, Node.js scripts—that need to send email or SMS, manage contacts, or interact with the Brevo platform programmatically.
api/ - Individual typed API client classes, one file per Brevo service domain (email, contacts, SMS, webhooks, etc.)model/ - TypeScript model/DTO classes for all request and response payloadsapi.ts - Root entrypoint; re-exports everything from api/apis and model/modelsrequestCompat.ts - Axios-based HTTP adapter that bridges the SDK's internal request layertsconfig.json - TypeScript compiler config for the SDK sourcepackage.json - Package manifest with dependencies and entry points.github/workflows/release.yml - CI release workflow (not relevant to integration)git_push.sh - Utility script for SDK publishing (not relevant to integration)LICENSE.md - MIT license textnpm install axios bluebird rewire
npm install --save-dev @types/node @types/bluebird
No native modules, no pod install, no Android linking, no prebuild step required. This is a pure Node.js/TypeScript package.
Copy source into your project. Place the contents of source/ at a path such as src/brevo/ in your project. The critical files are api/, model/, api.ts, and requestCompat.ts.
Configure TypeScript path aliases (optional but recommended). In your tsconfig.json:
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@brevo/*": ["src/brevo/*"]
}
},
"include": ["src"]
}
启动隔离沙箱并在服务器端直接运行 — 无需本地配置。
此版本的 Tetrees AI Review
This Express backend / api completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
管道 avcp-2026-08-04.1 · SHA-256 0f95dda9ce25cfc2…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
审查日期 2026年8月4日
将此产品直接导入你的 AI IDE、网页构建器或云端 IDE。
将 Tetrees 连接到兼容的 AI IDE,列出你拥有的产品并获取已验证 ZIP,同时不会开放卖家上传权限。
暂无评价。
Sign in to join the discussion
Loading discussion…
.envBREVO_API_KEY=xkeysib-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
import { TransactionalEmailsApi, SendSmtpEmail, ContactsApi, CreateContact } from './brevo/api';
const emailApi = new TransactionalEmailsApi();
emailApi.authentications['apiKey'].apiKey = process.env.BREVO_API_KEY!;
TransactionalEmailsApiclass TransactionalEmailsApi {
authentications: { apiKey: { apiKey: string } };
sendTransacEmail(sendSmtpEmail: SendSmtpEmail): Promise<{ body: { messageId: string } }>;
}
Use this to send individual transactional emails—password resets, order confirmations, OTP messages. Instantiate once, set authentications.apiKey.apiKey, then call sendTransacEmail with a populated SendSmtpEmail model.
ContactsApiclass ContactsApi {
authentications: { apiKey: { apiKey: string } };
createContact(createContact: CreateContact): Promise<{ body: { id: number } }>;
getContactInfo(identifier: string): Promise<{ body: object }>;
}
Use this to create and retrieve contacts in your Brevo account. Pair with the CreateContact model to set email, attributes (first name, last name, etc.), and list membership.
RequestOptions (from requestCompat.ts)export interface RequestOptions {
method?: string;
url?: string;
uri?: string;
params?: any;
headers?: any;
data?: any;
form?: any;
formData?: any;
useQuerystring?: boolean;
json?: boolean;
body?: any;
auth?: { username: string; password: string };
qs?: any;
encoding?: any;
}
Used internally by the SDK's HTTP layer. Relevant only if you are extending or patching request behavior; most integrations never touch this directly.
IncomingMessage (from requestCompat.ts)class IncomingMessage extends HttpIncomingMessage {
statusCode?: number;
statusMessage?: string;
constructor(res: AxiosResponse): void;
}
An Axios-compatible shim for Node's http.IncomingMessage. The SDK uses this internally to normalize HTTP responses. Surface this only if you need to inspect raw response metadata.
A user triggers a password reset. Your backend calls Brevo to deliver the email immediately.
import { TransactionalEmailsApi, SendSmtpEmail } from './brevo/api';
const emailApi = new TransactionalEmailsApi();
emailApi.authentications['apiKey'].apiKey = process.env.BREVO_API_KEY!;
async function sendPasswordReset(toEmail: string, toName: string, resetLink: string) {
const message = new SendSmtpEmail();
message.subject = 'Reset your password';
message.htmlContent = `<p>Click <a href="${resetLink}">here</a> to reset your password.</p>`;
message.sender = { name: 'My App', email: 'user@example.com' };
message.to = [{ email: toEmail, name: toName }];
try {
const res = await emailApi.sendTransacEmail(message);
console.log('Sent, messageId:', res.body.messageId);
} catch (err: any) {
console.error('Send failed:', err.body ?? err.message);
}
}
sendPasswordReset('alice@example.com', 'Alice', 'https://myapp.com/reset?token=abc123');
A new user signs up. You add them to Brevo with their name and assign them to a list.
import { ContactsApi, CreateContact } from './brevo/api';
const contactApi = new ContactsApi();
contactApi.authentications['apiKey'].apiKey = process.env.BREVO_API_KEY!;
async function registerContact(email: string, firstName: string, lastName: string, listId: number) {
const contact = new CreateContact();
contact.email = email;
contact.attributes = {
FIRSTNAME: firstName,
LASTNAME: lastName,
};
contact.listIds = [listId];
contact.updateEnabled = true; // upsert behavior
try {
const res = await contactApi.createContact(contact);
console.log('Contact created, id:', res.body.id);
} catch (err: any) {
console.error('Contact creation failed:', err.body ?? err.message);
}
}
registerContact('bob@example.com', 'Bob', 'Smith', 3);
A 2FA code needs to be delivered via SMS to a phone number.
import { TransactionalSMSApi, SendTransacSms } from './brevo/api';
const smsApi = new TransactionalSMSApi();
smsApi.authentications['apiKey'].apiKey = process.env.BREVO_API_KEY!;
async function send2FACode(phone: string, code: string) {
const sms = new SendTransacSms();
sms.sender = 'MyApp';
sms.recipient = phone; // E.164 format: +14155552671
sms.content = `Your verification code is: ${code}`;
sms.type = SendTransacSms.TypeEnum.Transactional;
try {
const res = await smsApi.sendTransacSms(sms);
console.log('SMS sent:', JSON.stringify(res.body));
} catch (err: any) {
console.error('SMS failed:', err.body ?? err.message);
}
}
send2FACode('+14155552671', '847201');
api.ts - Single re-export barrel; import all API clients and models from here.requestCompat.ts - Axios adapter and IncomingMessage shim; provides the HTTP transport layer the generated API clients rely on internally.api/apis.ts - Barrel that re-exports every individual API class from the api/ directory.api/transactionalEmailsApi.ts - API client for sending and managing transactional emails.api/contactsApi.ts - API client for creating, updating, and querying contacts and lists.api/transactionalSMSApi.ts - API client for sending transactional SMS messages.api/webhooksApi.ts - API client for registering and managing Brevo webhooks.api/ecommerceApi.ts - API client for ecommerce tracking events, carts, and orders.api/emailCampaignsApi.ts - API client for creating and sending bulk email campaigns.api/sMSCampaignsApi.ts - API client for bulk SMS campaign management.api/companiesApi.ts - API client for CRM company records.api/dealsApi.ts - API client for CRM deal pipeline management.api/conversationsApi.ts - API client for the Brevo Conversations (live chat) product.model/ - All DTO classes (e.g., SendSmtpEmail, CreateContact) used as typed request/response bodies.tsconfig.json - TypeScript config for the SDK itself; reference when resolving compile errors.package.json - Lists axios, bluebird, and rewire as runtime dependencies.authentications key mismatch: The key must be 'apiKey' (string literal index), not a dot-access property; use api.authentications['apiKey'].apiKey = ....Cannot use import statement): Ensure "esModuleInterop": true and "module": "commonjs" in tsconfig.json; the SDK is CJS-first.skipLibCheck: false causes deep type errors: The SDK has some loose internal types; set "skipLibCheck": true to avoid cascading errors from node_modules and vendored source.axios at runtime: axios must be installed in your project's own node_modules, not assumed to be present; run npm install axios explicitly.bluebird not found: Some internal SDK paths reference bluebird; install it even if you are using native Promise in your own code.authentications objects; the key is stored in plaintext on the instance; load exclusively from environment variables.I have a vendored copy of the Brevo Node.js SDK v3 (upstream: @getbrevo/brevo@3.0.1)
located at src/brevo/ in my project. The USAGE.md file at the project root describes
all available exports, setup steps, and working examples.
Please help me integrate the Brevo SDK into my project step by step:
1. Read USAGE.md and src/brevo/api.ts to understand the available API clients and models.
2. Identify the Brevo features I need: [DESCRIBE YOUR USE CASE, e.g., "send transactional
emails and create contacts"].
3. Add any missing dependencies from USAGE.md to my package.json using npm install.
4. Create a service module (e.g., src/services/brevo.ts) that initializes the relevant
API clients using an environment variable BREVO_API_KEY.
5. Implement typed wrapper functions for each operation I need, importing only from
src/brevo/api.ts.
6. Show me how to call these functions from my existing [Express route / handler /
serverless function].
7. Add error handling that surfaces err.body when available (Brevo API errors) and
falls back to err.message.
Do not install @getbrevo/brevo from npm. Import exclusively from the local path src/brevo/api.
The SDK source is distributed under the MIT license; see source/LICENSE.md for the full text. Upstream package: @getbrevo/brevo v3.0.1, maintained by Brevo. Note that v3.x is in security-only maintenance mode; the actively developed version is brevo-node v5.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
完整安装指南与集成提示词将在购买后解锁。
Automation, Utilities & Developer Tools
免费