# Get audience by ID

GET https://services.leadconnectorhq.com/ad-publishing/google/audiences/{audienceId}

Retrieve a specific Google Ads combined audience by ID

## 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 |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `audienceId` | string | Yes | Audience identifier |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location identifier |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-04-15"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ad-publishing/google/audiences/{audienceId}": {
      "get": {
        "summary": "Get audience by ID",
        "operationId": "getAudienceById",
        "description": "Retrieve a specific Google Ads combined audience by ID",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          },
          {
            "name": "audienceId",
            "required": true,
            "in": "path",
            "description": "Audience identifier",
            "schema": {
              "example": "aud_abc123",
              "type": "string"
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location identifier",
            "schema": {
              "example": "HChooFuiyPpVYzeJ4HMe",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The combined audience",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GoogleAudienceDTO"
                }
              }
            }
          },
          "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": {
      "GoogleAudienceDTO": {
        "type": "object",
        "properties": {
          "resourceName": {
            "type": "string",
            "description": "Google Ads resource name",
            "example": "customers/6776452901/audiences/330214962"
          },
          "id": {
            "type": "string",
            "description": "Audience id",
            "example": "330214962"
          },
          "status": {
            "type": "string",
            "description": "Audience status",
            "example": "ENABLED"
          },
          "name": {
            "type": "string",
            "description": "Audience name",
            "example": "Returning customers"
          },
          "scope": {
            "type": "string",
            "description": "Scope the audience is defined at",
            "example": "CUSTOMER"
          },
          "dimensions": {
            "description": "Inclusion targeting",
            "example": {
              "ageRanges": [
                {
                  "minAge": 18,
                  "maxAge": 64
                }
              ],
              "genders": [
                "MALE"
              ],
              "incomeRanges": [
                "INCOME_RANGE_0_50"
              ],
              "parentalStatuses": [
                "PARENT"
              ],
              "audienceSegments": {
                "customAudiences": [
                  "customers/6776452901/customAudiences/901256299"
                ],
                "userLists": [
                  "customers/6776452901/userLists/9144367872"
                ],
                "userInterests": [
                  "customers/6776452901/userInterests/80276"
                ]
              },
              "isAgeUnknown": true,
              "isHouseHoldIncomeUnknown": true
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "ageRanges": {
                    "description": "Targeted age ranges. Returned as spans, which may cover several Google buckets.",
                    "example": [
                      {
                        "minAge": 18,
                        "maxAge": 64
                      }
                    ],
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "minAge": {
                          "type": "number",
                          "description": "Lower bound of the range, inclusive",
                          "example": 18
                        },
                        "maxAge": {
                          "type": "number",
                          "description": "Upper bound of the range, inclusive. Absent for the open-ended 65+ range.",
                          "example": 64
                        }
                      },
                      "required": [
                        "minAge"
                      ],
                      "title": "GoogleAudienceAgeRangeDTO"
                    }
                  },
                  "genders": {
                    "type": "array",
                    "description": "Targeted genders",
                    "example": [
                      "MALE"
                    ],
                    "items": {
                      "type": "string",
                      "enum": [
                        "MALE",
                        "FEMALE",
                        "UNDETERMINED"
                      ]
                    }
                  },
                  "incomeRanges": {
                    "description": "Targeted household income bands, in Google `INCOME_RANGE_*` form",
                    "example": [
                      "INCOME_RANGE_0_50"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "parentalStatuses": {
                    "type": "array",
                    "description": "Targeted parental statuses",
                    "example": [
                      "PARENT"
                    ],
                    "items": {
                      "type": "string",
                      "enum": [
                        "PARENT",
                        "NOT_A_PARENT",
                        "UNDETERMINED"
                      ]
                    }
                  },
                  "audienceSegments": {
                    "description": "Segment targeting",
                    "example": {
                      "customAudiences": [
                        "customers/6776452901/customAudiences/901256299"
                      ],
                      "userLists": [
                        "customers/6776452901/userLists/9144367872"
                      ],
                      "userInterests": [
                        "customers/6776452901/userInterests/80276"
                      ]
                    },
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "customAudiences": {
                            "description": "Custom audience resource names",
                            "example": [
                              "customers/6776452901/customAudiences/901256299"
                            ],
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "userLists": {
                            "description": "User list resource names",
                            "example": [
                              "customers/6776452901/userLists/9144367872"
                            ],
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "userInterests": {
                            "description": "User interest resource names. Omitted entirely when the audience targets none.",
                            "example": [
                              "customers/6776452901/userInterests/80276"
                            ],
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "customAudiences",
                          "userLists"
                        ],
                        "title": "GoogleAudienceSegmentsDTO"
                      }
                    ]
                  },
                  "isAgeUnknown": {
                    "type": "boolean",
                    "description": "Whether users of unknown age are included. Omitted when not set.",
                    "example": true
                  },
                  "isHouseHoldIncomeUnknown": {
                    "type": "boolean",
                    "description": "Whether users of unknown household income are included. Omitted when not set.",
                    "example": true
                  }
                },
                "required": [
                  "ageRanges",
                  "genders",
                  "incomeRanges",
                  "parentalStatuses",
                  "audienceSegments"
                ],
                "title": "GoogleAudienceDimensionsDTO"
              }
            ]
          },
          "exclusionDimension": {
            "description": "Exclusion targeting",
            "example": {
              "userLists": [
                "customers/6776452901/userLists/8999046675"
              ]
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "userLists": {
                    "description": "User list resource names excluded from the audience",
                    "example": [
                      "customers/6776452901/userLists/8999046675"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "userLists"
                ],
                "title": "GoogleAudienceExclusionDimensionDTO"
              }
            ]
          }
        },
        "required": [
          "resourceName",
          "id",
          "status",
          "name",
          "scope",
          "dimensions",
          "exclusionDimension"
        ],
        "title": "GoogleAudienceDTO"
      },
      "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/audiences/<audienceId>?locationId=<LOCATIONID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15'
```

**Node.js**

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

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

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

params = {
    "locationId": "<LOCATIONID>"
}

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/audiences/<audienceId>?locationId=<LOCATIONID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
  ],
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/ad-publishing/google/audiences/<audienceId>?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/google/audiences/<audienceId>?locationId=<LOCATIONID>"
  req, _ := http.NewRequest("GET", url, nil)
  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/google/audiences/<audienceId>?locationId=<LOCATIONID>")

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-04-15"

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

**PowerShell**

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

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ad-publishing/google/audiences/<audienceId>?locationId=<LOCATIONID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
