curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11" \
-X POST https://api.ayrshare.com/api/ads/google/campaigns \
-d '{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/google/campaigns", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
},
body: JSON.stringify({
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
"Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11",
}
payload = {
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": False,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
r = requests.post("https://api.ayrshare.com/api/ads/google/campaigns", headers=headers, json=payload)
print(r.json())
<?php
$payload = <<<'JSON'
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
JSON;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
"Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
],
CURLOPT_POSTFIELDS => $payload
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
echo $response;
}
?>
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
client.DefaultRequestHeaders.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11");
var payload = """
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
""";
var response = await client.PostAsync(
"https://api.ayrshare.com/api/ads/google/campaigns",
new StringContent(payload, Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
payload := `{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}`
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/google/campaigns", strings.NewReader(payload))
req.Header.Add("Authorization", "Bearer API_KEY")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class CreateCampaign {
public static void main(String[] args) throws Exception {
String payload = """
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns"))
.header("Authorization", "Bearer API_KEY")
.header("Content-Type", "application/json")
.header("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'uri'
uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer API_KEY'
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = '0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11'
request.body = <<~JSON
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused"
}
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused",
"warnings": [
"This Google Ads account has no conversion tracking. Performance Max optimizes for conversions, so Google may limit the campaign's spend until you set up conversion tracking in Google Ads."
]
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "platformOptions.google.assets.logos[0]: the image is 100x100; use at least 128x128."
}
Google Ads
Google Performance Max Campaigns
Create a Google Ads Performance Max campaign in one request from text and image URLs, with a daily budget, one asset group and its assets built together.
POST
/
ads
/
google
/
campaigns
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11" \
-X POST https://api.ayrshare.com/api/ads/google/campaigns \
-d '{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/google/campaigns", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
},
body: JSON.stringify({
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
"Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11",
}
payload = {
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": False,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
r = requests.post("https://api.ayrshare.com/api/ads/google/campaigns", headers=headers, json=payload)
print(r.json())
<?php
$payload = <<<'JSON'
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
JSON;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
"Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
],
CURLOPT_POSTFIELDS => $payload
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
echo $response;
}
?>
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
client.DefaultRequestHeaders.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11");
var payload = """
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
""";
var response = await client.PostAsync(
"https://api.ayrshare.com/api/ads/google/campaigns",
new StringContent(payload, Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
payload := `{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}`
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/google/campaigns", strings.NewReader(payload))
req.Header.Add("Authorization", "Bearer API_KEY")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class CreateCampaign {
public static void main(String[] args) throws Exception {
String payload = """
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns"))
.header("Authorization", "Bearer API_KEY")
.header("Content-Type", "application/json")
.header("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'uri'
uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer API_KEY'
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = '0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11'
request.body = <<~JSON
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused"
}
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused",
"warnings": [
"This Google Ads account has no conversion tracking. Performance Max optimizes for conversions, so Google may limit the campaign's spend until you set up conversion tracking in Google Ads."
]
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "platformOptions.google.assets.logos[0]: the image is 100x100; use at least 128x128."
}
Set up conversion tracking first. Performance Max uses your conversions to decide where to show ads and how much to bid. Ayrshare does not block a campaign without it, but Google may limit its spend until conversion tracking is set up in your Google Ads account. Ayrshare does not set it up for you. When the account has none, the create response includes a
warnings entry saying so.- Google ads are turned on per account. Contact us to enable them.
- New campaigns start
pausedunless you sendstatus: "active". - The budget is per day, in the ad account’s currency, and is never shared with other campaigns.
- Spend in another currency is converted to USD for billing at that day’s exchange rate from Open Exchange Rates. An account in a currency that cannot be converted answers
code: 101before anything is created. - Video is not supported. Google may make videos from your images.
Header Parameters
string
required
A new unique value, such as a UUID, for each new campaign. Repeating a request with the same key returns the first response. When a create fails before Ayrshare sends the campaign to Google (for example, an image that is the wrong size), the key is freed, so you can fix the request and retry with the same key.
Body Parameters
string
required
performanceMax.object
required
Performance Max takes only these strategies. Any other answers
code: 101.maximizeConversions: get the most conversions for the budget.targetCpawithtargetCpa: the same, aiming at that cost per conversion.maximizeConversionValue: get the most conversion value for the budget.targetRoaswithtargetRoas: the same, aiming at that return on ad spend, for example3.5for 350%.
boolean
required
Google requires this declaration on every campaign.
string[]
Google location ids, for example
2840 for the United States. Leave it out to target every location.object
required
Show properties
Show properties
string
required
The
http or https page the ads open.object
required
Your text and images. Each list’s items must be different from each other.
Show properties
Show properties
string[]
required
3 to 15, each up to 30 characters.
string[]
required
1 to 5, each up to 90 characters.
string[]
required
2 to 5, each up to 90 characters. At least one must be 60 characters or fewer.
string
required
One business name, up to 25 characters.
string[]
required
1 to 20 landscape image URLs: 1.91:1, at least 600×314.
string[]
required
1 to 20 square image URLs: 1:1, at least 300×300.
string[]
required
1 to 5 square logo URLs: 1:1, at least 128×128.
string[]
Up to 4 wide logo URLs: 4:1, at least 512×128. Google takes 5 logos and wide logos together at most.
Images
Ayrshare downloads each image from its URL and checks it before sending anything to Google:- GIF, JPG or PNG, up to 5120 KB each.
- At least the minimum size above, with the aspect ratio of its field (within 1%).
- All images together up to 45 MB.
- The URL must be public. Private addresses are refused.
code: 101 naming it, for example platformOptions.google.assets.logos[0]: the image is 100x100; use at least 128x128.
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11" \
-X POST https://api.ayrshare.com/api/ads/google/campaigns \
-d '{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/google/campaigns", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
},
body: JSON.stringify({
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
"Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11",
}
payload = {
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": False,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
r = requests.post("https://api.ayrshare.com/api/ads/google/campaigns", headers=headers, json=payload)
print(r.json())
<?php
$payload = <<<'JSON'
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
JSON;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
"Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
],
CURLOPT_POSTFIELDS => $payload
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
echo $response;
}
?>
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
client.DefaultRequestHeaders.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11");
var payload = """
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
""";
var response = await client.PostAsync(
"https://api.ayrshare.com/api/ads/google/campaigns",
new StringContent(payload, Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
payload := `{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}`
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/google/campaigns", strings.NewReader(payload))
req.Header.Add("Authorization", "Bearer API_KEY")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class CreateCampaign {
public static void main(String[] args) throws Exception {
String payload = """
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns"))
.header("Authorization", "Bearer API_KEY")
.header("Content-Type", "application/json")
.header("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'uri'
uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer API_KEY'
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = '0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11'
request.body = <<~JSON
{
"accountId": "123-456-7890",
"name": "Fall sale PMax",
"type": "performanceMax",
"budget": { "amount": 40, "type": "daily" },
"bidding": { "strategy": "maximizeConversions" },
"targeting": { "locations": ["2840"] },
"euPoliticalAdvertising": false,
"platformOptions": {
"google": {
"finalUrl": "https://example.com/fall-sale",
"assets": {
"headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
"longHeadlines": ["Every running shoe 30% off this week only"],
"descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
"businessName": "Acme Shoes",
"marketingImages": ["https://example.com/images/fall-1200x628.png"],
"squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
"logos": ["https://example.com/images/logo-512.png"]
}
}
}
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused"
}
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused",
"warnings": [
"This Google Ads account has no conversion tracking. Performance Max optimizes for conversions, so Google may limit the campaign's spend until you set up conversion tracking in Google Ads."
]
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "platformOptions.google.assets.logos[0]: the image is 100x100; use at least 128x128."
}