Swift Vapor SDK for Brevo
Generated from the Brevo API OpenAPI specification using Swift OpenAPI Generator.
See the Brevo API docs for more information on how to use the API.
Add the package dependency in your Package.swift:
.package(url: "https://github.com/telemetryDeck/brevo-kit", from: "1.0.0"),Next, in your target, add BrevoKit to your dependencies:
.target(name: "MyTarget", dependencies: [
.product(name: "BrevoKit", package: "brevo-kit"),
]),Get an API key from your Brevo account here: https://app.brevo.com/settings/keys/api
Init with API Key:
let brevo: Brevo = try Brevo(apiKey: "xkeysib-...", sandbox: false)TODO: Setup with Vapor.
Send an email with defined content:
try await brevo.email.send(
from: .init(email: "root@eruditorium.org", name: "Enoch Root"),
to: [.init(email: "hello@example.com")],
subject: "Hello World",
htmlContent: nil,
textContent: "Hello World!"
)Send an email with a template:
try await brevo.email.send(
to: [.init(email: "hello@example.com")],
templateID: 1,
parameters: ["name": "Daniel"],
tags: ["test", "brevo-kit"]
)To update the generated code from the OpenAPI specification, you can use the generate-code-from-openapi plugin provided by Apple, take these steps:
- Download a new version of the Brevo API OpenAPI specification, place it into
openapi.yml - Uncomment the
swift-openapi-generatorpackage dependency inPackage.swift - Run
swift package plugin generate-code-from-openapi --target BrevoKit
If an error occurs, try deleting the .build directory.