# Get keyword ideas

POST https://services.leadconnectorhq.com/ad-publishing/google/keyword-ideas

Retrieve keyword suggestions for Google Ads campaigns

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

## 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/keyword-ideas": {
      "post": {
        "summary": "Get keyword ideas",
        "operationId": "getKeywordIdeas",
        "description": "Retrieve keyword suggestions for Google Ads campaigns",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location identifier",
            "schema": {
              "example": "HChooFuiyPpVYzeJ4HMe",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KeywordSuggestionDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Keyword suggestions ordered by search volume, highest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetKeywordIdeasResponse"
                }
              }
            }
          },
          "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": {
      "KeywordSuggestionDTO": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Target URL",
            "example": "https://example.com"
          },
          "languageCode": {
            "type": "string",
            "description": "Language code",
            "example": "en"
          },
          "locations": {
            "description": "Target locations",
            "example": [
              "US",
              "CA"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "keywords": {
            "description": "Seed keywords",
            "example": [
              "marketing"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "url"
        ],
        "title": "KeywordSuggestionDTO"
      },
      "GetKeywordIdeasResponse": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string",
              "description": "Suggested keyword",
              "example": "crm software"
            },
            "avgMonthlySearches": {
              "type": "string",
              "description": "Average monthly search volume, returned as a string rather than a number",
              "example": "450000"
            }
          },
          "required": [
            "text",
            "avgMonthlySearches"
          ],
          "title": "GoogleKeywordIdeaDTO"
        }
      },
      "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 POST 'https://services.leadconnectorhq.com/ad-publishing/google/keyword-ideas?locationId=<LOCATIONID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "url": "https://example.com",
  "languageCode": "en",
  "locations": [
    "US",
    "CA"
  ],
  "keywords": [
    "marketing"
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "url": "https://example.com",
      "languageCode": "en",
      "locations": [
        "US",
        "CA"
      ],
      "keywords": [
        "marketing"
      ]
  })
};

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

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

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

payload = {
    "url": "https://example.com",
    "languageCode": "en",
    "locations": [
        "US",
        "CA"
    ],
    "keywords": [
        "marketing"
    ]
}

response = requests.post(url, params=params, 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/keyword-ideas?locationId=<LOCATIONID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "url": "https://example.com",
  "languageCode": "en",
  "locations": [
    "US",
    "CA"
  ],
  "keywords": [
    "marketing"
  ]
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/ad-publishing/google/keyword-ideas?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .header("Content-Type", "application/json")
  .body("{\"url\":\"https://example.com\",\"languageCode\":\"en\",\"locations\":[\"US\",\"CA\"],\"keywords\":[\"marketing\"]}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/google/keyword-ideas?locationId=<LOCATIONID>"
  payload := strings.NewReader(`{
  "url": "https://example.com",
  "languageCode": "en",
  "locations": [
    "US",
    "CA"
  ],
  "keywords": [
    "marketing"
  ]
}`)
  req, _ := http.NewRequest("POST", 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/google/keyword-ideas?locationId=<LOCATIONID>")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"
request["Content-Type"] = "application/json"
request.body = '{
  "url": "https://example.com",
  "languageCode": "en",
  "locations": [
    "US",
    "CA"
  ],
  "keywords": [
    "marketing"
  ]
}'

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

**PowerShell**

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

$body = '{
  "url": "https://example.com",
  "languageCode": "en",
  "locations": [
    "US",
    "CA"
  ],
  "keywords": [
    "marketing"
  ]
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ad-publishing/google/keyword-ideas?locationId=<LOCATIONID>' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
