First API Call

Let’s make your first API call to verify your Brevo API setup is working correctly.

Prerequisites

  • A Brevo account
  • An API key from your dashboard
  • A tool for making HTTP requests (curl, Postman, or similar)

Get Account Information

The simplest first call is to get your account information:

Using cURL

Terminal window
curl -X GET "https://api.brevo.com/v3/account" \
-H "Accept: application/json" \
-H "api-key: YOUR_API_KEY"

Using JavaScript (Node.js)

const fetch = require('node-fetch');
const getAccount = async () => {
try {
const response = await fetch('https://api.brevo.com/v3/account', {
method: 'GET',
headers: {
'Accept': 'application/json',
'api-key': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log('Account Info:', data);
} catch (error) {
console.error('Error:', error);
}
};
getAccount();

Using Python

import requests
url = "https://api.brevo.com/v3/account"
headers = {
"Accept": "application/json",
"api-key": "YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
print(response.json())

Using PHP

<?php
$url = 'https://api.brevo.com/v3/account';
$headers = [
'Accept: application/json',
'api-key: YOUR_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>

Expected Response

If successful, you’ll receive a response like this:

{
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe",
"companyName": "Your Company",
"address": {
"street": "123 Main Street",
"city": "New York",
"zipCode": "10001",
"country": "United States"
},
"plan": [
{
"type": "payAsYouGo",
"credits": 10000,
"creditsUsed": 1500
}
]
}

Error Handling

If you encounter errors, check these common issues:

Invalid API Key (401 Unauthorized)

{
"code": "unauthorized",
"message": "Invalid API key provided"
}

Solution: Verify your API key is correct and has the proper permissions.

Rate Limit Exceeded (429 Too Many Requests)

{
"code": "too_many_requests",
"message": "Rate limit exceeded"
}

Solution: Wait before making another request or upgrade your plan.

Server Error (500 Internal Server Error)

{
"code": "internal_error",
"message": "An internal error occurred"
}

Solution: Check our status page or contact support.

Next Steps

Now that you’ve made your first successful API call:

  1. Set up authentication properly
  2. Install an SDK for your language
  3. Learn about rate limits
  4. Explore email endpoints
مساعد AI

مرحباً! اسألني أي شيء عن الوثائق.

ابدأ مجانًا مع Brevo