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

# Write API

> Start, stop and update RevShare campaigns, accept or reject CPL orders and start CPL campaigns with the same API key you use for reads.

The Write API lets you do from code what you do in the partner cabinet: start, stop and update RevShare campaigns, accept, reject and stop CPL orders, and start delivering to a client's CPL offer from Find Offers.

## Scope

| Endpoint                                                                                 | What it does in the cabinet              |
| ---------------------------------------------------------------------------------------- | ---------------------------------------- |
| [`POST /api/marketer/revshare/campaigns/start`](/docs/partners/api/revshare-campaign-start)   | RevShare offers -> **Start**             |
| [`POST /api/marketer/revshare/campaigns/stop`](/docs/partners/api/revshare-campaign-stop)     | Campaigns -> **Stop**                    |
| [`POST /api/marketer/revshare/campaigns/update`](/docs/partners/api/revshare-campaign-update) | Campaigns -> **Edit** (name, note, tags) |
| [`POST /api/marketer/cpl/orders/accept`](/docs/partners/api/cpl-order-accept)                 | CPL orders -> **Accept**                 |
| [`POST /api/marketer/cpl/orders/reject`](/docs/partners/api/cpl-order-reject)                 | CPL orders -> **Reject**                 |
| [`POST /api/marketer/cpl/orders/stop`](/docs/partners/api/cpl-order-stop)                     | CPL orders -> **Stop**                   |
| [`POST /api/marketer/cpl/campaigns/start`](/docs/partners/api/cpl-campaign-start)             | Find Offers -> **Start**                 |

Every write is a thin proxy to the platform: the same ownership checks, limits, cooldowns and validation messages as in the cabinet apply. Nothing here spends money; writes commit delivery, not payment.

## Rules

* **Full-access key.** The key from **Tools -> API** must be a **Full** key. Read-only keys receive `error_code` `403` with the message `This API key is read-only`.
* **POST with a JSON body.** Send `Content-Type: application/json`. Form bodies are accepted too.
* **Public ids only.** `campaign_id` is a `revc_…` id, `order_id` is a `cplo_…` id, exactly as the list endpoints return them. Numeric internal ids are rejected with `404`.
* **Rate limit: 30 requests per minute** per account (shared by all its keys), separate from the 120 per minute for reads. Over the limit you get `error_code` `429` and a `Retry-After` header.
* **Every write returns the updated object** in `data`, in the same shape as the matching list endpoint (`/api/marketer/revshare/campaigns` for campaigns, `/api/marketer/cpl/orders` for orders), so you can update your local copy without a second request. Some answers also carry a `message` with the platform's confirmation text.

## Response envelope

All responses return HTTP `200`. Check `status`:

<CodeGroup>
  ```json Success theme={null}
  {
    "status": "success",
    "data": { "campaign_id": "revc_abc123", "status": "completed", ... }
  }
  ```

  ```json Error theme={null}
  {
    "status": "error",
    "error_code": 422,
    "message": "Please fill in all campaign fields"
  }
  ```
</CodeGroup>

## Campaign starts

Campaign starts (`revshare/campaigns/start`, `cpl/campaigns/start`) run one at a time per account, the same as in the cabinet. A start sent while another one is still running answers:

```json theme={null}
{
  "status": "error",
  "error_code": 429,
  "message": "Another campaign start is still running. Wait a few seconds and try again"
}
```

Wait a few seconds and retry. Do not retry in a tight loop: the write rate limit counts these attempts.

## 503: service temporarily unavailable

A write is forwarded to the platform. When the platform does not answer in time you get `error_code` `503` with `message` `Service is temporarily unavailable`. The action may still have been applied. Before repeating a campaign start, check the matching read endpoint (`revshare/campaigns` with `of_account_id`, or `cpl/orders` with `client_offer_id`) so you do not start the campaign twice.

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://partners.onlytraffic.com/api/marketer/revshare/campaigns/stop" \
    -H "Authorization: your-api-key-here" \
    -H "Content-Type: application/json" \
    -d '{"campaign_id": "revc_abc123"}'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://partners.onlytraffic.com/api/marketer/revshare/campaigns/stop",
      headers={"Authorization": "your-api-key-here"},
      json={"campaign_id": "revc_abc123"}
  )
  data = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://partners.onlytraffic.com/api/marketer/revshare/campaigns/stop",
    {
      method: "POST",
      headers: {
        "Authorization": "your-api-key-here",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ campaign_id: "revc_abc123" })
    }
  );
  const data = await response.json();
  ```
</CodeGroup>
