## Track one's own interaction as an activity (tenant:crm:write, person)

`POST /api/crm/v1/interactions/{id}/activity`

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

Records the interaction as an activity of its customer – `CALL` for calls and remote sessions, `MEETING` for
meetings – with `interactionId`, the interaction's `addressId` and optionally a lead or opportunity. Only the
person who had the interaction may (`403` `not_your_interaction`; service accounts `403` `person_required`);
it needs a customer (`409` `unassigned`, assign it first) and is tracked once (`409` `already_tracked`; deleting
the activity frees it). Only now crm reads the summary and the transcript from comms and keeps them in the
activity's `meta` (`summary`, `transcript` up to 5 MB, `transcriptContentType`); activity lists leave
`meta.transcript` out, `GET /api/crm/v1/activities/{id}` has it. Without a connection to comms the answer is
`503` (`comms_unavailable`). Only calls, meetings and remote sessions can be tracked (`422` `unsupported_kind`).
When the interaction's customer or person changed meanwhile the answer is `409` (`version_conflict`): load it
again and retry. Emits `crm.activity.created`.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes | The interaction id (comms). |

### Request body

`application/json` (required)

- `body` (string): Note of the activity. (max length 20000)
- `leadId` (string (uuid)): Lead the activity belongs to.
- `opportunityId` (string (uuid)): Opportunity the activity belongs to.
- `subject` (string): Defaults to e.g. „Anruf mit <name or number>“. (max length 255)

Example:

```json
{
  "body": "WLAN im Restaurant fällt aus – Access Point neu gestartet, Ticket angelegt.",
  "subject": "Anruf mit Katrin Stadler"
}
```

### Responses

- **201** The activity recording the interaction (`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`)
- **404** The record does not exist in the token's tenant. (`application/json`)
- **409** The state of the record (or the tenant's settings) does not allow the request; `code` says why. (`application/json`)
- **422** The interaction is of a kind that cannot be tracked (`unsupported_kind`), or the lead or opportunity does not exist (`invalid_reference`). (`application/json`)
- **500** Unexpected error; details are only logged. (`application/json`)
- **502** An upstream service (masterdata, VAT check) failed, is switched off or is not configured. (`application/json`)
- **503** CRM has no connection to comms (`comms_unavailable`). (`application/json`)

Fields of the 201 answer:

- `bookedMinutes` (integer, nullable, required, read-only): Work HR booked on the activity (subject `crm:activity:<id>`, worked minus breaks, ADR 0040); filled by `GET /activities/{id}` and the activity list, null there when HR does not answer (never an error) and in answers of writes.
- `createdAt` (string (date-time), required): Creation time.
- `customerNo` (string, required): Customer number of the tenant.
- `id` (string (uuid), required): Id of the activity.
- `kind` (ActivityKind, required): `SYSTEM` entries are history written by the CRM and cannot be created or changed. (one of `NOTE`, `CALL`, `MEETING`, `EMAIL`, `TASK`, `SYSTEM`)
- `meta` (object, required): Details of `SYSTEM` entries (for example the old and new stage); of a tracked interaction `interactionId`, `provider`, `summary` and `transcript` (left out by lists); empty otherwise.
- `subject` (string, required): Subject (one line).
- `tenantName` (string, required): Tenant name.
- `updatedAt` (string (date-time), required): Time of the last change.
- `addressId` (string (uuid)): Masterdata address the activity belongs to; omitted when not set.
- `assigneeEmail` (string): Employee the task is assigned to.
- `body` (string): Omitted when not set (and after anonymisation).
- `campaignId` (string (uuid)): Campaign the activity belongs to; omitted when not set.
- `createdBy` (string): E-mail of the creating person; omitted for system entries.
- `createdByName` (string): Name of the creating person; omitted when not known.
- `doneAt` (string (date-time), read-only): Completion time of a task.
- `doneBy` (string, read-only): Who completed the task.
- `dueAt` (string (date-time)): Due date of a task.
- `interactionId` (string (uuid), read-only): The comms interaction a tracked call or meeting records.
- `leadId` (string (uuid)): Lead the activity belongs to; omitted when not set.
- `opportunityId` (string (uuid)): Opportunity the activity belongs to; omitted when not set.
- `recordName` (string, read-only): Title of the opportunity, else company of the lead the activity belongs to; set by the activity list only.

Example 201 answer:

```json
{
  "assigneeEmail": "lena.vogel@muster-it.example",
  "body": "Frau Gaßner wollte die Freigabe des Budgets mit dem Gesellschafter klären.",
  "bookedMinutes": 25,
  "createdAt": "2026-11-12T16:45:00Z",
  "createdBy": "lena.vogel@muster-it.example",
  "createdByName": "Lena Vogel",
  "customerNo": "99999",
  "dueAt": "2026-11-20T09:00:00Z",
  "id": "1d3f5b7d-9e1a-4c3d-8f5b-9a1c3e5b7d9f",
  "kind": "TASK",
  "leadId": "5b7d9f1a-3c5e-4a7b-9d1f-3a5c7e9b1d3f",
  "meta": {},
  "opportunityId": "7d9f1b3d-5e7a-4c9b-8f1d-5c7e9a1b3d5f",
  "recordName": "WLAN Sudhaus und Lager",
  "subject": "Angebot WLAN Sudhaus nachfassen",
  "tenantName": "DEMO",
  "updatedAt": "2026-11-12T16:45:00Z"
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/crm/v1/interactions/3f2b8c1e-7d4a-4e9b-9c2a-5b1d6e8f0a12/activity' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"body":"WLAN im Restaurant fällt aus – Access Point neu gestartet, Ticket angelegt.","subject":"Anruf mit Katrin Stadler"}'
```
