# Campaigns

Registering a destination, addressed by your id or ours.

## Opening a campaign

A campaign is one destination URL. One brand offer is one campaign; a brand running three offers wants three, because the destination is what a click resolves to.

```bash
curl -X POST https://track.acrune.com/v1/campaigns \
  -H "Authorization: Bearer $ACRUNE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "externalId": "cmp_4471",
       "name": "Brand X, January clips",
       "destinationUrl": "https://brandx.example/offer",
       "clickParam": "subid"
     }'
```

clickParam is whatever your destination already calls its own tracking parameter. We set it to the click id on the way through, so the identifier exists on the far side if anything downstream ever wants to read it. subid suits most affiliate platforms; a Stripe-native destination usually wants client_reference_id. If the destination URL contains the literal {click_id}, we substitute in place instead of appending.

## Calling it twice

Pass externalId, your own id for the campaign, and creation becomes idempotent. Called again with the same one it returns the existing campaign with 200 rather than opening a second with the same name pointed somewhere else, which is what a webhook retry would otherwise do.

| Status | Means |
| --- | --- |
| 201 | The campaign was opened by this call. |
| 200 | One already existed with that externalId, and is returned unchanged. |

> Without an externalId there is nothing to be idempotent on, so every call creates a campaign. Pass it.

## Addressing and listing

Anywhere a campaign is named, in a path or in an enrolment body, your externalId works as well as our id. That is what lets an integration store nothing of ours.

```bash
# Both of these address the same campaign.
curl https://track.acrune.com/v1/campaigns/cmp_4471 -H "Authorization: Bearer $ACRUNE_KEY"
curl https://track.acrune.com/v1/campaigns/4d6f... -H "Authorization: Bearer $ACRUNE_KEY"
```

Listing is paged with limit and offset, newest first, and carries hasMore rather than a total, a count over a growing table is a second query to answer a question nobody asked.

```bash
curl "https://track.acrune.com/v1/campaigns?limit=50&offset=0" \
  -H "Authorization: Bearer $ACRUNE_KEY"
```
