# Delete campaign

POST `https://app.iteras.dk/api/campaigns/deletecampaign/`

The API key must allow "Change campaigns".

Deletes a campaign that is not in use, e.g. one created by mistake. A campaign that has been used can be made inactive instead by [updating it](/api/docs/server/updatecampaign.md).

## Parameters

- `id` (string, required): The Iteras ID of the campaign, its `id` in the [list of campaigns](/api/docs/server/campaigns.md), also returned when [creating it](/api/docs/server/createcampaign.md).

## Examples

```http
POST /api/campaigns/deletecampaign/ HTTP/1.1
Content-Type: application/json
```

```json
{
  "id": "308"
}
```

## Return value

On success the endpoint returns the Iteras ID and the campaign ID of the deleted campaign:

```json
{ "deleted": true, "id": "308", "campaign_id": "3i" }
```

## Errors

Invalid JSON returns 400, and an unknown `id` returns 404.

If the campaign is in use, nothing is deleted and 422 is returned, with one error for each kind of reference that says where it is used:

```json
{ "deleted": false, "errors": { "id": [
  "Subscriptions refer to the campaign. It cannot be deleted.",
  "Other campaigns continue on it: 3i: 3 issues.",
  "It is used in the ordering form \"Yearly offer\"."
] } }
```

The campaign is left alone: the subscriptions' history refers to it, deleting it would stop the renewal or switch that continues on it, and the ordering forms, recipient layouts, orders and automations that use it would be left pointing at a campaign that is gone. A campaign that subscriptions have been on can never be deleted, only made inactive; one that is only used in those other settings can be taken off them and deleted afterwards.