# Campaigns API

> Campaigns and their members. Every route, its parameters and fields.

Campaigns and their members. 10 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `GET /v1/campaigns` | List campaigns |
| `POST /v1/campaigns` | Create a campaign |
| `GET /v1/campaigns/{id}` | Get a campaign |
| `PATCH /v1/campaigns/{id}` | Update a campaign |
| `DELETE /v1/campaigns/{id}` | Delete a campaign (soft delete) |
| `POST /v1/campaigns/{id}/restore` | Restore a deleted campaign |
| `GET /v1/campaigns/{id}/members` | A campaign's members |
| `POST /v1/campaigns/{id}/members` | Add members to a campaign |
| `PATCH /v1/campaigns/{id}/members/{contactId}` | Change a member's status |
| `DELETE /v1/campaigns/{id}/members/{contactId}` | Remove a member (soft delete) |

## List campaigns

`GET https://staging-api.naruskacrm.com/v1/campaigns`

Declared filters only (an unknown one is refused); `q` searches the name (accent- and case-insensitive); `sort` takes a declared field, `-` for descending. Pass `next_cursor` back as `cursor`.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `limit` | query | integer |  | 1–200, default `50` |
| `cursor` | query | string |  | next_cursor of the previous page. 1–400 characters |
| `owner` | query | `me` or string (uuid) |  |  |
| `status` | query | `planned`, `active`, `completed`, `cancelled` |  |  |
| `type` | query | `email`, `event`, `webinar`, `advertising`, `social`, `partner`, `other` |  |  |
| `date_from` | query | string (date) |  | Campaigns running on or after this day |
| `date_to` | query | string (date) |  | Campaigns running on or before this day |
| `q` | query | string |  | Name or utm_campaign. 1–200 characters |
| `sort` | query | `name`, `-name`, `start_date`, `-start_date`, `status`, `-status`, `owner_name`, `-owner_name`, `created_at`, `-created_at`, `updated_at`, `-updated_at` |  | Sort by name, start_date, status, owner_name, created_at, updated_at; prefix "-" for descending. |
| `updated_since` | query | string (date-time) |  |  |
| `include_deleted` | query | `true`, `false` |  |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [Campaign](/api/reference/objects.md#campaign) | yes |  |
| `next_cursor` | string or null | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create a campaign

`POST https://staging-api.naruskacrm.com/v1/campaigns`

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | yes | 1–200 characters |
| `type` | `email`, `event`, `webinar`, `advertising`, `social`, `partner`, `other` | yes |  |
| `status` | `planned`, `active`, `completed`, `cancelled` |  |  |
| `start_date` | string (date) or null |  |  |
| `end_date` | string (date) or null |  |  |
| `budget` | number or null |  | 0–10000000000000000 |
| `currency` | string |  |  |
| `description` | string or null |  | at most 10000 characters |
| `utm_campaign` | string or null |  | 1–200 characters |
| `owner_user_id` | string (uuid) or null |  |  |
| `owner_team_id` | string (uuid) or null |  |  |
| `source_system` | string or null |  | 1–100 characters |
| `source_id` | string or null |  | 1–500 characters |

### Response 201

Returns: [Campaign](/api/reference/objects.md#campaign).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Get a campaign

`GET https://staging-api.naruskacrm.com/v1/campaigns/{id}`

`include` adds `children` (emails, phones, addresses, affiliations, deal contacts, attendees), `tags` and `related` (the first 10 of each related list), so a record page loads in one request.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `include` | query | string |  | at most 100 characters |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes |  |
| `company_id` | string (uuid) | yes |  |
| `created_at` | string (date-time) | yes |  |
| `updated_at` | string (date-time) | yes |  |
| `created_by` | string (uuid) or null | yes |  |
| `updated_by` | string (uuid) or null | yes |  |
| `deleted_at` | string (date-time) or null | yes |  |
| `deleted_by` | string (uuid) or null | yes |  |
| `name` | string | yes |  |
| `type` | `email`, `event`, `webinar`, `advertising`, `social`, `partner`, `other` | yes |  |
| `status` | `planned`, `active`, `completed`, `cancelled` | yes |  |
| `start_date` | string (date) or null | yes |  |
| `end_date` | string (date) or null | yes |  |
| `budget` | number or null | yes |  |
| `currency` | string | yes |  |
| `base_currency` | string |  |  |
| `description` | string or null | yes |  |
| `utm_campaign` | string or null | yes |  |
| `owner_user_id` | string (uuid) or null | yes |  |
| `owner_user_name` | string or null |  |  |
| `owner_team_id` | string (uuid) or null | yes |  |
| `owner_team_name` | string or null |  |  |
| `owner_name` | string or null |  |  |
| `member_count` | number |  |  |
| `added_count` | number |  |  |
| `sent_count` | number |  |  |
| `responded_count` | number |  |  |
| `attended_count` | number |  |  |
| `deal_count` | number |  |  |
| `won_count` | number |  |  |
| `won_amount_base` | number |  |  |
| `source_system` | string or null | yes |  |
| `source_id` | string or null | yes |  |
| `children` | object |  |  |
| `tags` | array of [Tag](/api/reference/objects.md#tag) |  |  |
| `related` | object |  |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Update a campaign

`PATCH https://staging-api.naruskacrm.com/v1/campaigns/{id}`

JSON merge patch: send only the fields to change. custom is merged per key; a null value removes a key.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string |  | 1–200 characters |
| `type` | `email`, `event`, `webinar`, `advertising`, `social`, `partner`, `other` |  |  |
| `status` | `planned`, `active`, `completed`, `cancelled` |  |  |
| `start_date` | string (date) or null |  |  |
| `end_date` | string (date) or null |  |  |
| `budget` | number or null |  | 0–10000000000000000 |
| `currency` | string |  |  |
| `description` | string or null |  | at most 10000 characters |
| `utm_campaign` | string or null |  | 1–200 characters |
| `owner_user_id` | string (uuid) or null |  |  |
| `owner_team_id` | string (uuid) or null |  |  |
| `source_system` | string or null |  | 1–100 characters |
| `source_id` | string or null |  | 1–500 characters |

### Response 200

Returns: [Campaign](/api/reference/objects.md#campaign).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Delete a campaign (soft delete)

`DELETE https://staging-api.naruskacrm.com/v1/campaigns/{id}`

Soft delete (admins only). The record and its children are kept for 30 days and can be restored.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Restore a deleted campaign

`POST https://staging-api.naruskacrm.com/v1/campaigns/{id}/restore`

Admins only. Children and links deleted with the record come back with it.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

Returns: [Campaign](/api/reference/objects.md#campaign).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## A campaign's members

`GET https://staging-api.naruskacrm.com/v1/campaigns/{id}/members`

Members whose contact you can see. Filter by member_status, search the contact's name with `q`; `sort` takes a declared field.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `limit` | query | integer |  | 1–200, default `50` |
| `cursor` | query | string |  | next_cursor of the previous page. 1–400 characters |
| `member_status` | query | `added`, `sent`, `responded`, `attended` |  |  |
| `q` | query | string |  | The contact's name. 1–200 characters |
| `sort` | query | `contact_name`, `-contact_name`, `member_status`, `-member_status`, `responded_at`, `-responded_at`, `created_at`, `-created_at`, `updated_at`, `-updated_at` |  | Sort by contact_name, member_status, responded_at, created_at, updated_at; prefix "-" for descending. |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [CampaignMember](/api/reference/objects.md#campaignmember) | yes |  |
| `next_cursor` | string or null | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Add members to a campaign

`POST https://staging-api.naruskacrm.com/v1/campaigns/{id}/members`

Up to 500 contact_ids, or a contacts filter (status, category, owner, tag, city, q: the contacts list's filters) that is expanded under your access; more than 500 matches is refused (422 too_many). Contacts already in the campaign are skipped; with an explicit member_status they are moved to it. One operation, one undo.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `contact_ids` | array of string (uuid) |  | at most 500 items |
| `filter` | object |  |  |
| `filter.status` | string |  | at most 63 characters |
| `filter.category` | `lead`, `customer`, `inactive` |  |  |
| `filter.owner` | `me` or string (uuid) |  |  |
| `filter.tag` | string |  | at most 100 characters |
| `filter.city` | string |  | 1–200 characters |
| `filter.q` | string |  | 1–200 characters |
| `member_status` | `added`, `sent`, `responded`, `attended` |  |  |

### Response 200

Returns: [AddCampaignMembersResult](/api/reference/objects.md#addcampaignmembersresult).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Change a member's status

`PATCH https://staging-api.naruskacrm.com/v1/campaigns/{id}/members/{contactId}`

member_status: added, sent, responded or attended. responded_at is set the first time it becomes responded or attended.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `contactId` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `member_status` | `added`, `sent`, `responded`, `attended` | yes |  |

### Response 200

Returns: [CampaignMember](/api/reference/objects.md#campaignmember).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Remove a member (soft delete)

`DELETE https://staging-api.naruskacrm.com/v1/campaigns/{id}/members/{contactId}`

The membership can be brought back with undo.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `contactId` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

