# Upsert campaign

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

Create or update a Facebook campaign

## 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/campaigns": {
      "put": {
        "summary": "Upsert campaign",
        "operationId": "upsertCampaign",
        "description": "Create or update a Facebook campaign",
        "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/UpsertCampaignDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The saved campaign, without its ad sets",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacebookCampaignDTO"
                }
              }
            }
          },
          "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": {
      "UpsertCampaignDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Campaign identifier",
            "example": "camp_123"
          },
          "locationId": {
            "type": "string",
            "description": "Location identifier",
            "example": "loc_abc123"
          },
          "name": {
            "type": "string",
            "description": "Campaign name",
            "example": "Summer Campaign"
          },
          "objective": {
            "type": "string",
            "description": "Campaign objective",
            "example": "OUTCOME_LEADS",
            "enum": [
              "OUTCOME_LEADS",
              "OUTCOME_TRAFFIC",
              "OUTCOME_ENGAGEMENT",
              "OUTCOME_SALES"
            ]
          },
          "specialAdCategories": {
            "type": "array",
            "description": "Special ad categories",
            "example": [
              "NONE"
            ],
            "items": {
              "type": "string",
              "enum": [
                "EMPLOYMENT",
                "CREDIT",
                "FINANCIAL_PRODUCTS_SERVICES",
                "HOUSING",
                "ISSUES_ELECTIONS_POLITICS",
                "ONLINE_GAMBLING_AND_GAMING",
                "NONE"
              ]
            }
          },
          "isCampaignBudget": {
            "type": "boolean",
            "description": "Advantage campaign budget. When true the campaign carries `budget` and `bidStrategy`, and ad sets carry no budget of their own.",
            "example": false
          },
          "budget": {
            "description": "Campaign-level budget (Advantage campaign budget). Requires isCampaignBudget.",
            "example": {
              "budgetType": "DAILY",
              "amount": 1000
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "budgetType": {
                    "type": "string",
                    "description": "Budget type",
                    "example": "DAILY",
                    "enum": [
                      "DAILY",
                      "LIFETIME"
                    ]
                  },
                  "amount": {
                    "type": "number",
                    "description": "Budget amount in account currency, greater than zero",
                    "example": 1000
                  },
                  "scheduleStartDate": {
                    "type": "string",
                    "description": "Schedule start date",
                    "example": "2024-01-01"
                  },
                  "scheduleEndDate": {
                    "type": "string",
                    "description": "Schedule end date",
                    "example": "2024-01-31"
                  }
                },
                "required": [
                  "budgetType",
                  "amount"
                ],
                "title": "Budget"
              }
            ]
          },
          "bidStrategy": {
            "type": "string",
            "description": "Campaign-level bid strategy. Only with isCampaignBudget.",
            "example": "LOWEST_COST_WITHOUT_CAP",
            "enum": [
              "LOWEST_COST_WITHOUT_CAP",
              "LOWEST_COST_WITH_BID_CAP",
              "COST_CAP"
            ]
          },
          "bidAmount": {
            "type": "number",
            "description": "Default bid cap / cost-per-result goal in account currency for every ad set; an ad set's own bidAmount wins. Only with isCampaignBudget or adsetBudgetSharing.",
            "example": 2.5
          },
          "adsetBudgetSharing": {
            "type": "boolean",
            "description": "Ad set budget sharing: Meta may move up to 20% of an ad set budget to sibling ad sets. Mutually exclusive with isCampaignBudget.",
            "example": false
          },
          "source": {
            "type": "string",
            "description": "Campaign data source",
            "example": "facebook"
          },
          "customValueMappings": {
            "type": "object",
            "description": "User-provided overrides for custom_values merge tags used in ad copy",
            "example": {
              "{{ custom_values.pet_name }}": "Fluffy"
            }
          }
        },
        "required": [
          "locationId"
        ],
        "title": "UpsertCampaignDTO"
      },
      "FacebookCampaignDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Campaign identifier",
            "example": "6a323f3e4454921db1498ccf"
          },
          "name": {
            "type": "string",
            "description": "Campaign name",
            "example": "Spring promotion"
          },
          "locationId": {
            "type": "string",
            "description": "Location identifier",
            "example": "fRMewNQIxSyZ5R4nQyit"
          },
          "fbAdAccountId": {
            "type": "string",
            "description": "Ad account the campaign belongs to",
            "example": "act_357046700569338"
          },
          "fbCampaignId": {
            "type": "string",
            "description": "Facebook campaign id, set once published",
            "example": "120250378905720122"
          },
          "objective": {
            "type": "string",
            "description": "Campaign objective",
            "example": "OUTCOME_LEADS"
          },
          "specialAdCategories": {
            "description": "Special ad categories declared for the campaign",
            "example": [
              "NONE"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "publishingStatus": {
            "type": "string",
            "description": "Publishing status of the campaign itself. Independent of its children — pausing one ad set leaves the campaign `PUBLISHED`.",
            "enum": [
              "DRAFT",
              "SCHEDULED",
              "PUBLISHING",
              "PUBLISHED",
              "PAUSED",
              "IN_REVIEW",
              "WITH_ISSUES",
              "REJECTED",
              "ARCHIVED",
              "FAILED"
            ],
            "example": "DRAFT"
          },
          "fbError": {
            "type": "string",
            "description": "Despite the name this is not always an error. Reads return `null` when there is nothing to report and the upsert returns `\"\"`, but pausing an ad set or an ad overwrites it with an informational notice — `One or more adsets are paused` or `One or more ads are paused` — which the matching resume clears back to `null`. Treat it as a status line, not a failure signal.",
            "example": null,
            "nullable": true
          },
          "source": {
            "type": "string",
            "description": "Where the campaign was created from",
            "example": "AD_MANAGER"
          },
          "meta": {
            "description": "Ancillary campaign metadata",
            "example": {
              "evaluate": "{\"opportunityScore\":25,\"band\":\"Low\",\"categories\":[],\"fixItems\":[],\"sacCompliance\":{\"applicable\":false}}"
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "evaluate": {
                    "type": "string",
                    "description": "Opportunity-score result, stored as a JSON **string** rather than an object — parse before use. On Facebook it additionally carries `sacCompliance`, which is absent on Google and LinkedIn.",
                    "example": "{\"opportunityScore\":25,\"band\":\"Low\",\"categories\":[],\"fixItems\":[],\"sacCompliance\":{\"applicable\":false}}"
                  }
                },
                "title": "FacebookCampaignMetaDTO"
              }
            ]
          },
          "unpublishedChanges": {
            "type": "boolean",
            "description": "Whether the campaign has edits not yet published",
            "example": false
          },
          "createdAt": {
            "type": "string",
            "description": "Created at",
            "example": "2026-06-17T06:31:26.599Z"
          },
          "updatedAt": {
            "type": "string",
            "description": "Updated at",
            "example": "2026-08-19T11:45:39.340Z"
          }
        },
        "required": [
          "id",
          "name",
          "locationId",
          "fbAdAccountId",
          "objective",
          "specialAdCategories",
          "publishingStatus",
          "source",
          "createdAt",
          "updatedAt"
        ],
        "title": "FacebookCampaignDTO"
      },
      "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/campaigns' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "id": "camp_123",
  "locationId": "loc_abc123",
  "name": "Summer Campaign",
  "objective": "OUTCOME_LEADS",
  "specialAdCategories": [
    "NONE"
  ],
  "isCampaignBudget": false,
  "budget": {
    "budgetType": "DAILY",
    "amount": 1000
  },
  "bidStrategy": "LOWEST_COST_WITHOUT_CAP",
  "bidAmount": 2.5,
  "adsetBudgetSharing": false,
  "source": "facebook",
  "customValueMappings": {
    "{{ custom_values.pet_name }}": "Fluffy"
  }
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "id": "camp_123",
      "locationId": "loc_abc123",
      "name": "Summer Campaign",
      "objective": "OUTCOME_LEADS",
      "specialAdCategories": [
        "NONE"
      ],
      "isCampaignBudget": false,
      "budget": {
        "budgetType": "DAILY",
        "amount": 1000
      },
      "bidStrategy": "LOWEST_COST_WITHOUT_CAP",
      "bidAmount": 2.5,
      "adsetBudgetSharing": false,
      "source": "facebook",
      "customValueMappings": {
        "{{ custom_values.pet_name }}": "Fluffy"
      }
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/facebook/campaigns', 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/campaigns"

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

payload = {
    "id": "camp_123",
    "locationId": "loc_abc123",
    "name": "Summer Campaign",
    "objective": "OUTCOME_LEADS",
    "specialAdCategories": [
        "NONE"
    ],
    "isCampaignBudget": false,
    "budget": {
        "budgetType": "DAILY",
        "amount": 1000
    },
    "bidStrategy": "LOWEST_COST_WITHOUT_CAP",
    "bidAmount": 2.5,
    "adsetBudgetSharing": false,
    "source": "facebook",
    "customValueMappings": {
        "{{ custom_values.pet_name }}": "Fluffy"
    }
}

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/campaigns',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "id": "camp_123",
  "locationId": "loc_abc123",
  "name": "Summer Campaign",
  "objective": "OUTCOME_LEADS",
  "specialAdCategories": [
    "NONE"
  ],
  "isCampaignBudget": false,
  "budget": {
    "budgetType": "DAILY",
    "amount": 1000
  },
  "bidStrategy": "LOWEST_COST_WITHOUT_CAP",
  "bidAmount": 2.5,
  "adsetBudgetSharing": false,
  "source": "facebook",
  "customValueMappings": {
    "{{ custom_values.pet_name }}": "Fluffy"
  }
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/ad-publishing/facebook/campaigns")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .header("Content-Type", "application/json")
  .body("{\"id\":\"camp_123\",\"locationId\":\"loc_abc123\",\"name\":\"Summer Campaign\",\"objective\":\"OUTCOME_LEADS\",\"specialAdCategories\":[\"NONE\"],\"isCampaignBudget\":false,\"budget\":{\"budgetType\":\"DAILY\",\"amount\":1000},\"bidStrategy\":\"LOWEST_COST_WITHOUT_CAP\",\"bidAmount\":2.5,\"adsetBudgetSharing\":false,\"source\":\"facebook\",\"customValueMappings\":{\"{{ custom_values.pet_name }}\":\"Fluffy\"}}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/facebook/campaigns"
  payload := strings.NewReader(`{
  "id": "camp_123",
  "locationId": "loc_abc123",
  "name": "Summer Campaign",
  "objective": "OUTCOME_LEADS",
  "specialAdCategories": [
    "NONE"
  ],
  "isCampaignBudget": false,
  "budget": {
    "budgetType": "DAILY",
    "amount": 1000
  },
  "bidStrategy": "LOWEST_COST_WITHOUT_CAP",
  "bidAmount": 2.5,
  "adsetBudgetSharing": false,
  "source": "facebook",
  "customValueMappings": {
    "{{ custom_values.pet_name }}": "Fluffy"
  }
}`)
  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/campaigns")

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": "camp_123",
  "locationId": "loc_abc123",
  "name": "Summer Campaign",
  "objective": "OUTCOME_LEADS",
  "specialAdCategories": [
    "NONE"
  ],
  "isCampaignBudget": false,
  "budget": {
    "budgetType": "DAILY",
    "amount": 1000
  },
  "bidStrategy": "LOWEST_COST_WITHOUT_CAP",
  "bidAmount": 2.5,
  "adsetBudgetSharing": false,
  "source": "facebook",
  "customValueMappings": {
    "{{ custom_values.pet_name }}": "Fluffy"
  }
}'

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

**PowerShell**

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

$body = '{
  "id": "camp_123",
  "locationId": "loc_abc123",
  "name": "Summer Campaign",
  "objective": "OUTCOME_LEADS",
  "specialAdCategories": [
    "NONE"
  ],
  "isCampaignBudget": false,
  "budget": {
    "budgetType": "DAILY",
    "amount": 1000
  },
  "bidStrategy": "LOWEST_COST_WITHOUT_CAP",
  "bidAmount": 2.5,
  "adsetBudgetSharing": false,
  "source": "facebook",
  "customValueMappings": {
    "{{ custom_values.pet_name }}": "Fluffy"
  }
}'

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