Leadgen API (1.0.0-RC-1)

Download OpenAPI specification:Download

An API to gather prospective customers

Check that a given email is already registered

This endpoints checks that the given email is already associated with the Brevo list associated with the client. It will return 204 No Content if it is, and 404 Not Found and an appropriate error description otherwise.

The rationale of checking the association with a Brevo list ID instead of the client ID directly is that, in the end, you want to send emails to the subscribing user. It is therefore more useful to know if a given email is already receiving them or not, whichever client they registered with. One consequence is that, as different clients can be associated with the same Brevo list ID, a positive response from this endpoint does not necessarily mean that a subsequent request to the registration endpoint will result in an error.

Please be aware that using this endpoint prior to registering the given email is a textbook race condition setup. Given that a single client instance will be registering an email at a time, an actual race condition will probably never happen, but that doesn't mean you shouldn't be ready for it: always check for errors on the registration endpoint, especially those 409 Conflict.

Note: although this endpoint checks the validity of the email parameter, it is not a reliable email validator service and should not be used to that end.

Authorizations:
(BearerAuthOAuth2)
query Parameters
email
required
string
Example: email=john.doe%40example.com

The email address to check, properly URL-encoded

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    }
]

Register a new email address

Creates a new user subscription. The client has to pass a JSON formatted document containing the end-user subscription information.

When creating a new subscription for a given end-user, the API will send back to the provided e-mail address an email based on a Brevo template containing a link to confirm the subscription and email address. This double opt-in process is important to make sure the lead list is as correct as possible. Having bad addresses in the contact list can be very detrimental to the mail servers reputation and thus might impact all other mailings, including transactional emails.

The Brevo template will be chosen based on the client_id and language and a configuration reference prealably entered in the system (managed by Asmodee.net team at start). The confirm link is to be set in the template by the origin site product owner. The API will add a few parameters to this link including the confirmation_key.

Note: the combination of a client_id and an email address must be unique, i.e. a user can register the same email address multiple times, but only if if it comes from different clients.

Authorizations:
(BearerAuthOAuth2)
Request Body schema: application/json
email
required
string <email>

The email to register.

language
string <ISO 639-1>
Default: "en"

The ISO 639-1 two-letter code of the language to use for future communications. This code is case-insensitive and will default to en (English) if not provided. If the language is not already associated with the client ID making the request, the call will not be able to find the corresponding origin and return a 404 error.

country
string <ISO 3166-1 alpha-2>

The ISO 3166-1 alpha-2 two-letter code of the country the user is registering from. This code is case-insensitive and will default to the origin's country if not provided.

first_name
string

The first name of the registering user. Maximum length is 255 characters.

last_name
string

The last name of the registering user. Maximum length is 255 characters.

Responses

Request samples

Content type
application/json
{
  • "email": "john.doe@example.com",
  • "language": "fr",
  • "country": "FR",
  • "first_name": "John",
  • "last_name": "Doe"
}

Response samples

Content type
application/json
{
  • "status": "400",
  • "error": "bad_request",
  • "error_code": "API006",
  • "error_description": "\"john.doe\" must be valid email"
}

Confirm a user's email address.

This would be called by the origin server when a user clicks on the confirmation link in their confirmation email. At this point, the user will be stored into the Brevo contact list, and will receive all upcoming mailings.

Authorizations:
(BearerAuthOAuth2)
path Parameters
confirmation_key
required
string
Example: 3S6hJ_yF-SwbsP01orjY-4vey30CpGw0

A 32-characters long, URL-safe string.

Responses

Response samples

Content type
application/json
{
  • "status": "400",
  • "error": "bad_request",
  • "error_code": "API006",
  • "error_description": "Incorrect confirmation key"
}

Resend the confirmation email.

If needed, it is possible to resend the confirmation email using this endpoint. This will only happen if the email is already associated with the requesting client ID, and is not already confirmed.

This endpoint will return 204 No Content on success, 400 Bad Request if the email address is malformed, and 404 Not Found if the email doesn't exist in the database or has already been confirmed. Please note that the end user should not see any difference between those in order to prevent rogue clients from "scanning" our email database. Therefore, you should display a generic message such as "A new confirmation email has been sent to your address", and log the actual result for yourselves especially in case of an error.

Authorizations:
(BearerAuthOAuth2)
Request Body schema: application/json
email
required
string <email>

The email to resend the confirmation email to.

Responses

Request samples

Content type
application/json
{
  • "email": "john.doe@example.com"
}

Response samples

Content type
application/json
[
  • {
    },
  • {
    }
]

Unsubscribe a user

Every mailing will contain an unsubscribe link (this is the law in most of the countries). This unsubscribe link will contain a unique unsubscribe key. When the user clicks on the unsubscribe link, they will be redirected to the front website and either given the choice to stay subscribed or directly unsubscribed. When the unsubscribe is effective, the site will call this endpoint with the user unsubscribe_key. This user will then be removed from the Brevo contact list and will not receive any further newsletters sent to that list.

Trying to unsubscribe an email as client_id A when it was registered with client_id B will result in a 404 Not Found error.

Authorizations:
(BearerAuthOAuth2)
query Parameters
key
required
string
Example: key=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImphbmUuZG9lQGV4YW1wbGUuY29tIiwibGVhZGdlbl9sYW5nIjoiZnIifQ.OjcNEtQQnsv15KTvTZVkrCZc4CT1A3S--JEjJtzQ8K4

A signed JWT containing user information used to unsubscribe him from the list.

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    }
]