# Activities API

> Tasks, meetings and calls; marking them done. Every route, its parameters and fields.

Tasks, meetings and calls; marking them done. 13 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `GET /v1/activities` | List activities |
| `POST /v1/activities` | Create a activity |
| `GET /v1/activities/{id}` | Get a activity |
| `PATCH /v1/activities/{id}` | Update a activity |
| `DELETE /v1/activities/{id}` | Delete a activity (soft delete) |
| `POST /v1/activities/{id}/restore` | Restore a deleted activity |
| `POST /v1/activities/{id}/complete` | Mark an activity done |
| `POST /v1/activities/{id}/reopen` | Reopen a done activity |
| `POST /v1/activities/{id}/contacts` | Add a person to an activity |
| `DELETE /v1/activities/{id}/contacts/{contactId}` | Remove a person from an activity |
| `GET /v1/activity-types` | Activity types |
| `POST /v1/activity-types` | Add an activity type (admins) |
| `PATCH /v1/activity-types/{id}` | Rename, reorder, archive or make default an activity type (admins) |

## List activities

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

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) |  |  |
| `category` | query | `task`, `meeting`, `call` |  |  |
| `type` | query | string |  | Activity type api_key or id. At most 63 characters |
| `state` | query | `open`, `done` |  |  |
| `due_from` | query | string (date) |  |  |
| `due_to` | query | string (date) |  |  |
| `starts_from` | query | string (date-time) |  |  |
| `starts_to` | query | string (date-time) |  |  |
| `done_from` | query | string (date) or string (date-time) |  | Done (done_at) on or after |
| `done_to` | query | string (date) or string (date-time) |  | Done (done_at) on or before |
| `created_from` | query | string (date) or string (date-time) |  |  |
| `created_to` | query | string (date) or string (date-time) |  |  |
| `contact_id` | query | string (uuid) |  |  |
| `account_id` | query | string (uuid) |  |  |
| `opportunity_id` | query | string (uuid) |  |  |
| `case_id` | query | string (uuid) |  |  |
| `q` | query | string |  | 1–200 characters |
| `sort` | query | `subject`, `-subject`, `type_name`, `-type_name`, `due_date`, `-due_date`, `starts_at`, `-starts_at`, `done_at`, `-done_at`, `account_name`, `-account_name`, `opportunity_name`, `-opportunity_name`, `primary_contact_name`, `-primary_contact_name`, `owner_name`, `-owner_name`, `created_at`, `-created_at`, `updated_at`, `-updated_at` |  | Sort by subject, type_name, due_date, starts_at, done_at, account_name, opportunity_name, primary_contact_name, 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 [Activity](/api/reference/objects.md#activity) | yes |  |
| `next_cursor` | string or null | yes |  |

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

## Create a activity

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `activity_type_id` | string (uuid) |  |  |
| `type` | string |  | Activity type api_key |
| `category` | `task`, `meeting`, `call` |  | Use the default type of this category |
| `subject` | string | yes | 1–500 characters |
| `description` | string or null |  | at most 100000 characters |
| `owner_user_id` | string (uuid) or null |  |  |
| `owner_team_id` | string (uuid) or null |  |  |
| `due_date` | string (date) or null |  |  |
| `starts_at` | string (date-time) or null |  |  |
| `ends_at` | string (date-time) or null |  |  |
| `location` | string or null |  | at most 500 characters |
| `done_at` | string (date-time) or null |  |  |
| `account_id` | string (uuid) or null |  |  |
| `opportunity_id` | string (uuid) or null |  |  |
| `case_id` | string (uuid) or null |  |  |
| `contacts` | array of object |  | at most 50 items |
| `contacts[].contact_id` | string (uuid) | yes |  |
| `contacts[].is_primary` | boolean |  |  |
| `source_system` | string or null |  | 1–100 characters |
| `source_id` | string or null |  | 1–500 characters |

### Response 201

Returns: [Activity](/api/reference/objects.md#activity).

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

## Get a activity

`GET https://staging-api.naruskacrm.com/v1/activities/{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 |  |
| `activity_type_id` | string (uuid) | yes |  |
| `type_api_key` | string | yes |  |
| `type_name` | string | yes |  |
| `category` | `task`, `meeting`, `call` | yes |  |
| `subject` | string | yes |  |
| `description` | string or null | yes | at most 100000 characters |
| `owner_user_id` | string (uuid) or null | yes |  |
| `owner_team_id` | string (uuid) or null | yes |  |
| `due_date` | string (date) or null | yes |  |
| `starts_at` | string (date-time) or null | yes |  |
| `ends_at` | string (date-time) or null | yes |  |
| `location` | string or null | yes | at most 500 characters |
| `done_at` | string (date-time) or null | yes |  |
| `account_id` | string (uuid) or null | yes |  |
| `opportunity_id` | string (uuid) or null | yes |  |
| `case_id` | string (uuid) or null | yes |  |
| `is_done` | boolean | yes |  |
| `account_name` | string or null | yes |  |
| `opportunity_name` | string or null | yes |  |
| `case_title` | string or null |  |  |
| `case_display_number` | string or null |  |  |
| `primary_contact_id` | string (uuid) or null | yes |  |
| `primary_contact_name` | string or null | yes |  |
| `contact_ids` | array of string (uuid) | yes |  |
| `contact_count` | number | yes |  |
| `owner_user_name` | string or null | yes |  |
| `owner_team_name` | string or null | yes |  |
| `owner_name` | string or null | yes |  |
| `source_system` | string or null | yes |  |
| `source_id` | string or null | 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 |  |
| `recent_similar` | object or null |  |  |
| `recent_similar.id` | string (uuid) | yes |  |
| `recent_similar.created_at` | string (date-time) | yes |  |
| `recent_similar.primary_contact_name` | string or null | yes |  |
| `recent_similar.opportunity_name` | 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 activity

`PATCH https://staging-api.naruskacrm.com/v1/activities/{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 |
| --- | --- | --- | --- |
| `activity_type_id` | string (uuid) |  |  |
| `type` | string |  | Activity type api_key |
| `subject` | string |  | 1–500 characters |
| `description` | string or null |  | at most 100000 characters |
| `owner_user_id` | string (uuid) or null |  |  |
| `owner_team_id` | string (uuid) or null |  |  |
| `due_date` | string (date) or null |  |  |
| `starts_at` | string (date-time) or null |  |  |
| `ends_at` | string (date-time) or null |  |  |
| `location` | string or null |  | at most 500 characters |
| `done_at` | string (date-time) or null |  |  |
| `account_id` | string (uuid) or null |  |  |
| `opportunity_id` | string (uuid) or null |  |  |
| `case_id` | string (uuid) or null |  |  |

### Response 200

Returns: [Activity](/api/reference/objects.md#activity).

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

## Delete a activity (soft delete)

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

Soft delete. Anyone who can edit the activity may delete it; admins can restore it for 30 days.

### 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 activity

`POST https://staging-api.naruskacrm.com/v1/activities/{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: [Activity](/api/reference/objects.md#activity).

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

## Mark an activity done

`POST https://staging-api.naruskacrm.com/v1/activities/{id}/complete`

Sets done_at (now unless given). Idempotent: an activity that is already done is returned unchanged.

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `done_at` | string (date-time) |  | When it was done; default now |

### Response 200

Returns: [Activity](/api/reference/objects.md#activity).

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

## Reopen a done activity

`POST https://staging-api.naruskacrm.com/v1/activities/{id}/reopen`

Clears done_at. Idempotent: an open activity is returned unchanged.

### Parameters

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

### Response 200

Returns: [Activity](/api/reference/objects.md#activity).

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

## Add a person to an activity

`POST https://staging-api.naruskacrm.com/v1/activities/{id}/contacts`

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `contact_id` | string (uuid) | yes |  |
| `is_primary` | boolean |  |  |

### Response 201

Returns: [Activity](/api/reference/objects.md#activity).

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

## Remove a person from an activity

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

Refused when it is the activity's last link; delete the activity instead.

### 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).

## Activity types

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

The company's activity types with their category (task, meeting, call), api_key and description. Archived types are left out unless include_archived=true.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `include_archived` | query | `true`, `false` |  |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [ActivityType](/api/reference/objects.md#activitytype) | yes |  |

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

## Add an activity type (admins)

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `api_key` | string | yes |  |
| `name` | string | yes | 1–200 characters |
| `description` | string or null |  | at most 500 characters |
| `category` | `task`, `meeting`, `call` | yes |  |
| `sort_order` | integer |  |  |
| `is_default` | boolean |  |  |

### Response 201

Returns: [ActivityType](/api/reference/objects.md#activitytype).

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

## Rename, reorder, archive or make default an activity type (admins)

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

The category cannot change once an activity uses the type; a default type cannot be archived. api_key never changes.

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string |  | 1–200 characters |
| `description` | string or null |  | at most 500 characters |
| `category` | `task`, `meeting`, `call` |  |  |
| `sort_order` | integer |  |  |
| `is_default` | boolean |  |  |
| `archived` | boolean |  |  |

### Response 200

Returns: [ActivityType](/api/reference/objects.md#activitytype).

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

