Skip to content
AdCrunch
Esc
navigateopen⌘Jpreview

Update a Campaign Plan

Updates a Campaign Plan. Send the base_revision you read. Omit a field to keep it. Send null to clear it.

Any change puts an approved plan back into draft. An approval speaks about content, and it cannot survive a change to that content. A write that changes nothing keeps the approval.

The answer is 409 with error=currency_frozen if a Line Item already has a budget, with error=revision_mismatch if the plan changed after you read it, and with error=slug_conflict if the new name gives a slug that already exists.

PATCH/context/campaign-plans/{slug}
Authorization
AuthorizationBearer token · headerrequired

Send Authorization: Bearer <credential>. Two credentials work.

An API key (acr_…) is what a server integration uses. Create one in the AdCrunch console under Settings → API keys — see https://docs.adcrunch.dev/account/api-keys. A key is bound to the organization that was active when you created it, and it keeps acting on that organization whatever you do later. It carries the permissions of the member who created it.

A session issued by the AdCrunch sign-in flow also works, which is how the console calls this service from the browser.

Either way the organization comes from the credential. There is no organization parameter.

Path parameters
slugstringrequired
Request body
requiredapplication/json
base_revisionintegerrequired

The revision last read via GET — guards concurrent edits.

min -9007199254740991 · max 9007199254740991
brand_namestring | null

Re-point the plan at another Brand by slug; null unlinks it. Refused with 409 error=persona_not_in_brand while any Line Item still names a Persona of the current Brand.

currencystring

ISO 4217. Refused with 409 error=currency_frozen once any Line Item carries a budget — re-denominating a costed plan would silently reinterpret every number in it.

min length 3 · max length 3
descriptionstring
min length 1 · max length 500
end_datestring | null

null makes the plan always-on — which also flips every inheriting line’s amount from a total to a daily rate.

matches ^\d{4}-\d{2}-\d{2}$
measurementstring | null
min length 1
namestring
min length 1 · max length 120
rationalestring | null
min length 1
slugstring

Optional new slug handle (a deliberate rename).

max length 120
start_datestring | null
matches ^\d{4}-\d{2}-\d{2}$
total_budgetinteger | null

null means "no declared constraint", not zero.

min 0 · max 9007199254740991
Responses
200

The Campaign Plan as it now stands.

allocationobjectrequired

Derived on every read. Never stored.

Show properties
allocatednumber | nullrequired

The sum of the Line Item budgets. null when the lines mix units, because that sum would be meaningless.

comparablebooleanrequired

False when the lines mix totals and daily rates. A surface must then print "not comparable" rather than a plausible-looking wrong total.

unallocatednumber | nullrequired

The envelope less the allocated, where both are known.

unitstring | nullrequired

The shared unit, when the lines agree on one.

Allowed:totaldaily
brandIdstring | nullrequired

Nullable and mutable: a plan may precede its brand, cover a portfolio, or be re-pointed. Deleting a Brand leaves its plans standing.

createdAtnumberrequired

Milliseconds since the Unix epoch, UTC.

createdBystringrequired
currencystringrequired

Editable until the first Line Item budget, and frozen thereafter.

descriptionstringrequired
endDatestring | nullrequired

A calendar date, YYYY-MM-DD.

idstringrequired
lineItemsobject[]required
Show properties
Array of object
advertiserIdstring | nullrequired
ageMaxnumber | nullrequired
ageMinnumber | nullrequired

Each bound is independently optional, so "35+" is expressible.

budgetnumber | nullrequired

Integer minor units of the plan’s currency.

campaignPlanIdstringrequired
channelstringrequired

The planner’s word for what is being bought, not a provider name. A plan may name a channel we cannot execute.

Allowed:metatiktoksnapchatgoogle_searchgoogle_pmaxgoogle_displayyoutubeprogrammatic_displaylinkedinx
countriesstring[]required
createdAtnumberrequired

Milliseconds since the Unix epoch, UTC.

createdBystringrequired
effectiveEndDatestring | nullrequired

The line’s own bound where it has one, else the plan’s.

effectiveStartDatestring | nullrequired

A calendar date, YYYY-MM-DD.

endDatestring | nullrequired

A calendar date, YYYY-MM-DD.

executablebooleanrequired

Whether this channel could be executed at all today. Derived from our capabilities, never a promise that it will be.

executionsobject[]required

What this line has spawned. Never a claim that it is finished — nobody declared how many objects a line should produce.

Show properties
Array of object
advertiserIdstringrequired
createdAtnumberrequired

Milliseconds since the Unix epoch, UTC.

entityIdstringrequired

The provider’s own id, unprefixed, so it joins to entities.

entityTypestringrequired

The provider’s word for the level — campaign, adset, ad.

idstringrequired
mutationWorkflowIdstring | nullrequired

The durable execution that performed the write, when known.

providerstringrequired
genderstring | nullrequired
Allowed:allmenwomen
idstringrequired
objectivestringrequired
Allowed:awarenessengagementleadssalestrafficapp_promotion
personaIdstring | nullrequired

Explains the targeting; never supplies its values.

providerstring | nullrequired

Who sells this channel, or null when nobody we integrate with does.

revisionnumberrequired

Increments on every write. Send it back as base_revision to edit; a stale one answers 409.

startDatestring | nullrequired

A calendar date, YYYY-MM-DD.

statusstringrequired

validated is the gate on execution.

Allowed:draftvalidated
unitstringrequired

How budget reads, derived from the effective end date. Present → a total for the period; absent → a daily rate. A surface must print this beside the amount.

Allowed:totaldaily
updatedAtnumber | nullrequired

Milliseconds since the Unix epoch, UTC.

measurementstring | nullrequired
namestringrequired
rationalestring | nullrequired
revisionnumberrequired

Increments on every write. Send it back as base_revision to edit; a stale one answers 409.

slugstringrequired
startDatestring | nullrequired

A calendar date, YYYY-MM-DD.

statusstringrequired

The only two stored states. active, closed and "executed" are derived, never stored.

Allowed:draftapproved
totalBudgetnumber | nullrequired
updatedAtnumber | nullrequired

Milliseconds since the Unix epoch, UTC.

401

No credential, or one that does not resolve. Send an API key or a session. See the security scheme. error is unauthorized.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

Allowed:unauthorized
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

403

The caller does not hold campaign_plan:write. error is forbidden.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

Allowed:forbidden
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

404

No Campaign Plan with that slug, or brand_name names no Brand. error is not_found for both.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

409

Four codes share this status. revision_mismatch: somebody wrote first. slug_conflict: the rename collides. persona_not_in_brand: re-pointing the plan would orphan Line Items that name a Persona of the current Brand, and lineItemIds names them — they are not cleared for you. currency_frozen: a Line Item already carries a budget, so the denomination is fixed; nothing is ever converted.

Any of:
object
currentRevisionnumberrequired

The revision the row holds now. Re-read, re-apply your edit on top, and send this back as base_revision.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

Allowed:revision_mismatch
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

object
slugstringrequired

The slug that is already taken.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

Allowed:slug_conflict
messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

422

invalid_slug, invalid_currency, invalid_amount or invalid_window.

errorstringrequired

A stable code for the failure. This is the field to branch on. It does not change for a given failure.

messagestringrequired

A sentence to show a person. Written to say what to do next. Reworded whenever it can be said better, so never branch on it.

Request
curl -X PATCH "https://api.adcrunch.dev/context/campaign-plans/string" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "base_revision": -9007199254740991,
  "brand_name": "string",
  "currency": "str",
  "description": "string",
  "end_date": "string",
  "measurement": "string",
  "name": "string",
  "rationale": "string",
  "slug": "string",
  "start_date": "string",
  "total_budget": 0
}'
Response
{
  "allocation": {
    "allocated": 0,
    "comparable": true,
    "unallocated": 0,
    "unit": "total"
  },
  "brandId": "string",
  "createdAt": 0,
  "createdBy": "string",
  "currency": "string",
  "description": "string",
  "endDate": "string",
  "id": "string",
  "lineItems": [
    {
      "advertiserId": "string",
      "ageMax": 0,
      "ageMin": 0,
      "budget": 0,
      "campaignPlanId": "string",
      "channel": "meta",
      "countries": [
        "string"
      ],
      "createdAt": 0,
      "createdBy": "string",
      "effectiveEndDate": "string",
      "effectiveStartDate": "string",
      "endDate": "string",
      "executable": true,
      "executions": [
        {
          "advertiserId": "string",
          "createdAt": 0,
          "entityId": "string",
          "entityType": "string",
          "id": "string",
          "mutationWorkflowId": "string",
          "provider": "string"
        }
      ],
      "gender": "all",
      "id": "string",
      "objective": "awareness",
      "personaId": "string",
      "provider": "string",
      "revision": 0,
      "startDate": "string",
      "status": "draft",
      "unit": "total",
      "updatedAt": 0
    }
  ],
  "measurement": "string",
  "name": "string",
  "rationale": "string",
  "revision": 0,
  "slug": "string",
  "startDate": "string",
  "status": "draft",
  "totalBudget": 0,
  "updatedAt": 0
}