# Get entities

GET https://services.leadconnectorhq.com/ad-publishing/google/entity

Retrieve Google campaigns, ad groups, or ads based on entity type

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location identifier |
| `type` | string | Yes | Integration type |
| `campaignId` | string | No | Campaign identifier |
| `adGroupId` | string | No | Ad group identifier |
| `entityType` | string | Yes | Entity type |
| `searchId` | string | No | Comma-separated Google Ads IDs to filter by |
| `startDate` | string | No | Filter start date |
| `endDate` | string | No | Filter end date |
| `selectedAdAccountId` | string | No | Selected ad account ID |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-07-28"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ad-publishing/google/entity": {
      "get": {
        "summary": "Get entities",
        "operationId": "getEntities",
        "description": "Retrieve Google campaigns, ad groups, or ads based on entity type",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-07-28"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location identifier",
            "schema": {
              "example": "loc_abc123",
              "type": "string"
            }
          },
          {
            "name": "type",
            "required": true,
            "in": "query",
            "description": "Integration type",
            "schema": {
              "example": "AD_MANAGER",
              "enum": [
                "AD_MANAGER",
                "INTEGRATION"
              ],
              "type": "string"
            }
          },
          {
            "name": "campaignId",
            "required": false,
            "in": "query",
            "description": "Campaign identifier",
            "schema": {
              "example": "196684453527082",
              "type": "string"
            }
          },
          {
            "name": "adGroupId",
            "required": false,
            "in": "query",
            "description": "Ad group identifier",
            "schema": {
              "example": "123456789",
              "type": "string"
            }
          },
          {
            "name": "entityType",
            "required": true,
            "in": "query",
            "description": "Entity type",
            "schema": {
              "example": "CAMPAIGN",
              "enum": [
                "CAMPAIGN",
                "ADGROUP",
                "AD"
              ],
              "type": "string"
            }
          },
          {
            "name": "searchId",
            "required": false,
            "in": "query",
            "description": "Comma-separated Google Ads IDs to filter by",
            "schema": {
              "example": "123,456",
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "required": false,
            "in": "query",
            "description": "Filter start date",
            "schema": {
              "example": "2024-01-01",
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "required": false,
            "in": "query",
            "description": "Filter end date",
            "schema": {
              "example": "2024-12-31",
              "type": "string"
            }
          },
          {
            "name": "selectedAdAccountId",
            "required": false,
            "in": "query",
            "description": "Selected ad account ID",
            "schema": {
              "example": "123-456-7890",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A { data } envelope whose items follow entityType — campaigns, ad groups, or ads",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetEntitiesResponse"
                }
              }
            }
          },
          "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.readonly"
            ]
          }
        ]
      }
    }
  },
  "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": {
      "GetEntitiesResponse": {
        "type": "object",
        "properties": {
          "data": {
            "description": "Campaigns, ad groups, or ads, shaped by the requested `entityType`",
            "type": "array",
            "example": [
              {
                "resourceName": "customers/6776452901/campaigns/22173400513",
                "id": "22173400513",
                "name": "Spring promotion",
                "status": "PAUSED"
              }
            ],
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "resourceName": {
                      "type": "string",
                      "description": "Google Ads resource name",
                      "example": "customers/6776452901/campaigns/22173400513"
                    },
                    "id": {
                      "type": "string",
                      "description": "Campaign id",
                      "example": "22173400513"
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name",
                      "example": "Spring promotion"
                    },
                    "status": {
                      "type": "string",
                      "description": "Campaign status",
                      "example": "PAUSED"
                    }
                  },
                  "required": [
                    "resourceName",
                    "id",
                    "name",
                    "status"
                  ],
                  "title": "GoogleEntityCampaignDTO"
                },
                {
                  "type": "object",
                  "properties": {
                    "resourceName": {
                      "type": "string",
                      "description": "Google Ads resource name",
                      "example": "customers/6776452901/adGroups/175603784313"
                    },
                    "id": {
                      "type": "string",
                      "description": "Ad group id",
                      "example": "175603784313"
                    },
                    "name": {
                      "type": "string",
                      "description": "Ad group name",
                      "example": "Ad Group 1"
                    },
                    "status": {
                      "type": "string",
                      "description": "Ad group status",
                      "example": "ENABLED"
                    }
                  },
                  "required": [
                    "resourceName",
                    "id",
                    "name",
                    "status"
                  ],
                  "title": "GoogleEntityAdGroupDTO"
                },
                {
                  "type": "object",
                  "properties": {
                    "resourceName": {
                      "type": "string",
                      "description": "Google Ads resource name",
                      "example": "customers/6776452901/ads/730847006298"
                    },
                    "id": {
                      "type": "string",
                      "description": "Ad id",
                      "example": "730847006298"
                    },
                    "name": {
                      "type": "string",
                      "description": "Display name, derived from the ad headline where available and falling back to `Ad - {id}`",
                      "example": "Ad - 730847006298"
                    },
                    "type": {
                      "type": "string",
                      "description": "Google Ads ad type",
                      "example": "RESPONSIVE_SEARCH_AD"
                    }
                  },
                  "required": [
                    "resourceName",
                    "id",
                    "name",
                    "type"
                  ],
                  "title": "GoogleEntityAdDTO"
                }
              ]
            }
          }
        }
      },
      "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 GET 'https://services.leadconnectorhq.com/ad-publishing/google/entity?locationId=<LOCATIONID>&type=<TYPE>&entityType=<ENTITYTYPE>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-07-28'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-07-28'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/google/entity?locationId=<LOCATIONID>&type=<TYPE>&entityType=<ENTITYTYPE>', 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/entity"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-07-28"
}

params = {
    "locationId": "<LOCATIONID>",
    "type": "<TYPE>",
    "entityType": "<ENTITYTYPE>"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/ad-publishing/google/entity?locationId=<LOCATIONID>&type=<TYPE>&entityType=<ENTITYTYPE>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-07-28',
  ],
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/ad-publishing/google/entity?locationId=<LOCATIONID>&type=<TYPE>&entityType=<ENTITYTYPE>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-07-28")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/google/entity?locationId=<LOCATIONID>&type=<TYPE>&entityType=<ENTITYTYPE>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-07-28")

  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/entity?locationId=<LOCATIONID>&type=<TYPE>&entityType=<ENTITYTYPE>")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-07-28"

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

**PowerShell**

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

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ad-publishing/google/entity?locationId=<LOCATIONID>&type=<TYPE>&entityType=<ENTITYTYPE>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
