Google accepts campaigns. See Google Search Campaigns and Google Performance Max Campaigns for what is specific to Google. Other networks refuse a campaign request with
code: 101, and details says why. On Facebook, for example, it says campaignCreation is not supported on facebook.Endpoints
{platform} is the ads network. {id} is the campaign id returned when you created it. You can read and change only campaigns created through Ayrshare by the same user profile.
Header Parameters
string
required
Required to create a campaign. Send a new unique value, such as a UUID, for each new campaign. If you repeat a request with the same key, Ayrshare returns the first response, marked
idempotentReplayed: true, and creates nothing new. You can send the key in the body as idempotencyKey instead. If you send both, they must match.Create a Campaign
POST /ads/{platform}/campaigns
New campaigns start paused unless you send status: "active", so nothing is spent until you choose to start.
string
required
The ad account to create the campaign in.
string
required
The campaign name, 1 to 255 characters.
string
required
The campaign type:
search or performanceMax. Each network supports only some types. A type the network does not support answers code: 101 and lists the supported ones.object
required
object
required
boolean
required
Whether the campaign is political advertising in the EU. You must always send it. Ayrshare never fills it in for you.
object
object
Each network supports only some targeting. A field the network does not support answers
code: 101.string
default:"paused"
active or paused.object
Options for one network only, under that network’s name, for example
{ "facebook": { ... } }. Options for any other network answer code: 101.status: "success", the campaignId, and the campaign’s own state as campaignStatus (active or paused). Get and update answer the same way.
Get a Campaign
GET /ads/{platform}/campaigns/{id}
Returns the campaign as the network reports it. A campaign that is not yours, or that does not exist, answers code: 400.
Update a Campaign
PUT /ads/{platform}/campaigns/{id}
Send at least one of these fields. You cannot change type, accountId, or euPoliticalAdvertising after you create the campaign.
string
The new campaign name.
string
active or paused. A request that only sends status: "paused" is not blocked when Ayrshare has paused ads on that network. It still needs a linked network, and it can still fail if the network itself is down.object
{ "amount": number }: the new amount to spend per day.object
{ "end": string }: the new end date, in the same format as schedule.start. It must be after the campaign’s start. A network that schedules whole days, such as Google, also accepts the same day as the start.Errors
These errors carry an Ayrsharecode:
A create can also answer with one of these HTTP statuses. Its body has no
code, only { "action": "createAdCampaign", "status": "error", "message": "..." }: