# Upsert conversion

PUT https://services.leadconnectorhq.com/ad-publishing/google/conversions

Create or update a Google Ads conversion action

## 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": "v4"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ad-publishing/google/conversions": {
      "put": {
        "summary": "Upsert conversion",
        "operationId": "upsertConversion",
        "description": "Create or update a Google Ads conversion action",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v4"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertConversionDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resource name of the created or updated conversion action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GoogleResourceNameDTO"
                }
              }
            }
          },
          "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": {
      "UpsertConversionDTO": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "description": "Location identifier",
            "example": "loc_abc123"
          },
          "conversionId": {
            "type": "string",
            "description": "Conversion identifier",
            "example": "conv_456"
          },
          "name": {
            "type": "string",
            "description": "Conversion name",
            "example": "Purchase Conversion"
          },
          "type": {
            "type": "string",
            "description": "Conversion action type. Only `UPLOAD_CLICKS` is supported — the conversion list endpoint reads back UPLOAD_CLICKS actions only, so a conversion created with any other type would never be returned.",
            "example": "UPLOAD_CLICKS",
            "enum": [
              "UPLOAD_CLICKS"
            ]
          },
          "category": {
            "type": "string",
            "description": "Conversion action category",
            "example": "PURCHASE",
            "enum": [
              "DEFAULT",
              "PAGE_VIEW",
              "PURCHASE",
              "SIGNUP",
              "LEAD",
              "DOWNLOAD",
              "ADD_TO_CART",
              "BEGIN_CHECKOUT",
              "SUBSCRIBE_PAID",
              "PHONE_CALL_LEAD",
              "IMPORTED_LEAD",
              "SUBMIT_LEAD_FORM",
              "BOOK_APPOINTMENT",
              "REQUEST_QUOTE",
              "GET_DIRECTIONS",
              "OUTBOUND_CLICK",
              "CONTACT",
              "ENGAGEMENT",
              "STORE_VISIT",
              "STORE_SALE",
              "QUALIFIED_LEAD",
              "CONVERTED_LEAD"
            ]
          },
          "valueSettings": {
            "description": "Value settings that control how monetary value is attributed to conversions",
            "example": {
              "defaultValue": "10.00",
              "defaultCurrencyCode": "USD",
              "alwaysUseDefaultValue": false
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "defaultValue": {
                    "type": "number",
                    "description": "Default monetary value assigned to each conversion",
                    "example": 10
                  },
                  "defaultCurrencyCode": {
                    "type": "string",
                    "description": "ISO 4217 currency code for the default value",
                    "example": "USD"
                  },
                  "alwaysUseDefaultValue": {
                    "type": "boolean",
                    "description": "When true, always uses the default value even if a transaction-specific value is provided",
                    "example": false
                  }
                },
                "required": [
                  "defaultValue",
                  "defaultCurrencyCode",
                  "alwaysUseDefaultValue"
                ],
                "title": "ConversionValueSettings"
              }
            ]
          },
          "countingType": {
            "type": "string",
            "description": "How conversions are counted per interaction",
            "example": "ONE_PER_CLICK",
            "enum": [
              "ONE_PER_CLICK",
              "MANY_PER_CLICK"
            ]
          },
          "attributionModel": {
            "type": "string",
            "description": "Attribution model used to credit conversions",
            "example": "GOOGLE_ADS_LAST_CLICK",
            "enum": [
              "GOOGLE_SEARCH_ATTRIBUTION_DATA_DRIVEN",
              "GOOGLE_ADS_LAST_CLICK"
            ]
          },
          "clickThroughWindow": {
            "type": "number",
            "description": "Click-through conversion window in days",
            "example": 30
          }
        },
        "required": [
          "locationId",
          "name",
          "type",
          "category",
          "valueSettings",
          "countingType",
          "attributionModel",
          "clickThroughWindow"
        ],
        "title": "UpsertConversionDTO"
      },
      "GoogleResourceNameDTO": {
        "type": "object",
        "properties": {
          "resourceName": {
            "type": "string",
            "description": "Resource name of the created or updated record",
            "example": "customers/6776452901/conversionActions/7142718149"
          }
        },
        "required": [
          "resourceName"
        ],
        "title": "GoogleResourceNameDTO"
      },
      "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/google/conversions' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v4' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locationId": "loc_abc123",
  "conversionId": "conv_456",
  "name": "Purchase Conversion",
  "type": "UPLOAD_CLICKS",
  "category": "PURCHASE",
  "valueSettings": {
    "defaultValue": "10.00",
    "defaultCurrencyCode": "USD",
    "alwaysUseDefaultValue": false
  },
  "countingType": "ONE_PER_CLICK",
  "attributionModel": "GOOGLE_ADS_LAST_CLICK",
  "clickThroughWindow": 30
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v4',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "locationId": "loc_abc123",
      "conversionId": "conv_456",
      "name": "Purchase Conversion",
      "type": "UPLOAD_CLICKS",
      "category": "PURCHASE",
      "valueSettings": {
        "defaultValue": "10.00",
        "defaultCurrencyCode": "USD",
        "alwaysUseDefaultValue": false
      },
      "countingType": "ONE_PER_CLICK",
      "attributionModel": "GOOGLE_ADS_LAST_CLICK",
      "clickThroughWindow": 30
  })
};

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

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v4"
}

payload = {
    "locationId": "loc_abc123",
    "conversionId": "conv_456",
    "name": "Purchase Conversion",
    "type": "UPLOAD_CLICKS",
    "category": "PURCHASE",
    "valueSettings": {
        "defaultValue": "10.00",
        "defaultCurrencyCode": "USD",
        "alwaysUseDefaultValue": false
    },
    "countingType": "ONE_PER_CLICK",
    "attributionModel": "GOOGLE_ADS_LAST_CLICK",
    "clickThroughWindow": 30
}

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/google/conversions',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v4',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "locationId": "loc_abc123",
  "conversionId": "conv_456",
  "name": "Purchase Conversion",
  "type": "UPLOAD_CLICKS",
  "category": "PURCHASE",
  "valueSettings": {
    "defaultValue": "10.00",
    "defaultCurrencyCode": "USD",
    "alwaysUseDefaultValue": false
  },
  "countingType": "ONE_PER_CLICK",
  "attributionModel": "GOOGLE_ADS_LAST_CLICK",
  "clickThroughWindow": 30
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/ad-publishing/google/conversions")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v4")
  .header("Content-Type", "application/json")
  .body("{\"locationId\":\"loc_abc123\",\"conversionId\":\"conv_456\",\"name\":\"Purchase Conversion\",\"type\":\"UPLOAD_CLICKS\",\"category\":\"PURCHASE\",\"valueSettings\":{\"defaultValue\":\"10.00\",\"defaultCurrencyCode\":\"USD\",\"alwaysUseDefaultValue\":false},\"countingType\":\"ONE_PER_CLICK\",\"attributionModel\":\"GOOGLE_ADS_LAST_CLICK\",\"clickThroughWindow\":30}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/google/conversions"
  payload := strings.NewReader(`{
  "locationId": "loc_abc123",
  "conversionId": "conv_456",
  "name": "Purchase Conversion",
  "type": "UPLOAD_CLICKS",
  "category": "PURCHASE",
  "valueSettings": {
    "defaultValue": "10.00",
    "defaultCurrencyCode": "USD",
    "alwaysUseDefaultValue": false
  },
  "countingType": "ONE_PER_CLICK",
  "attributionModel": "GOOGLE_ADS_LAST_CLICK",
  "clickThroughWindow": 30
}`)
  req, _ := http.NewRequest("PUT", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v4")

  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/google/conversions")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v4"
request["Content-Type"] = "application/json"
request.body = '{
  "locationId": "loc_abc123",
  "conversionId": "conv_456",
  "name": "Purchase Conversion",
  "type": "UPLOAD_CLICKS",
  "category": "PURCHASE",
  "valueSettings": {
    "defaultValue": "10.00",
    "defaultCurrencyCode": "USD",
    "alwaysUseDefaultValue": false
  },
  "countingType": "ONE_PER_CLICK",
  "attributionModel": "GOOGLE_ADS_LAST_CLICK",
  "clickThroughWindow": 30
}'

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v4"
}

$body = '{
  "locationId": "loc_abc123",
  "conversionId": "conv_456",
  "name": "Purchase Conversion",
  "type": "UPLOAD_CLICKS",
  "category": "PURCHASE",
  "valueSettings": {
    "defaultValue": "10.00",
    "defaultCurrencyCode": "USD",
    "alwaysUseDefaultValue": false
  },
  "countingType": "ONE_PER_CLICK",
  "attributionModel": "GOOGLE_ADS_LAST_CLICK",
  "clickThroughWindow": 30
}'

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