Create or update a Google Ads audience segment
http
PUT https://services.leadconnectorhq.com/ad-publishing/google/segmentsAuthorization
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
Authorization | string | Yes | Bearer token generated from the Leadway portal. See Authentication. | |
Version | string | Yes | 2021-07-28 | API version. |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
locationId | string | Yes | HChooFuiyPpVYzeJ4HMe | Account identifier |
type | string | Yes | CUSTOM_SEGMENTS | Segment type |
Body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
name | string | Yes | My Segment | Segment name |
description | string | No | Target audience segment | Segment description |
members(object[]): Segment members — keywords, URLs, or apps that define the custom segmentmemberType(string, required): Member type Possible values: 'KEYWORD', 'URL', 'APP' Example:KEYWORDkeyword(string): Keyword value Example:marketingurl(string): URL value Example:https://example.comapp(string): App identifier Example:com.example.app
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
status | string | No | ENABLED | Segment status |
type | string | No | CUSTOM_SEGMENTS | Segment type |
id | string | No | seg_123 | Segment identifier |
membershipStatus | string | No | OPEN | Membership status |
ruleBasedUserList | object | No | Rule-based user list config | |
membershipLifeSpan | number | No | 30 | Membership life span |
seedUserListIds | string[] | No | Seed user list IDs | |
countryCodes | string[] | No | Country codes | |
expansionLevel | string | No | BALANCED | Expansion level Possible values: 'BALANCED', 'BROAD', 'NARROW' |
Responses
200 - Response
400 - Bad Request
json
{}422 - Unprocessable Entity
json
{}Example
curl -X PUT 'https://services.leadconnectorhq.com/ad-publishing/google/segments' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Version: 2021-07-28' \
-H 'Content-Type: application/json' \
-d '{
"name": "My Segment",
"description": "Target audience segment",
"members": [
{
"memberType": "KEYWORD",
"keyword": "digital marketing"
},
{
"memberType": "URL",
"url": "https://example.com"
},
{
"memberType": "APP",
"app": "com.example.app"
}
],
"status": "ENABLED",
"type": "CUSTOM_SEGMENTS",
"id": "seg_123",
"membershipStatus": "OPEN",
"membershipLifeSpan": 30,
"seedUserListIds": [
"list_1"
],
"countryCodes": [
"US",
"CA"
],
"expansionLevel": "BALANCED"
}'const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/google/segments', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
Version: '2021-07-28',
'Content-Type': 'application/json',
},
body: JSON.stringify({"name": "My Segment", "description": "Target audience segment", "members": [{"memberType": "KEYWORD", "keyword": "digital marketing"}, {"memberType": "URL", "url": "https://example.com"}, {"memberType": "APP", "app": "com.example.app"}], "status": "ENABLED", "type": "CUSTOM_SEGMENTS", "id": "seg_123", "membershipStatus": "OPEN", "membershipLifeSpan": 30, "seedUserListIds": ["list_1"], "countryCodes": ["US", "CA"], "expansionLevel": "BALANCED"}),
});
const data = await response.json();import os, requests
response = requests.request(
'PUT',
'https://services.leadconnectorhq.com/ad-publishing/google/segments',
headers={
'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
'Version': '2021-07-28',
'Content-Type': 'application/json',
},
json={"name": "My Segment", "description": "Target audience segment", "members": [{"memberType": "KEYWORD", "keyword": "digital marketing"}, {"memberType": "URL", "url": "https://example.com"}, {"memberType": "APP", "app": "com.example.app"}], "status": "ENABLED", "type": "CUSTOM_SEGMENTS", "id": "seg_123", "membershipStatus": "OPEN", "membershipLifeSpan": 30, "seedUserListIds": ["list_1"], "countryCodes": ["US", "CA"], "expansionLevel": "BALANCED"},
)
data = response.json()<?php
$ch = curl_init('https://services.leadconnectorhq.com/ad-publishing/google/segments');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
'Version: 2021-07-28',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({'name': 'My Segment', 'description': 'Target audience segment', 'members': [{'memberType': 'KEYWORD', 'keyword': 'digital marketing'}, {'memberType': 'URL', 'url': 'https://example.com'}, {'memberType': 'APP', 'app': 'com.example.app'}], 'status': 'ENABLED', 'type': 'CUSTOM_SEGMENTS', 'id': 'seg_123', 'membershipStatus': 'OPEN', 'membershipLifeSpan': 30, 'seedUserListIds': ['list_1'], 'countryCodes': ['US', 'CA'], 'expansionLevel': 'BALANCED'}),
]);
$data = json_decode(curl_exec($ch), true);