## Create a campaign (tenant:crm:write)

`POST /api/crm/v1/campaigns`

Module: CRM · operationId: `createCampaign` · Tag: Campaigns · Auth: access token (`Authorization: Bearer <accessToken>`)

Defaults are type `EMAIL`, status `PLANNING`, budget and cost `0`. Emits `crm.campaign.created`.

### Request body

`application/json` (required)

- `name` (string, required): Name of the campaign. (max length 255)
- `actualCost` (number (double)): Cost so far. (max 9999999999)
- `budget` (number (double)): Planned budget. (max 9999999999)
- `description` (string): Description. (max length 10000)
- `endDate` (string (date-time)): Not before `startDate`.
- `startDate` (string (date-time)): Start of the campaign.
- `status` (object): Default `PLANNING`.
- `type` (object): Default `EMAIL`.

Example:

```json
{
  "budget": 5000,
  "description": "Mailing an Bestandskunden mit Gaskessel älter als 15 Jahre.",
  "endDate": "2027-04-30T00:00:00Z",
  "name": "Frühjahrsaktion Wärmepumpen",
  "startDate": "2027-03-01T00:00:00Z",
  "type": "EMAIL"
}
```

### Responses

- **201** Created (`application/json`)
- **400** Invalid input (`invalid`): `field` names the first invalid field, `details.fields` every one (JSON paths for
bodies, parameter names for the query). Some refusals have their own code (`invalid_sort`,
`invalid_stages`, `invalid_custom_fields`, `convert_target_required`, `invalid_csv`, …).
 (`application/json`)
- **401** Missing, invalid or expired token (no body).
- **403** The token lacks the permission (`insufficient permissions`) or has no active tenant.
 (`application/json`)
- **500** Unexpected error; details are only logged. (`application/json`)

Fields of the 201 answer:

- `actualCost` (number (double), required): Cost so far.
- `budget` (number (double), required): Planned budget.
- `createdAt` (string (date-time), required): Creation time.
- `customerNo` (string, required): Customer number of the tenant.
- `id` (string (uuid), required): Id of the campaign.
- `name` (string, required): Name of the campaign.
- `status` (CampaignStatus, required): (one of `PLANNING`, `ACTIVE`, `COMPLETED`, `CANCELLED`)
- `tenantName` (string, required): Tenant name.
- `type` (CampaignType, required): (one of `EMAIL`, `WEBINAR`, `TRADE_SHOW`, `ADS`, `EVENT`, `SOCIAL_MEDIA`, `OTHER`)
- `updatedAt` (string (date-time), required): Time of the last change.
- `description` (string): Omitted when not set.
- `endDate` (string (date-time)): Omitted when not set.
- `startDate` (string (date-time)): Omitted when not set.

Example 201 answer:

```json
{
  "actualCost": 11340,
  "budget": 12000,
  "createdAt": "2026-04-16T14:00:00Z",
  "customerNo": "99999",
  "description": "Gemeinschaftsstand mit Nordlicht IT-Distribution auf der regionalen IT-Messe; Schwerpunkt Netzwerk, WLAN und Managed Services.",
  "endDate": "2026-07-20T00:00:00Z",
  "id": "2a4c6e8a-0b2d-4f4a-8c6e-8a0c2e4a6c8e",
  "name": "Messe IT-Business Ostbayern",
  "startDate": "2026-07-18T00:00:00Z",
  "status": "COMPLETED",
  "tenantName": "DEMO",
  "type": "TRADE_SHOW",
  "updatedAt": "2026-08-18T09:00:00Z"
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/crm/v1/campaigns' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"budget":5000,"description":"Mailing an Bestandskunden mit Gaskessel älter als 15 Jahre.","endDate":"2027-04-30T00:00:00Z","name":"Frühjahrsaktion Wärmepumpen","startDate":"2027-03-01T00:00:00Z","type":"EMAIL"}'
```
