> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apostra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Change a live buy with control_media_buy

> How an Apostra storefront answers AdCP control_media_buy: the revision you must send, the actions that authorise a control, and what each refusal means

An agent that talks AdCP directly to an Apostra storefront changes a media buy
it already holds with `control_media_buy`: pause or resume it, cancel it, or
change its budget caps, pacing, bidding or package controls. This page says what
the storefront checks first and what it answers.

## Which storefronts serve it

A storefront that books through Apostra serves `control_media_buy`, and lists it
in `media_buy.lifecycle_tools` in its `get_adcp_capabilities` answer. A storefront
that sells through a platform adapter, such as Meta or TikTok, keeps
`update_media_buy`, which every storefront serves, and does not serve
`control_media_buy`.

## What you send

Send the buy's `media_buy_id`, your `account`, the control fields, and the
`revision` from the latest `get_media_buys` read of that buy. `revision` is
required. The storefront compares it with the buy's current revision before it
writes anything.

## What the storefront checks

| Check | If it fails |
| - | - |
| The account holds the buy. | `MEDIA_BUY_NOT_FOUND`, on `media_buy_id`. |
| `revision` is the buy's current revision, checked while no other control of the buy runs. | `CONFLICT`, on `revision`, with `current_revision` in the details. Nothing was applied. Read the buy again and resend with its revision. |
| Each control is one of the buy's `available_actions`, as a self-serve action. | `ACTION_NOT_ALLOWED`, naming `attempted_action`, with the actions the buy lists now. Nothing was applied. A control that needs the seller's agreement is refused as `mode_mismatch`; ask for it by refining the accepted proposal. |

A buy that lists no actions allows no control: the storefront lists a buy's
actions while it is active or paused, so a control of any other buy is refused
with `ACTION_NOT_ALLOWED` (`reason: no_actions_available`). The reporting webhook
is not checked against an action.

## Two controls at once

The storefront runs one `control_media_buy` of a buy at a time. A second control
of the same buy waits for the first to finish, then reads the buy's new revision
and is refused with `CONFLICT` if it sent the old one. So two controls sent at
the same revision never both apply: one does, and the other is told the
revision to resend with. A control that cannot start within about 20 seconds, because the
buy stayed busy or the storefront was already running as many controls as it
allows, is refused with `SERVICE_UNAVAILABLE` (retryable) and nothing is applied.

This guarantee covers controls against each other only. A change to the same buy
that is not a `control_media_buy`, such as an `update_media_buy`, a creative
change or a status update from the seller, does not wait for the lock. One that
lands between a control's revision check and the seller's answer is not
serialized with it. Read the buy again after a `CONFLICT` and send the control
with the revision you read.

## What you get back

A control that was applied answers `status: "completed"` with:

| Field | What it tells you |
| - | - |
| `media_buy_id` | The buy you changed. |
| `revision` | The buy's new revision. Use it for the next control. |
| `media_buy_status` | The buy's status now. |
| `affected_package_ids` | The packages the control touched, when it touched any. |
| `available_actions` | The actions the buy allows now, read after the change. |
| `warnings` | Non-blocking observations about the control, when there are any. |

A control that the seller queues for approval answers `status: "submitted"` with
a `task_id`. Nothing has changed until the task completes. While it is queued, a second
control of the same buy is refused with `CONFLICT` (`details.reason:
update_pending_approval`, `mutation_outcome: not_applied`), because the buy's
revision has not moved yet; send it again once the update has been decided. An
update whose approval was granted but whose forward to the seller has run out of
retries no longer counts: it is finished, and the buy accepts controls again. If the storefront cannot read the buy's pending updates, the control is refused
with `SERVICE_UNAVAILABLE` and `mutation_outcome: not_applied`; send it again.

If the control is applied but the buy's new revision cannot be read, the answer
is `SERVICE_UNAVAILABLE` with `mutation_outcome: applied`. Do not resend the
control; read the buy with `get_media_buys` first. Every refusal carries
`mutation_outcome` on the error itself, so an agent knows whether the buy
changed.

## A known limit

The revision check protects against another `control_media_buy`, not against every
writer. A write that is not a control (`update_media_buy`, an update entering approval, a late leg commit, a creative sync or poll) can commit between the revision check and the seller call. The storefront closes this by checking and advancing the
revision before it calls the seller, for `control_media_buy` and
`update_media_buy` together; that work is tracked as AI-23966.

## What it does not do

`control_media_buy` does not change creatives, add products or packages, change
the flight, change prices, or change billing terms. Those go through their own
tasks or through a refined proposal. Sending an identical call again with the
same `idempotency_key` returns the first answer.

## Turning it off

There is no separate switch for `control_media_buy`. A storefront serves it
whenever it books through Apostra and is not a platform-adapter storefront. It
changes the buy it names, so it is not read-only: it takes the same effect as
`update_media_buy` with the same change.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.