Domain creation and management

Domains are used for authenticating and verifying the senders so that a user knows that the email is being sent from a genuine source. You can check out the endpoints for creating and managing domains at API reference > Domains.

1. Creating a new domain

You can use the endpoint https://api.brevo.com/v3/senders/domainswith the POST method to send a request to the API for creating a new domain. You can use the cURL request below for this endpoint.

curl --request POST \
     --url https://api.brevo.com/v3/senders/domains \
     --header 'accept: application/json' \
     --header 'api-key:' \
     --header 'content-type: application/json' \
     --data '
{
  "name": "mycompany.com"
}
'

You can add your API key in the header api-key above in the cURL request. This endpoint only has one body parameter which is defined in the table below.

AttributeDatatypeDescriptionValue
nameStringName of the domain being created.mydomain.com

Response

You will receive a success response something like this below:

{
  "id": "641db448a6a7ea326e585e15",
  "domain_name": "mycompany.com",
  "message": "Domain added successfully. To authenticate it, add following DNS records",
  "dns_records": {
    "dkim_record": {
      "type": "TXT",
      "value": "k=rsa;p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDeMVIzrCa3T14JsNY0IRv5/2V1/v2itlviLQBwXsa7shBD6TrBkswsFUToPyMRWC9tbR/5ey0nRBH0ZVxp+lsmTxid2Y2z+FApQ6ra2VsXfbJP3HE6wAO0YTVEJt1TmeczhEd2Jiz/fcabIISgXEdSpTYJhb0ct0VJRxcg4c8c7wIDAQAB",
      "host_name": "mail._domainkey.",
      "status": false
    },
    "brevo_code": {
      "type": "TXT",
      "value": "brevo-code:4bc1566441c4131069853d135c5905ab",
      "host_name": "",
      "status": false
    }
  }
}

On the other hand, A bad request response would be something like this:

{
  "code": "invalid_parameter",
  "message": "Enter domain name in correct format. Example: myexampledomain.com"
}

You can view the responses for the request you send below in the table:

Response codeMessageDescription
200Domain createdThis response code is shown when a domain is created
400Bad requestA bad request has been sent to the API endpoint which involves invalid or missing parameters etc.

2. Getting the list of your domains

You can use this endpoint to retrieve created domains. You can use the endpoint https://api.brevo.com/v3/senders/domains using the GET method. You can use the cURL request below

curl --request GET \
     --url https://api.brevo.com/v3/senders/domains \
     --header 'accept: application/json' \
     --header 'api-key: '

πŸ“˜

No attributes for getting the list of your domains

There are no prominent attributes for getting the list of your domains. The request will use your API key and the endpoint to check the domains you have created and it will display them to you in response.


Response

A sample response would return all the domains you have created just like in the below JSON format.

{
  "domains": [
    {
      "id": "641db6b43f10ae7b6604d178",
      "domain_name": "mycompany.com",
      "authenticated": false,
      "verified": false,
      "validationRequest": null,
      "verifier": null,
      "authenticator": null,
      "creator": {
        "id": "63930fe975f3bf52825956b7",
        "email": "[email protected]",
        "method": null,
        "creationDate": "2023-03-24T14:41:56+00:00"
      },
      "ip": null
    }
  ],
  "count": 1,
  "current_page": 1,
  "total_pages": 1
}

Response codes for the endpoint are mentioned below in a table.

Response codeMessageDescription
200List of domainsA valid request displays the list of domains in the response.
400Bad requestA 400 response code is due to a bad request involving incorrect parameters or wrong API key etc.

3. Delete a domain

You can delete a domain by using the endpoint https://api.brevo.com/v3/senders/domains/{domainName} with the DELETE method. You can put the domain name in endpoint URL in the cURL request as shown below.

curl --request DELETE \
     --url https://api.brevo.com/v3/senders/domains/mydomain.com \
     --header 'accept: application/json' \
     --header 'api-key: '

A sample and appropriate response would return null which shows that domain has been deleted. This endpoint only uses domainName as an attribute which is mentioned in the table below.

AttributeDatatypeDescriptionValue
domainNameStringName of the domainmycompany.com

Response

Response codeMessageDescription
200Domain deletedYour domain is deleted.
400Bad requestInvalid, incorrect, missing parameters etc.
404Domain does not existDomain does not exist in the database.