Skip to main content

Crate brevo_v3

Crate brevo_v3 

Source
Expand description

§brevo-v3

An asynchronous, type-safe, and idiomatic Rust client library for the Brevo (Sendinblue) v3 REST API.

§Overview

  • Full API Coverage: All 291 endpoints covering Transactional Emails, SMS, WhatsApp, Contacts, Campaigns, Deals, Companies, Tasks, Webhooks, Inbound Parsing, Ecommerce, and Account Management.
  • Domain Invariants: Strong unforgeable newtypes (Email, PhoneNumber, ContactId, CampaignId, TemplateId, DealId, CompanyId, etc.) following the “Parse, Don’t Validate” philosophy.
  • Async Runtime: Built on tokio (1.x) and reqwest (0.12+ with hyper & rustls).
  • Error Handling: Structured API errors with thiserror and automatic 429 rate limit backoff parsing.
  • Date/Time: Powered by the time crate (0.3) for RFC3339 / ISO8601 formatting.

§Quick Start

use brevo_v3::client::BrevoClient;
use brevo_v3::models::{SendTransacEmailRequest, SendTransacEmailRequestSender, SendTransacEmailRequestToItem};
use brevo_v3::types::Email;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = BrevoClient::new("xkeysib-your-api-key")?;

    let recipient = Email::new("alice@example.com")?;
    let sender = Email::new("notifications@mycompany.com")?;

    let request = SendTransacEmailRequest {
        subject: Some("Order Confirmation".to_string()),
        html_content: Some("<h1>Order Received!</h1>".to_string()),
        sender: Some(SendTransacEmailRequestSender {
            email: Some(sender),
            name: Some("Store Notifications".to_string()),
            id: None,
        }),
        to: Some(vec![SendTransacEmailRequestToItem {
            email: recipient,
            name: Some("Alice".to_string()),
        }]),
        ..Default::default()
    };

    let response = client.transactional_emails().send_transac_email(&request).await?;
    println!("Sent message ID: {:?}", response.message_id);

    Ok(())
}

Re-exports§

pub use client::BrevoClient;
pub use client::BrevoClientBuilder;
pub use client::BrevoConfig;
pub use client::DEFAULT_BASE_URL;
pub use error::Error;
pub use error::Result;
pub use types::*;

Modules§

api
API modules categorized by Brevo domain resources.
client
Core HTTP client, configuration, and request execution logic.
error
Error definitions for the Brevo v3 SDK.
models
Strongly typed Brevo v3 API request and response data models.
types
Strongly-typed domain primitives and unforgeable newtypes.

Macros§

define_id
Macro to define zero-cost, type-safe ID newtypes.