# Upsert ad

PUT https://services.leadconnectorhq.com/ad-publishing/facebook/ads

Create or update a Facebook ad

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `adPublishing.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-04-15"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ad-publishing/facebook/ads": {
      "put": {
        "summary": "Upsert ad",
        "operationId": "upsertAd",
        "description": "Create or update a Facebook ad",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertAdDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The saved ad",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacebookAdDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "adPublishing.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "UpsertAdDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Ad identifier",
            "example": "ad_123"
          },
          "locationId": {
            "type": "string",
            "description": "Location identifier",
            "example": "loc_abc123"
          },
          "name": {
            "type": "string",
            "description": "Ad name",
            "example": "My Ad Creative"
          },
          "primaryText": {
            "type": "string",
            "description": "Single primary text. Normalised into `primaryTexts` when that array is empty, so send `primaryTexts` instead unless you have exactly one variant.",
            "example": "Check out our offer!"
          },
          "headline": {
            "type": "string",
            "description": "Ad-level headline for CAROUSEL ads — used for any card that does not set its own `media[].headline`. SINGLE (image and video) ads take their headline from the `headlines` array instead.",
            "example": "Great Deal"
          },
          "description": {
            "type": "string",
            "description": "Single ad description. SINGLE (image and video) ads take their description from the `descriptions` array, and carousel cards from `media[].description`.",
            "example": "Limited time offer"
          },
          "imageUrl": {
            "type": "string",
            "description": "Ad image URL",
            "example": "https://example.com/img.jpg"
          },
          "mediaType": {
            "type": "string",
            "description": "Ad media type",
            "enum": [
              "SINGLE",
              "CAROUSEL"
            ],
            "example": "SINGLE"
          },
          "media": {
            "description": "Media items (images or videos) attached to the ad creative",
            "example": [
              {
                "src": "https://example.com/image.jpg",
                "thumbnailUrl": "https://example.com/thumb.jpg",
                "selectedPoster": 0,
                "type": "IMAGE",
                "name": "ad_image.jpg"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "src": {
                  "type": "string",
                  "description": "Media source URL",
                  "example": "https://example.com/image.jpg"
                },
                "thumbnailUrl": {
                  "type": "string",
                  "description": "Thumbnail URL (required when type is video)",
                  "example": "https://example.com/thumb.jpg"
                },
                "selectedPoster": {
                  "type": "number",
                  "description": "Selected poster index (required when type is video)",
                  "example": 0
                },
                "type": {
                  "type": "string",
                  "description": "Media content type",
                  "example": "image",
                  "enum": [
                    "image",
                    "video"
                  ]
                },
                "name": {
                  "type": "string",
                  "description": "Media file name",
                  "example": "ad_image.jpg"
                },
                "headline": {
                  "type": "string",
                  "description": "Media headline",
                  "example": "Great Offer"
                },
                "description": {
                  "type": "string",
                  "description": "Media description",
                  "example": "Click to learn more"
                },
                "link": {
                  "type": "string",
                  "description": "Media destination link",
                  "example": "https://example.com"
                }
              },
              "required": [
                "src",
                "type"
              ],
              "title": "MediaDTO"
            }
          },
          "multiAdvertiserAds": {
            "type": "boolean",
            "description": "Enable multi-advertiser ads",
            "example": false
          },
          "campaignId": {
            "type": "string",
            "description": "Parent campaign ID",
            "example": "camp_123"
          },
          "adsetId": {
            "type": "string",
            "description": "Parent ad set ID",
            "example": "adset_123"
          },
          "cta": {
            "type": "string",
            "description": "Call-to-action button. Valid values depend on the parent campaign objective (and, for sales, the ad set `conversionLocation`) — OUTCOME_LEADS: `APPLY_NOW`, `DOWNLOAD`, `GET_OFFER`, `GET_QUOTE`, `LEARN_MORE`, `SIGN_UP`, `SUBSCRIBE`; OUTCOME_TRAFFIC: `APPLY_NOW`, `BOOK_TRAVEL`, `BUY_NOW`, `CONTACT_US`, `GET_OFFER`, `GET_PROMOTIONS`, `GET_QUOTE`, `LEARN_MORE`, `NO_BUTTON`, `ORDER_NOW`, `SHOP_NOW`, `SIGN_UP`, `SUBSCRIBE`; OUTCOME_ENGAGEMENT: `APPLY_NOW`, `BOOK_TRAVEL`, `CONTACT_US`, `GET_PROMOTIONS`, `GET_QUOTE`, `INQUIRE_NOW`, `LEARN_MORE`, `MESSAGE_PAGE`, `ORDER_NOW`, `SEND_UPDATES`, `SHOP_NOW`, `SIGN_UP`, `SUBSCRIBE`; OUTCOME_SALES with `conversionLocation: messaging`: `APPLY_NOW`, `BOOK_TRAVEL`, `CONTACT_US`, `GET_QUOTE`, `LEARN_MORE`, `MESSAGE_PAGE`, `ORDER_NOW`, `PLAY_GAME`, `SHOP_NOW`, `SIGN_UP`, `SUBSCRIBE`; OUTCOME_SALES with `conversionLocation: website`: `APPLY_NOW`, `BOOK_TRAVEL`, `BUY_TICKETS`, `CONTACT_US`, `GET_OFFER`, `GET_QUOTE`, `GET_SHOWTIMES`, `LEARN_MORE`, `LISTEN_NOW`, `ORDER_NOW`, `PLAY_GAME`, `SHOP_NOW`, `SIGN_UP`, `SUBSCRIBE`, `WATCH_MORE`. Note `BOOK_TRAVEL` is the \"Book now\" button. Not validated server-side, so values outside this set are forwarded to Facebook and may be rejected there.",
            "example": "LEARN_MORE"
          },
          "conversationFormId": {
            "type": "string",
            "description": "Conversation form ID",
            "example": "conv_123"
          },
          "destinationLink": {
            "type": "string",
            "description": "Destination link URL",
            "example": "https://example.com"
          },
          "destinationFormId": {
            "type": "string",
            "description": "Destination form ID",
            "example": "form_123"
          },
          "primaryTexts": {
            "type": "array",
            "description": "Primary text variants. Used by every media type. Supply more than one to run Facebook text variations; with a single entry it becomes the ad message. Prefer this over the singular `primaryText`.",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "description": "Primary text variant",
                  "example": "Automation Test Primary Text"
                }
              },
              "required": [
                "text"
              ]
            },
            "example": [
              {
                "text": "Automation Test Primary Text"
              }
            ]
          },
          "headlines": {
            "type": "array",
            "description": "Headline variants. Applies to SINGLE (image and video) ads only — carousel ads take their per-card headline from `media[].headline`, falling back to the singular `headline`. Supply more than one to run Facebook text variations.",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "description": "Headline variant",
                  "example": "Automation Test Headline"
                }
              },
              "required": [
                "text"
              ]
            },
            "example": [
              {
                "text": "Automation Test Headline"
              },
              {
                "text": "Automation Test Headline1"
              }
            ]
          },
          "descriptions": {
            "type": "array",
            "description": "Description variants. Applies to SINGLE (image and video) ads only — carousel ads take their per-card description from `media[].description`. Supply more than one to run Facebook text variations.",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "description": "Description variant",
                  "example": "Automation Test Description"
                }
              },
              "required": [
                "text"
              ]
            },
            "example": [
              {
                "text": "Automation Test Description"
              }
            ]
          }
        },
        "required": [
          "locationId",
          "campaignId",
          "adsetId"
        ],
        "title": "UpsertAdDTO"
      },
      "FacebookAdDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Ad identifier",
            "example": "6a323f3f4454921db1498ce1"
          },
          "name": {
            "type": "string",
            "description": "Ad name",
            "example": "Ad 1"
          },
          "campaignId": {
            "type": "string",
            "description": "Parent campaign id",
            "example": "6a323f3e4454921db1498ccf"
          },
          "adsetId": {
            "type": "string",
            "description": "Parent ad set id",
            "example": "6a323f3f4454921db1498cd8"
          },
          "fbAdId": {
            "type": "string",
            "description": "Facebook ad id, set once published",
            "example": "120250378908850122"
          },
          "publishingStatus": {
            "type": "string",
            "description": "Publishing status. On a published entity this is not the state you asked for but the `effective_status` Meta reports, mapped back — a pause or resume re-reads it live, so an ad awaiting review comes back `IN_REVIEW` rather than `PAUSED` or `PUBLISHED`. Any effective status this service does not recognise also maps to `IN_REVIEW`.",
            "enum": [
              "DRAFT",
              "SCHEDULED",
              "PUBLISHING",
              "PUBLISHED",
              "PAUSED",
              "IN_REVIEW",
              "WITH_ISSUES",
              "REJECTED",
              "ARCHIVED",
              "FAILED"
            ],
            "example": "PUBLISHED"
          },
          "fbError": {
            "type": "string",
            "description": "Publish error from Facebook. `null` on reads when there is none.",
            "example": null,
            "nullable": true
          },
          "mediaType": {
            "type": "string",
            "description": "Creative format",
            "example": "SINGLE"
          },
          "cta": {
            "type": "string",
            "description": "Call-to-action button",
            "example": "GET_OFFER"
          },
          "multiAdvertiserAds": {
            "type": "boolean",
            "description": "Whether multi-advertiser ads are enabled",
            "example": true
          },
          "primaryTexts": {
            "description": "Primary text variants. Used by SINGLE image and video ads.",
            "example": [
              {
                "text": "Book a free demo",
                "_id": "6a3245204454921db1499735"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "description": "Variant text. May be an empty string for an unused slot.",
                  "example": "Book a free demo"
                },
                "_id": {
                  "type": "string",
                  "description": "Mongo subdocument id. Note `_id`, not `id` — the transform applies to the top-level document only.",
                  "example": "6a3245204454921db1499735"
                }
              },
              "required": [
                "text"
              ],
              "title": "FacebookAdTextVariantDTO"
            }
          },
          "headlines": {
            "description": "Headline variants",
            "example": [
              {
                "text": "Book a free demo",
                "_id": "6a3245204454921db1499735"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "description": "Variant text. May be an empty string for an unused slot.",
                  "example": "Book a free demo"
                },
                "_id": {
                  "type": "string",
                  "description": "Mongo subdocument id. Note `_id`, not `id` — the transform applies to the top-level document only.",
                  "example": "6a3245204454921db1499735"
                }
              },
              "required": [
                "text"
              ],
              "title": "FacebookAdTextVariantDTO"
            }
          },
          "descriptions": {
            "description": "Description variants",
            "example": [
              {
                "text": "Book a free demo",
                "_id": "6a3245204454921db1499735"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "description": "Variant text. May be an empty string for an unused slot.",
                  "example": "Book a free demo"
                },
                "_id": {
                  "type": "string",
                  "description": "Mongo subdocument id. Note `_id`, not `id` — the transform applies to the top-level document only.",
                  "example": "6a3245204454921db1499735"
                }
              },
              "required": [
                "text"
              ],
              "title": "FacebookAdTextVariantDTO"
            }
          },
          "primaryText": {
            "type": "string",
            "description": "Single primary text. Carried alongside `primaryTexts`, mirroring its first entry.",
            "example": "Get an instant estimate"
          },
          "headline": {
            "type": "string",
            "description": "Single headline. Used by carousel ads; mirrors the first `headlines` entry otherwise.",
            "example": "Free home valuation"
          },
          "description": {
            "type": "string",
            "description": "Single description",
            "example": "Fast and hassle-free"
          },
          "media": {
            "description": "Creative media",
            "example": [
              {
                "type": "image",
                "src": "https://staging.files.leadconnectorhq.com/file/abc/def.jpeg",
                "name": "creative.jpeg",
                "_id": "6a859661867e604d24f4d73d"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "description": "Media kind",
                  "example": "image"
                },
                "src": {
                  "type": "string",
                  "description": "Source URL of the uploaded file",
                  "example": "https://staging.files.leadconnectorhq.com/file/abc/def.jpeg"
                },
                "name": {
                  "type": "string",
                  "description": "Original file name",
                  "example": "creative.jpeg"
                },
                "_id": {
                  "type": "string",
                  "description": "Mongo subdocument id",
                  "example": "6a859661867e604d24f4d73d"
                }
              },
              "required": [
                "type",
                "src",
                "name"
              ],
              "title": "FacebookAdMediaDTO"
            }
          },
          "destinationFormId": {
            "type": "string",
            "description": "Instant form the ad routes to, when the conversion location is on-ad",
            "example": "36267736432839880"
          },
          "destinationLink": {
            "type": "string",
            "description": "Click destination. `null` when the ad routes to an instant form instead.",
            "example": null,
            "nullable": true
          },
          "unpublishedChanges": {
            "type": "boolean",
            "description": "Whether the ad has edits not yet published",
            "example": false
          },
          "createdAt": {
            "type": "string",
            "description": "Created at",
            "example": "2026-06-17T06:31:27.661Z"
          },
          "updatedAt": {
            "type": "string",
            "description": "Updated at",
            "example": "2026-08-19T11:45:39.340Z"
          }
        },
        "required": [
          "id",
          "name",
          "campaignId",
          "adsetId",
          "publishingStatus",
          "mediaType",
          "multiAdvertiserAds",
          "primaryTexts",
          "headlines",
          "descriptions",
          "media",
          "createdAt",
          "updatedAt"
        ],
        "title": "FacebookAdDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      },
      "InternalServerErrorDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for an unexpected server error",
            "example": 500
          },
          "message": {
            "type": "string",
            "description": "Error message describing the server failure",
            "example": "Internal Server Error"
          }
        },
        "title": "InternalServerErrorDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X PUT 'https://services.leadconnectorhq.com/ad-publishing/facebook/ads' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "id": "ad_123",
  "locationId": "loc_abc123",
  "name": "My Ad Creative",
  "primaryText": "Check out our offer!",
  "headline": "Great Deal",
  "description": "Limited time offer",
  "imageUrl": "https://example.com/img.jpg",
  "mediaType": "SINGLE",
  "media": [
    {
      "src": "https://example.com/image.jpg",
      "thumbnailUrl": "https://example.com/thumb.jpg",
      "selectedPoster": 0,
      "type": "IMAGE",
      "name": "ad_image.jpg"
    }
  ],
  "multiAdvertiserAds": false,
  "campaignId": "camp_123",
  "adsetId": "adset_123",
  "cta": "LEARN_MORE",
  "conversationFormId": "conv_123",
  "destinationLink": "https://example.com",
  "destinationFormId": "form_123",
  "primaryTexts": [
    {
      "text": "Automation Test Primary Text"
    }
  ],
  "headlines": [
    {
      "text": "Automation Test Headline"
    },
    {
      "text": "Automation Test Headline1"
    }
  ],
  "descriptions": [
    {
      "text": "Automation Test Description"
    }
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "id": "ad_123",
      "locationId": "loc_abc123",
      "name": "My Ad Creative",
      "primaryText": "Check out our offer!",
      "headline": "Great Deal",
      "description": "Limited time offer",
      "imageUrl": "https://example.com/img.jpg",
      "mediaType": "SINGLE",
      "media": [
        {
          "src": "https://example.com/image.jpg",
          "thumbnailUrl": "https://example.com/thumb.jpg",
          "selectedPoster": 0,
          "type": "IMAGE",
          "name": "ad_image.jpg"
        }
      ],
      "multiAdvertiserAds": false,
      "campaignId": "camp_123",
      "adsetId": "adset_123",
      "cta": "LEARN_MORE",
      "conversationFormId": "conv_123",
      "destinationLink": "https://example.com",
      "destinationFormId": "form_123",
      "primaryTexts": [
        {
          "text": "Automation Test Primary Text"
        }
      ],
      "headlines": [
        {
          "text": "Automation Test Headline"
        },
        {
          "text": "Automation Test Headline1"
        }
      ],
      "descriptions": [
        {
          "text": "Automation Test Description"
        }
      ]
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/facebook/ads', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/ad-publishing/facebook/ads"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-04-15"
}

payload = {
    "id": "ad_123",
    "locationId": "loc_abc123",
    "name": "My Ad Creative",
    "primaryText": "Check out our offer!",
    "headline": "Great Deal",
    "description": "Limited time offer",
    "imageUrl": "https://example.com/img.jpg",
    "mediaType": "SINGLE",
    "media": [
        {
            "src": "https://example.com/image.jpg",
            "thumbnailUrl": "https://example.com/thumb.jpg",
            "selectedPoster": 0,
            "type": "IMAGE",
            "name": "ad_image.jpg"
        }
    ],
    "multiAdvertiserAds": false,
    "campaignId": "camp_123",
    "adsetId": "adset_123",
    "cta": "LEARN_MORE",
    "conversationFormId": "conv_123",
    "destinationLink": "https://example.com",
    "destinationFormId": "form_123",
    "primaryTexts": [
        {
            "text": "Automation Test Primary Text"
        }
    ],
    "headlines": [
        {
            "text": "Automation Test Headline"
        },
        {
            "text": "Automation Test Headline1"
        }
    ],
    "descriptions": [
        {
            "text": "Automation Test Description"
        }
    ]
}

response = requests.put(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/ad-publishing/facebook/ads',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "id": "ad_123",
  "locationId": "loc_abc123",
  "name": "My Ad Creative",
  "primaryText": "Check out our offer!",
  "headline": "Great Deal",
  "description": "Limited time offer",
  "imageUrl": "https://example.com/img.jpg",
  "mediaType": "SINGLE",
  "media": [
    {
      "src": "https://example.com/image.jpg",
      "thumbnailUrl": "https://example.com/thumb.jpg",
      "selectedPoster": 0,
      "type": "IMAGE",
      "name": "ad_image.jpg"
    }
  ],
  "multiAdvertiserAds": false,
  "campaignId": "camp_123",
  "adsetId": "adset_123",
  "cta": "LEARN_MORE",
  "conversationFormId": "conv_123",
  "destinationLink": "https://example.com",
  "destinationFormId": "form_123",
  "primaryTexts": [
    {
      "text": "Automation Test Primary Text"
    }
  ],
  "headlines": [
    {
      "text": "Automation Test Headline"
    },
    {
      "text": "Automation Test Headline1"
    }
  ],
  "descriptions": [
    {
      "text": "Automation Test Description"
    }
  ]
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/ad-publishing/facebook/ads")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .header("Content-Type", "application/json")
  .body("{\"id\":\"ad_123\",\"locationId\":\"loc_abc123\",\"name\":\"My Ad Creative\",\"primaryText\":\"Check out our offer!\",\"headline\":\"Great Deal\",\"description\":\"Limited time offer\",\"imageUrl\":\"https://example.com/img.jpg\",\"mediaType\":\"SINGLE\",\"media\":[{\"src\":\"https://example.com/image.jpg\",\"thumbnailUrl\":\"https://example.com/thumb.jpg\",\"selectedPoster\":0,\"type\":\"IMAGE\",\"name\":\"ad_image.jpg\"}],\"multiAdvertiserAds\":false,\"campaignId\":\"camp_123\",\"adsetId\":\"adset_123\",\"cta\":\"LEARN_MORE\",\"conversationFormId\":\"conv_123\",\"destinationLink\":\"https://example.com\",\"destinationFormId\":\"form_123\",\"primaryTexts\":[{\"text\":\"Automation Test Primary Text\"}],\"headlines\":[{\"text\":\"Automation Test Headline\"},{\"text\":\"Automation Test Headline1\"}],\"descriptions\":[{\"text\":\"Automation Test Description\"}]}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/facebook/ads"
  payload := strings.NewReader(`{
  "id": "ad_123",
  "locationId": "loc_abc123",
  "name": "My Ad Creative",
  "primaryText": "Check out our offer!",
  "headline": "Great Deal",
  "description": "Limited time offer",
  "imageUrl": "https://example.com/img.jpg",
  "mediaType": "SINGLE",
  "media": [
    {
      "src": "https://example.com/image.jpg",
      "thumbnailUrl": "https://example.com/thumb.jpg",
      "selectedPoster": 0,
      "type": "IMAGE",
      "name": "ad_image.jpg"
    }
  ],
  "multiAdvertiserAds": false,
  "campaignId": "camp_123",
  "adsetId": "adset_123",
  "cta": "LEARN_MORE",
  "conversationFormId": "conv_123",
  "destinationLink": "https://example.com",
  "destinationFormId": "form_123",
  "primaryTexts": [
    {
      "text": "Automation Test Primary Text"
    }
  ],
  "headlines": [
    {
      "text": "Automation Test Headline"
    },
    {
      "text": "Automation Test Headline1"
    }
  ],
  "descriptions": [
    {
      "text": "Automation Test Description"
    }
  ]
}`)
  req, _ := http.NewRequest("PUT", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-04-15")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/ad-publishing/facebook/ads")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"
request["Content-Type"] = "application/json"
request.body = '{
  "id": "ad_123",
  "locationId": "loc_abc123",
  "name": "My Ad Creative",
  "primaryText": "Check out our offer!",
  "headline": "Great Deal",
  "description": "Limited time offer",
  "imageUrl": "https://example.com/img.jpg",
  "mediaType": "SINGLE",
  "media": [
    {
      "src": "https://example.com/image.jpg",
      "thumbnailUrl": "https://example.com/thumb.jpg",
      "selectedPoster": 0,
      "type": "IMAGE",
      "name": "ad_image.jpg"
    }
  ],
  "multiAdvertiserAds": false,
  "campaignId": "camp_123",
  "adsetId": "adset_123",
  "cta": "LEARN_MORE",
  "conversationFormId": "conv_123",
  "destinationLink": "https://example.com",
  "destinationFormId": "form_123",
  "primaryTexts": [
    {
      "text": "Automation Test Primary Text"
    }
  ],
  "headlines": [
    {
      "text": "Automation Test Headline"
    },
    {
      "text": "Automation Test Headline1"
    }
  ],
  "descriptions": [
    {
      "text": "Automation Test Description"
    }
  ]
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-04-15"
}

$body = '{
  "id": "ad_123",
  "locationId": "loc_abc123",
  "name": "My Ad Creative",
  "primaryText": "Check out our offer!",
  "headline": "Great Deal",
  "description": "Limited time offer",
  "imageUrl": "https://example.com/img.jpg",
  "mediaType": "SINGLE",
  "media": [
    {
      "src": "https://example.com/image.jpg",
      "thumbnailUrl": "https://example.com/thumb.jpg",
      "selectedPoster": 0,
      "type": "IMAGE",
      "name": "ad_image.jpg"
    }
  ],
  "multiAdvertiserAds": false,
  "campaignId": "camp_123",
  "adsetId": "adset_123",
  "cta": "LEARN_MORE",
  "conversationFormId": "conv_123",
  "destinationLink": "https://example.com",
  "destinationFormId": "form_123",
  "primaryTexts": [
    {
      "text": "Automation Test Primary Text"
    }
  ],
  "headlines": [
    {
      "text": "Automation Test Headline"
    },
    {
      "text": "Automation Test Headline1"
    }
  ],
  "descriptions": [
    {
      "text": "Automation Test Description"
    }
  ]
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ad-publishing/facebook/ads' -Method 'PUT' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
