### Install Test Server Dependencies and Start Source: https://developers.brevo.com/docs/oauth-quickstart Navigate to the generated app directory, install the test server's Node.js dependencies, and start the local OAuth test server. ```bash cd my-app npm --prefix src/oauth install brevo app start oauth ``` -------------------------------- ### Brevo Test Server Startup Example Source: https://developers.brevo.com/docs/oauth-quickstart Example output indicating that the test server is starting and has opened the browser to the specified local development URL. ```text Starting oauth... Test server running at http://localhost:3009 Opening browser... ``` -------------------------------- ### General Setup Source: https://developers.brevo.com/docs/javascript-api-reference Basic example of setting up the `window.BrevoConversationsSetup` object with various configuration options. ```APIDOC ## General Setup Settings are defined via the `window.BrevoConversationsSetup` object **before** the widget code, for example: ```html ``` ``` -------------------------------- ### Start Local OAuth Test Server Source: https://developers.brevo.com/docs/integrating-oauth-20-to-your-solution Navigate to the generated app directory, install its dependencies, and start the local test server. This will open your browser to initiate the OAuth flow. ```bash $| cd my-app ---|--- $| npm --prefix src/oauth install $| brevo app start oauth ``` ```text Starting oauth... --- Test server running at http://localhost:3009 Opening browser... ``` -------------------------------- ### Initialize a new Brevo application Source: https://developers.brevo.com/docs/cli-reference The `brevo app init` command provides a guided setup process for authenticating, creating a new app, and scaffolding starter code. It is recommended for first-time setup. For automated workflows, consider using `brevo app create` with flags. ```APIDOC ## `brevo app init` ### Description Guided setup to authenticate, create an app, and scaffold starter code. ### Usage ```bash brevo app init ``` ### Parameters This command does not accept any flags. It prompts the user for the following information: - App name - Distribution type - Redirect URL - Output directory ### Example ```bash brevo app init ``` ### Notes Use this command for initial setup. For scripted or automated flows, use `brevo app create` with flags. ``` -------------------------------- ### Create Domain using Brevo SDK (Python) Source: https://developers.brevo.com/reference/create-domain This Python example demonstrates how to create a domain using the Brevo SDK. Remember to install the SDK and substitute 'YOUR_API_KEY_HERE' with your Brevo API key. ```python from brevo import Brevo client = Brevo( api_key="YOUR_API_KEY_HERE", ) client.domains.create_domain() ``` -------------------------------- ### Create Test Domain using PHP SDK Source: https://developers.brevo.com/reference/create-domain Implement domain creation using the Brevo PHP SDK. This example demonstrates the necessary setup and function call. ```php domains->createDomain( new CreateDomainRequest([ 'name' => 'test.example.com', ]), ); ``` -------------------------------- ### Start OAuth Test Server Source: https://developers.brevo.com/docs/cli-reference Starts the OAuth test server locally. Ensure dependencies are installed first. The server can be configured to run on a custom port. ```bash npm --prefix src/oauth install # or: yarn --cwd src/oauth install ``` ```bash brevo app start oauth ``` ```bash brevo app start oauth --port 3000 ``` -------------------------------- ### Create Domain using Brevo PHP SDK Source: https://developers.brevo.com/reference/create-domain Example of creating a domain with the Brevo PHP SDK. This requires the Brevo SDK to be installed and configured with your API key. ```php domains->createDomain( new CreateDomainRequest([ 'name' => 'mycompany.com', ]), ); ``` -------------------------------- ### Make a Basic API Call (Account Info) Source: https://developers.brevo.com/docs/getting-started Example of making a GET request to the /account endpoint using cURL. Replace YOUR_API_KEY with your actual Brevo API key. This demonstrates basic authentication. ```bash curl -X GET https://api.brevo.com/v3/account \ -H "api-key: YOUR_API_KEY" ``` -------------------------------- ### Create Voucher using Brevo Python SDK Source: https://developers.brevo.com/reference/create-voucher Use the Brevo Python SDK to create a voucher. This example requires the SDK to be installed and authenticated with your API key. ```python from brevo import Brevo client = Brevo( api_key="YOUR_API_KEY_HERE", ) client.reward.create_voucher( pid="pid", reward_id="string", ) ``` -------------------------------- ### Get all folders Source: https://developers.brevo.com/reference/get-folders This example demonstrates how to retrieve all folders using the Brevo API client. It shows the basic setup and the call to the `getFolders` method. ```APIDOC ## GET /v3/contacts/folders ### Description Retrieves a list of all folders in your Brevo account. ### Method GET ### Endpoint https://api.brevo.com/v3/contacts/folders ### Query Parameters - **limit** (long) - Optional - Number of documents per page. Defaults to `10`. Maximum value is `50`. - **offset** (long) - Optional - Index of the first document of the page. Defaults to `0`. - **sort** (enum) - Optional - Sort the results in the ascending/descending order of record creation. Default order is `desc`. Allowed values: `asc`, `desc`. ### Authentication api-keystring The API key should be passed in the request headers as `api-key` for authentication. ### Response #### Success Response (200) - **count** (long) - Number of folders available in your account. - **folders** (list of objects) - A list of folder objects, each containing: - **id** (integer) - The unique identifier for the folder. - **name** (string) - The name of the folder. - **totalBlacklisted** (integer) - The total number of blacklisted contacts in the folder (deprecated, will default to 0). - **totalSubscribers** (integer) - The total number of subscribers in the folder (deprecated, will default to 0). - **uniqueSubscribers** (integer) - The number of unique subscribers in the folder (deprecated). ### Request Example ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.contacts.getFolders({}); } main(); ``` ### Response Example ```json { "count": 2, "folders": [ { "id": 42, "name": "Ninja_Form", "totalBlacklisted": 98, "totalSubscribers": 4567, "uniqueSubscribers": 4665 }, { "id": 29, "name": "Prestashop", "totalBlacklisted": 10, "totalSubscribers": 6543, "uniqueSubscribers": 6553 } ] } ``` ### Errors - **400** - Bad Request Error ``` -------------------------------- ### Get all segments Source: https://developers.brevo.com/reference/getsegments This example demonstrates how to retrieve all contact segments using the Brevo API client. It shows the basic setup with an API key and a call to the `getSegments` method. ```APIDOC ## GET /v3/contacts/segments ### Description Retrieve all contact segments defined in your Brevo account with support for pagination and sorting. Results default to 10 segments per page (maximum 50) sorted in descending order of creation. Each segment includes its ID, name, category name, and last update timestamp. ### Method GET ### Endpoint https://api.brevo.com/v3/contacts/segments ### Query Parameters #### limit - **limit** (long) - Optional - Defaults to `10`. Number of documents per page (0-50). #### offset - **offset** (long) - Optional - Defaults to `0`. Index of the first document of the page. #### sort - **sort** (enum) - Optional - Defaults to `desc`. Sort the results in the ascending/descending order of record creation. Allowed values: `asc`, `desc`. ### Request Example (No request body for GET request) ### Response #### Success Response (200) - **count** (long) - Number of Segments in your account. - **segments** (list of objects) - Listing of all the segments available in your account. - **categoryName** (string) - **id** (integer) - **segmentName** (string) - **updatedAt** (string, date-time) #### Response Example ```json { "count": 2, "segments": [ { "categoryName": "Name1", "id": 53, "segmentName": "Segment1", "updatedAt": "2017-03-12T12:30:00Z" }, { "categoryName": "Name2", "id": 50, "segmentName": "Segment2", "updatedAt": "2017-03-12T12:30:00Z" } ] } ``` ### Errors #### 400 Bad Request Error ``` -------------------------------- ### Brevo CLI App Initialization Example Source: https://developers.brevo.com/docs/oauth-quickstart Example output of the `brevo app init` command, detailing the app configuration including name, ID, client ID, scopes, and redirect URL. ```text Brevo CLI — Quick Setup ────────────────────────────────────── ✓ Already authenticated. Step 2: Create your first OAuth app ? App name: my-app ? Distribution type? Private (Used exclusively by your organisation) ? OAuth callback URL — where users are sent after authorizing your app: http://localhost:3009/auth/callback ? Add another redirect URL? No ✓ App created. App name: my-app App ID: e22eb778-a2a8-488a-a5e8-466b6dad9385 Client ID: 8768a0ad5801806c7946ca7c29648cc2 Client secret: [hidden — run `brevo app credentials --reveal-secret`] Scopes: contacts:read, contacts:write, crm:read, crm:write Redirect URL 1: http://localhost:3009/auth/callback → To change scopes, run: brevo app available-scopes brevo app update --scope ? Generate starter code now? Yes ? Output directory: ./my-app ✓ Test app scaffolded (11 files) ├── src/ │ └── oauth/ │ ├── .env.example │ ├── .env.local ← credentials written here (gitignored) │ ├── handler.js ← OAuth routes │ ├── package.json │ ├── server.js ← test server entry point │ └── token-store.js ├── .gitignore ├── app-config.json ← app metadata ├── AGENTS.md ├── CLAUDE.md └── README.md ``` -------------------------------- ### Get all lists - Response Example Source: https://developers.brevo.com/reference/get-lists?explorer=true This is an example of the JSON response when successfully retrieving all contact lists. It includes the count of lists and details for each list. ```json { "count": 2, "lists": [ { "id": 53, "name": "Spanish_Speakers", "totalBlacklisted": 65, "totalSubscribers": 5432, "uniqueSubscribers": 5497, "folderId": 1 }, { "id": 50, "name": "Other", "totalBlacklisted": 765, "totalSubscribers": 10976, "uniqueSubscribers": 11741, "folderId": 2 } ] } ``` -------------------------------- ### Example 200 Response for Get Orders Source: https://developers.brevo.com/reference/get-orders This is an example of a successful response when fetching orders, showing the structure of the order data returned by the API. ```json { "count": 1, "orders": [ { "amount": 2000, "billing": { "address": "Sec 62, Noida", "city": "Noida", "country": "India", "countryCode": "IN", "paymentMethod": "Net banking", "phone": 9238283982, "postCode": 110001, "region": "North India" }, "contact_id": 2, "coupons": [ "flat50", "flat40" ], "createdAt": "2021-12-31T11:42:35.638Z", "email": "testvisitor@sendinblue.com", "id": "order1803", "identifiers": { "ext_id": "ab12", "loyalty_subscription_id": "1234" }, "products": [ { "price": 100, "productId": 21, "quantity": 2, "quantityFloat": 0, "variantId": "P100" }, { "price": 100, "productId": 21, "quantity": 0, "quantityFloat": 2.52, "variantId": "P15756" } ], "status": "complete", "storeId": "123", "updatedAt": "2022-03-03T14:48:31.867Z" } ] } ``` -------------------------------- ### Get Webhook Details in TypeScript Source: https://developers.brevo.com/reference/get-webhook Use this to get complete webhook configuration and settings. Ensure you have the Brevo SDK installed and your API key configured. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.webhooks.getWebhook(1); } main(); ``` -------------------------------- ### Create New Loyalty Program using HTTP POST (Go) Source: https://developers.brevo.com/reference/create-new-lp This Go example shows how to make a direct HTTP POST request to create a new loyalty program. It includes setting the API key and content type headers. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.brevo.com/v3/loyalty/config/programs" payload := strings.NewReader("{\n \"name\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Example Response for Get All Ecommerce Categories Source: https://developers.brevo.com/reference/get-categories?explorer=true This is an example of a successful response when retrieving all ecommerce categories. It includes a list of categories with their details and a total count. ```json { "categories": [ { "createdAt": "2021-12-31T11:42:35.638Z", "id": "C19", "isDeleted": true, "modifiedAt": "2022-03-03T14:48:31.867Z", "name": "Food", "url": "http://mydomain.com/category/food" }, { "createdAt": "2021-12-31T11:42:35.638Z", "id": "C20", "isDeleted": true, "modifiedAt": "2022-03-03T14:48:31.867Z", "name": "clothing", "url": "http://mydomain.com/category/clothing" } ], "count": 2 } ``` -------------------------------- ### Install Node.js SDK Source: https://developers.brevo.com/docs/getting-started Install the official Node.js SDK for Brevo to interact with the API. This is the first step for Node.js developers. ```bash npm install @getbrevo/brevo ``` -------------------------------- ### Initialize a new Brevo App Source: https://developers.brevo.com/docs/cli-reference Use `brevo app init` for a guided, first-time setup of a new Brevo OAuth app. This command prompts for necessary details like app name, distribution type, and redirect URL. ```bash brevo app init ``` -------------------------------- ### Example Response for Get Sub-Account Groups Source: https://developers.brevo.com/reference/get-sub-account-groups This is an example of the JSON response you will receive when successfully retrieving the list of sub-account groups. Each group includes its name and a unique ID. ```json [ { "groupName": "My group 1", "id": "d3b142c709d6ed67ef1cd903" }, { "groupName": "My group 2", "id": "a5b192a709d6ed67ef8fd922" }, { "groupName": "My group 3", "id": "bbb142c709d6ed67ef1cd910" } ] ``` -------------------------------- ### Brevo CLI Login Prompt Example Source: https://developers.brevo.com/docs/oauth-quickstart Example output of the `brevo login` command, showing the browser authentication choice and confirmation of saved credentials. ```text Welcome to Brevo CLI ────────────────────────────────────── ? How would you like to authenticate? Browser (sign in through your browser) Opening your browser to log you in... Waiting for login to complete (Ctrl+C to cancel)... ✓ Login complete. Credentials saved to /Users/you/.brevo/credentials.json. ✓ Authenticated as you@example.com ``` -------------------------------- ### Example Response for Get Products Source: https://developers.brevo.com/reference/get-products?explorer=true This is an example of a successful response when retrieving ecommerce products. It includes product details such as creation date, ID, name, price, and stock. ```json { "count": 2, "products": [ { "createdAt": "2022-06-30T10:29:16.078Z", "id": "7498033266862", "modifiedAt": "2022-06-30T10:29:16.078Z", "name": "Alpina Panoma Classic", "s3ThumbAnalytics": "https://img-ecom.mailinblue.com/path-to-analytics/img.jpg", "s3ThumbEditor": "https://img-ecom.mailinblue.com/path-to-editor/img.jpg", "categories": [ "279638835374", "279502848174" ], "imageUrl": "http://mydomain.com/product-absoulte-url/img.jpeg", "isDeleted": true, "price": 49.95, "alternativePrice": 39.95, "s3Original": "https://img-ecom.mailinblue.com/path-to-original/img.jpg", "sku": "186622-9", "stock": 100, "url": "https://mydomain.com/products/alpina-panoma-classic" }, { "createdAt": "2022-06-30T10:29:16.078Z", "id": "7498033266862", "modifiedAt": "2022-06-30T10:29:16.078Z", "name": "Alpina Panoma Classic2", "s3ThumbAnalytics": "https://img-ecom.mailinblue.com/path-to-analytics/img.jpg", "s3ThumbEditor": "https://img-ecom.mailinblue.com/path-to-editor/img.jpg", "categories": [ "2d79638835374", "27d9502848174" ], "imageUrl": "http://mydomain.com/product-absoulte-url/img.jpeg", "isDeleted": true, "metaInfo": { "brand": "addidas", "description": "Shoes for sports" }, "price": 49.95, "alternativePrice": 44.95, "s3Original": "https://img-ecom.mailinblue.com/path-to-original/img.jpg", "sku": "186622-9", "stock": 350, "url": "https://mydomain.com/products/alpina-panoma-classic2" } ] } ``` -------------------------------- ### Create Coupons via HTTP POST (Go) Source: https://developers.brevo.com/reference/create-coupons This Go example demonstrates creating coupons by making a direct HTTP POST request to the Brevo API. It includes setting the API key and content type headers. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.brevo.com/v3/coupons" payload := strings.NewReader("{\n \"collectionId\": \"23befbae-1505-47a8-bd27-e30ef739f32c\",\n \"coupons\": [\n \"Uf12AF\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Voucher for a Contact Source: https://developers.brevo.com/reference/get-voucher-for-a-contact This example demonstrates how to retrieve vouchers for a given contact using the Brevo SDK. ```APIDOC ## GET /v3/loyalty/offer/programs/:pid/vouchers ### Description Retrieves a list of vouchers for a specific contact within a loyalty program. ### Method GET ### Endpoint https://api.brevo.com/v3/loyalty/offer/programs/:pid/vouchers ### Parameters #### Path Parameters - **pid** (string) - Required - Loyalty Program ID (`format: "uuid"`) #### Query Parameters - **limit** (integer) - Optional - Page size (`1-100`). Defaults to `25`. - **offset** (integer) - Optional - Pagination offset. Defaults to `0`. - **sort** (enum) - Optional - Sort order. Allowed values: `asc`, `desc`. Defaults to `desc`. - **sortField** (enum) - Optional - Sort field. Allowed values: `updatedAt`, `createdAt`. Defaults to `updatedAt`. - **contactId** (integer) - Required - Contact ID (`>=1`). - **metadata_key_val** (string) - Optional - Metadata value for a Key filter. - **rewardId** (string) - Optional - Reward ID. ### Response #### Success Response (200) - **contactId** (long) - Contact id associated with the current reward. - **contactRewards** (list of objects) - List of all the rewards for current contact. - **code** (string) - **consumedAt** (string) - **createdAt** (string) - **expirationDate** (string) - **id** (string) - **meta** (object) - **rewardId** (string) - **unit** (string) - **updatedAt** (string) - **value** (number) - **validFrom** (string) - **count** (integer) - Count of the rewards associated with the current contact. - **loyaltyProgramId** (string) - Loyalty Program Id for the contact. - **loyaltySubscriptionId** (string) - Loyalty Subscription Id for the contact. ### Request Example ```json { "example": "request body" } ``` ### Response Example ```json { "contactId": 1, "contactRewards": [ { "code": "string", "consumedAt": "string", "createdAt": "string", "expirationDate": "string", "id": "string", "meta": {}, "rewardId": "string", "unit": "string", "updatedAt": "string", "value": 1.1, "validFrom": "2024-01-15T09:30:00Z" } ], "count": 1, "loyaltyProgramId": "string", "loyaltySubscriptionId": "string" } ``` ### Errors - **401** - Unauthorized Error - **403** - Forbidden Error - **404** - Not Found Error - **422** - Unprocessable Entity Error - **500** - Internal Server Error ``` -------------------------------- ### Example 200 Response for Get Coupon Collection Source: https://developers.brevo.com/reference/get-coupon-collection?explorer=true This is an example of a successful response when retrieving a coupon collection. It includes details like creation date, default coupon, ID, name, and remaining/total coupon counts. ```JSON { "0": { "createdAt": "2017-03-12T12:30:00Z", "defaultCoupon": "10 OFF", "id": "23befbae-1505-47a8-bd27-e30ef739f32c", "name": "Summer", "remainingCoupons": 5000, "totalCoupons": 10000 }, "createdAt": "2023-01-06T05:03:47.053000000Z", "defaultCoupon": "10 OFF", "id": "23befbae-1505-47a8-bd27-e30ef739f32c", "name": "SummerPromotions", "remainingCoupons": 5000, "totalCoupons": 10000 } ``` -------------------------------- ### Create Subdomain using HTTP POST (Go) Source: https://developers.brevo.com/reference/create-domain This Go example shows how to create a subdomain by making a direct HTTP POST request to the Brevo API. It includes setting the API key and content type headers. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.brevo.com/v3/senders/domains" payload := strings.NewReader("{\n \"name\": \"newsletter.mycompany.com\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Create Subscription Balances using Go HTTP Client Source: https://developers.brevo.com/reference/create-subscription-balances This Go code demonstrates how to make a POST request to create subscription balances using the standard net/http package. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.brevo.com/v3/loyalty/balance/programs/pid/subscriptions/cid/balances" payload := strings.NewReader("{\n \"balanceDefinitionId\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Example Response for Get Folder Lists Source: https://developers.brevo.com/reference/get-folder-lists This is an example of a successful response (200 OK) when retrieving lists from a folder. It includes the total count of lists and an array of list objects, each detailing its ID, name, and subscriber counts. ```json { "count": 3, "lists": [ { "id": 46, "name": "Reactiv", "totalBlacklisted": 0, "totalSubscribers": 7655, "uniqueSubscribers": 7655 }, { "id": 41, "name": "NY_Area", "totalBlacklisted": 23, "totalSubscribers": 3654, "uniqueSubscribers": 3677 }, { "id": 22, "name": "VIP_Customer", "totalBlacklisted": 72, "totalSubscribers": 8753, "uniqueSubscribers": 8826 } ] } ``` -------------------------------- ### Get All Orders - TypeScript Source: https://developers.brevo.com/reference/get-orders Use this snippet to retrieve a list of all orders. Ensure you have your API key and the Brevo client library installed. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.ecommerce.getOrders({}); } main(); ``` -------------------------------- ### Create Company using Brevo SDK (PHP) Source: https://developers.brevo.com/reference/create-a-company This example demonstrates creating a company using the Brevo PHP SDK. It requires instantiating the Brevo client with your API key. ```php companies->createACompany( new PostCompaniesRequest([ 'name' => 'company', ]), ); ``` -------------------------------- ### Create Domain using Brevo SDK (PHP) Source: https://developers.brevo.com/reference/create-domain This PHP snippet shows how to initiate domain creation with the Brevo SDK. Replace 'YOUR_API_KEY_HERE' with your valid API key before execution. ```php domains->createDomain( new CreateDomainRequest([]), ); ``` -------------------------------- ### Get Loyalty Program List Source: https://developers.brevo.com/reference/get-lp-list Fetches a list of all loyalty programs. You can control the number of results, the starting index, and the sorting order. ```APIDOC ## GET /v3/loyalty/config/programs ### Description Returns a list of loyalty programs. ### Method GET ### Endpoint https://api.brevo.com/v3/loyalty/config/programs ### Query Parameters - **limit** (integer) - Optional - Number of documents per page - **offset** (integer) - Optional - Index of the first document in the page - **sort_field** (enum) - Optional - Sort documents by field. Allowed values: name, created_at, updated_at - **sort** (enum) - Optional - Sort order. Allowed values: asc, desc ### Response #### Success Response (200) Loyalty Program page - **items** (list of objects) - Loyalty Program list ### Response Example ```json { "items": [ { "id": "string", "name": "string", "description": "string", "meta": {}, "state": "inactive", "subscriptionPoolId": "string", "subscriptionGeneratorId": "string", "pattern": "string", "codeCount": 1, "documentId": "string", "birthdayAttribute": "string", "createdAt": "2024-01-15T09:30:00Z", "updatedAt": "2024-01-15T09:30:00Z" } ] } ``` ### Errors - **400** - Bad Request Error - **401** - Unauthorized Error - **403** - Forbidden Error - **404** - Not Found Error - **422** - Unprocessable Entity Error - **500** - Internal Server Error ``` -------------------------------- ### Get All Companies Source: https://developers.brevo.com/reference/get-all-companies Use this snippet to retrieve all companies from your Brevo account. Ensure you have your API key and have installed the Brevo client library. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.companies.getAllCompanies({}); } main(); ``` -------------------------------- ### Create Subscription Balances using Brevo Python SDK Source: https://developers.brevo.com/reference/create-subscription-balances Use the Brevo Python SDK to create subscription balances. Initialize the client with your API key. ```python from brevo import Brevo client = Brevo( api_key="YOUR_API_KEY_HERE", ) client.balance.create_subscription_balances( pid="pid", cid="cid", balance_definition_id="string", ) ``` -------------------------------- ### Get Deal Attributes using BrevoClient Source: https://developers.brevo.com/reference/get-deal-attributes Use the BrevoClient to fetch all deal attributes. Ensure you have your API key and the necessary SDK installed. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.deals.getDealAttributes(); } main(); ``` -------------------------------- ### Create Product Alert (Direct HTTP POST - Ruby) Source: https://developers.brevo.com/reference/create-product-alert This Ruby example demonstrates how to create a product alert by making a direct HTTP POST request to the Brevo API. Ensure your API key is correctly set. ```ruby require 'uri' require 'net/http' url = URI("https://api.brevo.com/v3/products/id/alerts/back_in_stock") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Get All Notes Source: https://developers.brevo.com/reference/get-all-notes This TypeScript snippet demonstrates how to use the Brevo SDK to retrieve all CRM notes. Ensure you have your API key and the SDK installed. ```TypeScript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.notes.getAllNotes({}); } main(); ``` -------------------------------- ### Create Domain using Brevo Python SDK Source: https://developers.brevo.com/reference/create-domain Shows how to create a domain using the Brevo Python SDK. Replace 'YOUR_API_KEY_HERE' with your actual Brevo API key. ```python from brevo import Brevo client = Brevo( api_key="YOUR_API_KEY_HERE", ) client.domains.create_domain( name="mycompany.com", ) ``` -------------------------------- ### Install Node.js SDK Beta Source: https://developers.brevo.com/changelog/2026/2/11 Use these npm commands to install the beta version of the Node.js SDK. The first command installs the specific beta version, while the second installs the latest pre-release version. ```bash npm install @getbrevo/brevo@^4.0.1 ``` ```bash npm install @getbrevo/brevo@^next ``` -------------------------------- ### Get Active Balances API in TypeScript Source: https://developers.brevo.com/reference/get-active-balances-api Use this TypeScript snippet to call the Get Active Balances API. Ensure you have the BrevoClient initialized with your API key. This example demonstrates how to fetch active balances for a given contact and balance definition within a loyalty program. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.balance.getActiveBalancesApi("pid", { contactId: 1, balanceDefinitionId: "balanceDefinitionId", }); } main(); ``` -------------------------------- ### Get All Ecommerce Categories Source: https://developers.brevo.com/reference/get-categories Use this snippet to fetch all ecommerce categories from your Brevo account. Ensure you have your API key and the Brevo client library installed. ```TypeScript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.ecommerce.getCategories({}); } main(); ``` -------------------------------- ### Create Coupons using Brevo SDK (PHP) Source: https://developers.brevo.com/reference/create-coupons This PHP example shows how to create coupons using the Brevo SDK. Ensure the Brevo client is instantiated with your API key. ```php coupons->createCoupons( new CreateCouponsRequest([ 'collectionId' => '23befbae-1505-47a8-bd27-e30ef739f32c', 'coupons' => [ 'Uf12AF', ], ]), ); ``` -------------------------------- ### Get all email senders Source: https://developers.brevo.com/reference/get-senders Fetches a list of all email senders associated with your Brevo account. This can be useful for managing your sender configurations and preparing for campaign setup. ```APIDOC ## GET /v3/senders ### Description Retrieves a list of all email senders from your Brevo account with optional filtering. ### Method GET ### Endpoint https://api.brevo.com/v3/senders ### Query Parameters #### Optional Parameters - **ip** (string) - Optional - Filter your senders for a specific IP. Available for dedicated IP usage only. - **domain** (string) - Optional - Filter your senders for a specific domain. ### Authentication api-keystring The API key should be passed in the request headers as `api-key` for authentication. ### Response #### Success Response (200) - **senders** (list of objects) - List of the senders available in your account. ### Response Example ```json { "senders": [ { "active": true, "email": "support@example.com", "id": 1, "ips": [], "name": "Support Team" }, { "active": false, "email": "hello@example.com", "id": 3, "ips": [], "name": "Customer Service" } ] } ``` ### Errors #### 400 Bad Request Error ``` -------------------------------- ### Create Product Alert (Python SDK) Source: https://developers.brevo.com/reference/create-product-alert Create a product alert using the Brevo Python SDK. Initialize the client with your API key before making the call. ```python from brevo import Brevo client = Brevo( api_key="YOUR_API_KEY_HERE", ) client.ecommerce.create_product_alert( id="id", ) ``` -------------------------------- ### Install Python SDK v4 Source: https://developers.brevo.com/changelog/2026/2/23 Install the beta version of the Python SDK using pip. This command installs the necessary package for using the SDK. ```bash pip install brevo-python ``` -------------------------------- ### Get External Feed by UUID in TypeScript Source: https://developers.brevo.com/reference/get-external-feed-by-uuid?explorer=true Use the Brevo SDK to retrieve an external feed by its UUID. Ensure you have the SDK installed and initialized with your API key. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "", }); await client.externalFeeds.getExternalFeedByUuid("b1c2d3e4-f5a6-47b8-89c0-d1e2f3a4b5c6"); } main(); ``` -------------------------------- ### Create Order with Brevo PHP SDK Source: https://developers.brevo.com/reference/create-order This example shows how to create an order using the Brevo PHP SDK. It involves instantiating the Brevo client and passing an Order object. ```php ecommerce->createOrder( new Order([ 'amount' => 308.42, 'createdAt' => '2021-07-29T20:59:23.383Z', 'id' => '14', 'products' => [ new OrderProductsItem([ 'price' => 99.99, 'productId' => 'P1', ]), ], 'status' => 'completed', 'updatedAt' => '2021-07-30T10:59:23.383Z', ]), ); ``` -------------------------------- ### Get Company Attributes Source: https://developers.brevo.com/reference/get-company-attributes Use this TypeScript code to retrieve all company attributes. Ensure you have the Brevo SDK installed and replace 'YOUR_API_KEY_HERE' with your actual API key. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.companies.getCompanyAttributes(); } main(); ``` -------------------------------- ### Create Test Domain using Ruby HTTP Client Source: https://developers.brevo.com/reference/create-domain This Ruby example demonstrates creating a test domain by sending an HTTP POST request to the Brevo API. It configures the request with necessary headers and body. ```ruby require 'uri' require 'net/http' url = URI("https://api.brevo.com/v3/senders/domains") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"test.example.com\"\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Create New Loyalty Program using HTTP POST (Swift) Source: https://developers.brevo.com/reference/create-new-lp This Swift example demonstrates creating a new loyalty program by making an HTTP POST request. It configures headers and sends the JSON payload. ```swift import Foundation let headers = [ "api-key": "", "Content-Type": "application/json" ] let parameters = ["name": "string"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.brevo.com/v3/loyalty/config/programs")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Create API Key for Sub-Account (Go) Source: https://developers.brevo.com/reference/create-an-api-key-for-a-sub-account This Go program demonstrates how to make a POST request to create an API key for a sub-account. It includes setting the API key, content type, and the JSON payload. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.brevo.com/v3/corporate/subAccount/key" payload := strings.NewReader("{\n \"id\": 3232323,\n \"name\": \"My Api Key\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get WhatsApp Account Configuration Source: https://developers.brevo.com/reference/get-whats-app-config Use this TypeScript code to retrieve your WhatsApp API account configuration. Ensure you have your API key and the Brevo client library installed. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.whatsAppCampaigns.getWhatsAppConfig(); } main(); ``` -------------------------------- ### Create Domain via HTTP POST Request (Go) Source: https://developers.brevo.com/reference/create-domain This Go program sends an HTTP POST request to the Brevo API to create a domain. It includes setting the API key and content type headers. Replace '' with your actual API key. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.brevo.com/v3/senders/domains" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get User Permissions Source: https://developers.brevo.com/reference/get-user-permission?explorer=true Use this TypeScript code to fetch the permissions for a specific user by their email address. Ensure you have your API key and the Brevo client library installed. ```typescript import { BrevoClient } from "@getbrevo/brevo"; async function main() { const client = new BrevoClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.user.getUserPermission("email"); } main(); ``` -------------------------------- ### v1.x Brevo Python SDK Account API Example Source: https://developers.brevo.com/guides/python This snippet demonstrates how to instantiate the client and retrieve account information using the v1.x version of the Brevo Python SDK. ```python # v1.x import brevo_python from brevo_python.rest import ApiException configuration = brevo_python.Configuration() configuration.api_key['api-key'] = 'YOUR_API_KEY' api_instance = brevo_python.AccountApi( brevo_python.ApiClient(configuration) ) account = api_instance.get_account() ```