---
title: "Update an activity's content"
method: PATCH
path: "/activities/{activityId}"
tags: ["Activity Records"]
---

# Update an activity's content

`PATCH /activities/{activityId}`

## Request

- Base URL: `https://api.surense.com/api/v1`
- URL: `https://api.surense.com/api/v1/activities/{activityId}`
- Auth: OAuth 2
  - Client credentials
  - Token URL: `https://api.surense.com/oauth/token`

Replaces the content (and, if provided, the mentions) of an existing activity record. The type and parent entity are fixed at creation.

**Authorization.** Only the user who created the activity may edit it. The caller must also be able to access the parent entity and hold the user permission matching its type: `employers:write`, `leads:update`, `workflows:update`, `customers:update` or `meetings:update`. No OAuth2 scope beyond a valid token is required.

**Behaviour.** The content is sanitized as on creation. If it differs from the current content, an audit entry (before/after) is written and `lastEditedAt`/`lastEditedBy` are set. If the content or the mentions changed, an `ActivityUpdated` event is published. Sending identical content and mentions is a no-op that still returns `200 OK` with the record.

**Errors.** `404` if the activity or a mentioned user does not exist in the caller's tenant; `400` if the request is invalid (empty content, invalid mentions), and `400` with error code `40000` if the caller is not the creator, lacks the permission, or cannot access the parent entity.

## Path parameters

- `activityId` string, uuid, required

## Request body

- UpdateActivityRequest: Request to replace the content (and, if provided, the mentions) of an activity record
  - `jsonContent` JsonNode: Rich-text content of the activity as JSON (the editor's document model), stored alongside htmlContent
    - `empty` boolean
    - `array` boolean
    - `null` boolean
    - `object` boolean
    - `float` boolean
    - `container` boolean
    - `string` boolean
    - `pojo` boolean
    - `floatingPointNumber` boolean
    - `short` boolean
    - `int` boolean
    - `long` boolean
    - `valueNode` boolean
    - `missingNode` boolean
    - `nodeType` 'ARRAY' | 'BINARY' | 'BOOLEAN' | 'MISSING' | 'NULL' | 'NUMBER' | 'OBJECT' | 'POJO' | 'STRING'
    - `integralNumber` boolean
    - `double` boolean
    - `bigDecimal` boolean
    - `bigInteger` boolean
    - `textual` boolean
    - `boolean` boolean
    - `binary` boolean
    - `number` boolean
    - `embeddedValue` boolean
  - `htmlContent` string, required: New activity content as HTML. Sanitized on save as on creation; must not be blank.
  - `mentions` ActivityMention[]: Mentions present in the activity
    - `type` string
    - `entityId` string, uuid
    - `label` string
    - `order` integer

## Response `200`

The updated (or unchanged) activity record

- ActivityRecordValue: An activity record logged against an employer, customer, lead, workflow or meeting, with its replies and reactions
  - `tenantId` string, uuid
  - `createdDate` string, date-time
  - `createdBy` string, uuid
  - `creatorName` string
  - `lastModifiedDate` string, date-time
  - `lastModifiedBy` string, uuid
  - `version` integer
  - `id` string, uuid: Activity record ID
  - `typeId` string, uuid: ID of the activity type
  - `employerId` string, uuid: Employer the activity is logged against, if any
  - `customerId` string, uuid: Customer the activity is linked to, if any (also set for lead, workflow and meeting activities that relate to a customer)
  - `leadId` string, uuid: Lead the activity is linked to, if any
  - `workflowId` string, uuid: Workflow the activity is logged against, if any
  - `meetingId` string, uuid: Meeting the activity is logged against, if any
  - `activityDate` string, date-time: When the activity was logged (ISO-8601, UTC)
  - `jsonContent` JsonNode: Rich-text content of the activity as JSON (the editor's document model), stored alongside htmlContent
    - `empty` boolean
    - `array` boolean
    - `null` boolean
    - `object` boolean
    - `float` boolean
    - `container` boolean
    - `string` boolean
    - `pojo` boolean
    - `floatingPointNumber` boolean
    - `short` boolean
    - `int` boolean
    - `long` boolean
    - `valueNode` boolean
    - `missingNode` boolean
    - `nodeType` 'ARRAY' | 'BINARY' | 'BOOLEAN' | 'MISSING' | 'NULL' | 'NUMBER' | 'OBJECT' | 'POJO' | 'STRING'
    - `integralNumber` boolean
    - `double` boolean
    - `bigDecimal` boolean
    - `bigInteger` boolean
    - `textual` boolean
    - `boolean` boolean
    - `binary` boolean
    - `number` boolean
    - `embeddedValue` boolean
  - `htmlContent` string: Sanitized HTML content of the activity
  - `lastEditedAt` string, date-time: When the content was last edited (ISO-8601, UTC); null if never edited
  - `lastEditedBy` string, uuid: ID of the user who last edited the content; null if never edited
  - `reactions` ActivityReaction[]: Reactions of users on the activity, oldest first
    - `id` string, uuid
    - `userId` string, uuid
    - `userName` string
    - `reaction` string
    - `reactedAt` string, date-time
  - `replies` ActivityReply[]: Replies to the activity, oldest first
    - `id` string, uuid
    - `userId` string, uuid
    - `userName` string
    - `jsonContent` JsonNode: Rich-text content of the activity as JSON (the editor's document model), stored alongside htmlContent
      - `empty` boolean
      - `array` boolean
      - `null` boolean
      - `object` boolean
      - `float` boolean
      - `container` boolean
      - `string` boolean
      - `pojo` boolean
      - `floatingPointNumber` boolean
      - `short` boolean
      - `int` boolean
      - `long` boolean
      - `valueNode` boolean
      - `missingNode` boolean
      - `nodeType` 'ARRAY' | 'BINARY' | 'BOOLEAN' | 'MISSING' | 'NULL' | 'NUMBER' | 'OBJECT' | 'POJO' | 'STRING'
      - `integralNumber` boolean
      - `double` boolean
      - `bigDecimal` boolean
      - `bigInteger` boolean
      - `textual` boolean
      - `boolean` boolean
      - `binary` boolean
      - `number` boolean
      - `embeddedValue` boolean
    - `htmlContent` string
    - `createdAt` string, date-time
    - `updatedAt` string, date-time
    - `mentions` ActivityMention[]
      - `type` string
      - `entityId` string, uuid
      - `label` string
      - `order` integer
    - `reactions` ActivityReaction[]
      - `id` string, uuid
      - `userId` string, uuid
      - `userName` string
      - `reaction` string
      - `reactedAt` string, date-time

## Other responses

- `400`: Invalid request (empty content, invalid mentions), or (error code 40000) the caller is not the creator, lacks the permission for the parent entity type, or cannot access the parent entity
- `404`: Activity or mentioned user not found

---

[API](https://skmtc.dev/surense/apis/activity-api.md) - [All operations](https://skmtc.dev/surense/apis/activity-api/llms.txt) - [OpenAPI document](https://skmtc.dev/surense/apis/activity-api/revisions/1fa9c003b93b?raw)
