POST /ads

Create a new ad with either trip or cart data (exactly one required)

application/json

Body Required

  • trip object
    Hide trip attributes Show trip attributes object
    • type string Required

      Values are One Way, Round Trip, or Multi-City.

    • flights array[object] Required
      Hide flights attributes Show flights attributes object
      • departureAirport string Required

        IATA airport code

      • arrivalAirport string Required

        IATA airport code

      • departureTimestamp integer Required

        Unix timestamp for departure

      • arrivalTimestamp integer Required

        Unix timestamp for arrival

      • numTravelers integer Required

        Number of travelers

        Minimum value is 1.

      • seatClass string Required

        Values are economy, main, premium, business, or first.

  • cart object
    Hide cart attributes Show cart attributes object
    • type string Required

      Value is grocery.

    • products array[object] Required
      Hide products attributes Show products attributes object
      • name string Required

        Product name

      • brand string | null
      • price number(float) | null
      • quantity integer

        Default value is 1.

      • category string | null
      • size string | null
      • unit string | null

        Unit of measurement

      • barcode string | null
      • organic boolean

        Default value is false.

      • gluten_free boolean

        Default value is false.

  • widgets array[object]

    List of widget configurations for the ad

    Hide widgets attributes Show widgets attributes object
    • type string Required

      Type of widget to generate

      Values are food, hotels, events, experiences, packing, apps, mood, or recipes.

    • maxItems integer

      Maximum number of items to return for this widget

      Minimum value is 1.

Responses

  • 200 application/json

    Ad created successfully

    Hide response attributes Show response attributes object
    • trip object
      Hide trip attribute Show trip attribute object
      • adId string Required

        Unique identifier for the created ad

    • cart object
      Hide cart attribute Show cart attribute object
      • adId string Required

        Unique identifier for the created ad

    • accessToken string Required

      Access token for retrieving the ad via GET /ads/{ad_id}. Important: Use this token (not the /auth/token response) as the Bearer token when calling GET /ads/{ad_id}.

  • 400 application/json

    Invalid request (missing or multiple content objects)

    Hide response attribute Show response attribute object
    • detail string
  • 401

    Unauthorized

POST /ads
curl \
 --request POST 'https://api.thankly.ai/ads' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"trip":{"type":"One Way","flights":[{"departureAirport":"JFK","arrivalAirport":"LAX","departureTimestamp":1735689600,"arrivalTimestamp":1735710000,"numTravelers":2,"seatClass":"economy"}]},"cart":{"type":"grocery","products":[{"name":"Organic Bananas","brand":"Dole","price":2.99,"quantity":3,"category":"Produce","size":"1 lb","unit":"lb","barcode":"011110482587","organic":false,"gluten_free":false}]},"widgets":[{"type":"food","maxItems":4,"sponsoredLinks":[{"title":"Example","description":"This is an advertiser injected content","link":"https://example.com"}]}]}'
Request examples
{
  "trip": {
    "type": "One Way",
    "flights": [
      {
        "departureAirport": "JFK",
        "arrivalAirport": "LAX",
        "departureTimestamp": 1735689600,
        "arrivalTimestamp": 1735710000,
        "numTravelers": 2,
        "seatClass": "economy"
      }
    ]
  },
  "cart": {
    "type": "grocery",
    "products": [
      {
        "name": "Organic Bananas",
        "brand": "Dole",
        "price": 2.99,
        "quantity": 3,
        "category": "Produce",
        "size": "1 lb",
        "unit": "lb",
        "barcode": "011110482587",
        "organic": false,
        "gluten_free": false
      }
    ]
  },
  "widgets": [
    {
      "type": "food",
      "maxItems": 4,
      "sponsoredLinks": [
        {
          "title": "Example",
          "description": "This is an advertiser injected content",
          "link": "https://example.com"
        }
      ]
    }
  ]
}
Response examples (200)
{
  "trip": {
    "adId": "string"
  },
  "cart": {
    "adId": "string"
  },
  "accessToken": "string"
}
Response examples (400)
{
  "detail": "Exactly one content object is required"
}