Skip to content

Add Promo Ad

Description

This API allows store owners to add a promotional advertisement to their store. Only authorized users (store owners) can access this endpoint.

Endpoint

  • URL: /v1/promo-ads
  • Method: POST

Required Headers

json
{
  "Authorization": "Bearer JWT_TOKEN",
  "X-MerchantApiKey": "MERCHANT_API_KEY",
  "Content-Type": "application/json"
}

📥 Request Body

PromoAdRequest

Field NameTypeRequiredDescription
adNameStringYesThe name of the promotional ad (max: 100 characters).
imagesListYesA list of image URLs for the ad. At least one image is required.
ctaTextStringYesThe call-to-action (CTA) text for the ad.
promoCodeStringYesThe promotional code associated with the ad (max: 20 characters).
buttonsListYesA list of buttons associated with the ad. At least one button is required.
statusStringYesThe status of the ad (DRAFT or PUBLISHED).

ButtonRequest

Field NameTypeRequiredDescription
typeStringYesThe button type (e.g., primary, secondary).
positionStringYesThe position of the button (e.g., top-right, bottom-left).
colorStringYesThe background color of the button (hex or name).
textColorStringYesThe text color of the button (hex or name).
textStringYesThe text inside the button.
linkStringYesThe URL associated with the button.
metadataObjectNoAdditional metadata for the button.

Example API Call (Using Fetch)

javascript
fetch("https://api.shopsynch.com/v1/promo-ads/12345", {
  method: "PATCH",
  headers: {
    "Authorization": "Bearer JWT_TOKEN",
    "X-MerchantApiKey": "MERCHANT_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "adName": "Spring Sale",
    "images": ["https://example.com/image1.jpg", "https://example.com/image2.jpg"],
    "ctaText": "Shop Now!",
    "promoCode": "SPRING20",
    "buttons": [
      {
        "type": "primary",
        "position": "top-right",
        "color": "#FF5733",
        "textColor": "#FFFFFF",
        "link": "https://example.com/shop",
        "metadata": {}
      }
    ],
    "status": "PUBLISHED"
  })
})

## ✅ Sample 200 Response (Success)
```json
{
    "data": {
        "id": "67abd011ea45dd1b9222e591",
        "adName": "Biggest Sale Ever",
        "images": [
            "https://example.com/sale1.jpg",
            "https://example.com/sale2.jpg"
        ],
        "ctaText": "Shop Now!",
        "promoCode": "BIGSALE50",
        "buttons": [
            {
                "type": "primary",
                "position": "bottom-center",
                "color": "#FF0000",
                "textColor": "#FFFFFF",
                "link": "https://example.com/shop",
                "metadata": null
            }
        ],
        "status": "DRAFT",
        "metadata": null,
        "createdAt": "2025-02-11T23:32:49.254402",
        "updatedAt": "2025-02-11T23:32:49.254402"
    },
    "message": "Promo Ad created successfully",
    "status": true
}

❌ Sample 400 Response (Not Found Error)

json
{
    "data": {
        "id": "67ab8731aae58b6fb27a03af",
        "adName": "Biggest Sale Ever - Updated",
        "images": [
            "https://example.com/sale1.jpg",
            "https://example.com/sale2.jpg",
            "https://example.com/sale3.jpg"
        ],
        "ctaText": "Limited Offer!",
        "promoCode": "BIGSALE2024",
        "buttons": [
            {
                "type": "secondary",
                "position": "top-right",
                "color": "#008000",
                "textColor": "#FFFFFF",
                "link": "https://example.com/deals",
                "metadata": null
            }
        ],
        "status": "PUBLISHED",
        "metadata": null
    },
    "message": "Promo Ad updated successfully",
    "status": true
}

Next Steps

Build with joy