Overview

For access to the Ad Generation API, please Contact Us

Bria's Ad Generation API enables builders to create multiple ads (scenes) in various sizes and resolutions, all unified by the same branding, style, and messaging.
The API streamlines the production of professional-grade ads through templates, providing a scalable solution while minimizing manual design work. Smart image embedding with AI-powered background generation allows seamless integration of objects, products, and presenters into diverse backgrounds.

The Ad Generation API provides a set of endpoints to manage the assets needed for ads generation:

  1. Templates: Pre-designed ad layouts that can be reused and customized:

    • Access template libraries and their configurations
    • Each template contains multiple scenes with customizable elements
    • Templates can be created using BRIA's Ads Editor
  2. Brands: Define and manage brand assets:

    • Store and retrieve brand-specific elements like logos, colors, and fonts
    • Ensure brand consistency across all generated ads
  3. Ad Generation: Create ads using templates and brand assets:

    • Customize text, images, and smart image backgrounds
    • Generate multiple ad variations at scale
    • Configure scene-specific elements and properties
Languages
Servers
https://engine.prod.bria-api.com/v1/

Endpoints

Operations

Generate Ads

Request

For access to the Ad Generation API, please Contact Us

The Ad Generation API enables the creation of multiple ads (scenes) in various sizes and resolutions, all unified by the same branding, style, and messaging. This is essential for testing different ad variations, repurposing successful ad formats, and significantly reducing the manual effort required to create multiple ads.

BRIA's Ad Generation API provides a unique and scalable solution for producing professional-grade ads while minimizing the need for time-consuming design work.

Template
Templates enable to repurpose and reuse well-design ads that share the same style, content and branded elements.It consists of multiple ads (“scenes”) and includes configurations for customizing the content at scale.

Smart Image Feature
A standout feature of BRIA's Ad Generation API is its ability to seamlessly embed objects, products, and presenter images into another image (a "smart image"). This AI-powered capability allows for generating diverse backgrounds for the embedded image or extending the background to fit the ad's design perfectly.

How It Works
The Ad Generation API works by sending a template ID along with inputs such as text, images, the main object with its background definition, and a brand ID (including logos, colors, and fonts). In response, the API generates a set of ad images.

In thie endpoint, responses are asynchronous, immediately providing URLs for ads that are generated in the background. Use polling for the URLs to retrieve ads once ready.

Templates can be easily created using BRIA’s Ads Editor. Once a template is ready, it can be used to produce multiple ad versions with varying messaging, branding, and images.

This API endpoint supports content moderation via an optional parameter that can prevent generation if input images contain inappropriate content, and filters out unsafe generated images - the first blocked input image will fail the entire request.

Headers
api_tokenstringrequired

API token associated with the organization.

Bodyapplication/json
content_moderationboolean

When enabled, applies content moderation to both input visuals and generated outputs.

For input images:

  • Processing stops at the first image that fails moderation
  • Returns a 422 error with details about which parameter failed

For generated ads:

  • Failed ads are replaced with zero-byte files at their placeholder URLs
  • Successful ads are stored at their original placeholder URLs
Default false
template_idstring

The ID of the template to be used for generating the ads scenes.

brand_idstring

The ID of the brand to be used across all scenes in the template.

canvas_colorstring

Canvas background color in hex format.

Default "#FFFFFF"
smart_imageobject

Smart image object for generating an image based on the embedded image, including the main object and its background definition (expand or generate_by_text).

smart_image.​main_object_urlstringrequired

URL of the main image that will be embedded within the smart image.

smart_image.​backgroundobject

Background object to determine the operation type and its associated input.

smart_image.​background.​operationstring

Choose whether to expand the existing image background or replace it by generating a new one.

Enum"expand""generate_by_text"
smart_image.​background.​inputstring

Background prompt or hex color for the image’s background. If the operation chosen is "expand" this parameter is ignored.

elementsArray of objects

List of text/images objects

elements[].​layer_typestring

The element type, either "text" or "image".

Enum"text""image"
elements[].​content_typestring

The heading level configuration for the text. This allows the same text to be inserted into multiple elements across scenes. Value should be in the format - Heading *, Body *, Image * when * can be replaced with any value between #1-#5 (for example Heading #1, Image #1 and etc.)

elements[].​contentstring

Content of the text or image, if content_type is set to text it should be a string, and if content_type is image it should be an image URL. To ignore this element, set this parameter to an empty string.

elements[].​idstring

Unique identifier for the element.

elements[].​text_configsobject

Text configs object to set text configuration to be applied to the text element

elements[].​text_configs.​highlight_colorstring

Color to highlight the text.

elements[].​text_configs.​strikethroughboolean

Strike through the text.

elements[].​text_configs.​shadowobject
elements[].​text_configs.​shadow.​blurinteger

Blur amount for the text shadow.

elements[].​text_configs.​shadow.​colorstring

Color of the text shadow.

elements[].​text_configs.​shadow.​offsetobject
elements[].​text_configs.​shadow.​offset.​xnumber(int)

Shadow's x-axis offset.

elements[].​text_configs.​shadow.​offset.​ynumber(int)

Shadow's y-axis offset.

elements[].​text_configs.​fix_text_boxobject

The “Fix text box” object allows you to specify the text box dimensions and the max font size and it will resize the content text within the text box.

elements[].​text_configs.​fix_text_box.​widthnumber(float)

The width of the text box in pixels

elements[].​text_configs.​fix_text_box.​heightnumber(float)

The height of the text box in pixels

elements[].​text_configs.​fix_text_box.​max_font_sizenumber(int)

The maximum font size to ensure that, during rescaling, the font size does not exceed this value.

curl -i -X POST \
  https://engine.prod.bria-api.com/v1/campaign-gen/create \
  -H 'Content-Type: application/json' \
  -H 'api_token: string' \
  -d '{
    "template_id": "123",
    "smart_image": {
      "main_object_url": "https://example.com/image.jpg",
      "background": {
        "operation": "generate_by_text",
        "input": "A scenic background"
      }
    },
    "brand_id": "456",
    "background_color": "#FFFFFF",
    "elements": [
      {
        "layer_type": "text",
        "content_type": "Heading #1",
        "content": "Sale Now!",
        "text_configs": {
          "highlight_color": "#FF5733",
          "strikethrough": false,
          "shadow": {
            "blur": 10,
            "color": "#000000",
            "offset": {
              "x": 2,
              "y": 2
            }
          },
          "fix_text_box": {
            "width": 200,
            "height": 100,
            "max_font_size": 15
          }
        }
      }
    ]
  }'

Responses

Successfull operation.

Bodyapplication/json
resultsArray of objects

A list of objects, where each object contains an image URL corresponding to a scene in the template, the scene's name, and its resolution.

results[].​namestring

The name of the scene from the template used to generate the image.

Example: "scene_name"
results[].​urlstring

The URL to download the generated scene result as a .png image.

Example: "IMAGE_URL"
results[].​resolutionArray of numbers(int)

The resolution of the generated image, represented as [width, height].

Example: [1000,1000]
Response
application/json
{ "results": [ { "name": "scene_name", "url": "IMAGE_URL", "resolution": [ 1000, 1000 ] } ] }

Get Brands

Request

Get the list of brands associated with your token, used to customize ads with colors, fonts, and logos.

Headers
api_tokenstringrequired

API token associated with the organization.

curl -i -X GET \
  https://engine.prod.bria-api.com/v1/campaign-gen/brands \
  -H 'api_token: string'

Responses

Successfully retrieved list of brands.

Bodyapplication/jsonArray [
idinteger
namestring
descriptionstring
created_atstring
]
Response
application/json
[ { "id": 0, "name": "string", "description": "string", "created_at": "string" } ]

Get Templates

Request

Get the list of templates associated with your token, used for ads generation.

Headers
api_tokenstringrequired

API token associated with the organization.

curl -i -X GET \
  https://engine.prod.bria-api.com/v1/campaign-gen/templates \
  -H 'api_token: string'

Responses

Successfully retrieved list of templates.

Bodyapplication/jsonArray [
idinteger
namestring
created_atstring
number_of_scenesinteger
previewstring
]
Response
application/json
[ { "id": 0, "name": "string", "created_at": "string", "number_of_scenes": 0, "preview": "string" } ]

Get Template info by ID

Request

Retrieve details for a specific template by template ID.

Path
template_idstringrequired

The ID of the template.

Headers
api_tokenstringrequired

API token associated with the organization.

curl -i -X GET \
  'https://engine.prod.bria-api.com/v1/campaign-gen/templates/{template_id}' \
  -H 'api_token: string'

Responses

Successfully retrieved template details.

Bodyapplication/jsonArray [
idstring
scene_numberinteger
elementsArray of objects
elements[].​layer_typestring
elements[].​content_typestring
elements[].​contentstring
]
Response
application/json
[ { "id": "string", "scene_number": 0, "elements": [ { "layer_type": "string", "content_type": "string", "content": "string" } ] } ]