---
title: "Set View Portion"
method: POST
path: "/{databaseId}/viewportions/"
tags: ["User-Item Interactions"]
---

# Set View Portion

`POST /{databaseId}/viewportions/`

Sets viewed portion of an item (for example a video or article) by a user (at a session).
If you send a new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated.

## Path parameters

- `databaseId` string, required

## Request body

- ViewPortion
  - `userId` string, required — User who viewed a portion of the item
  - `itemId` string, required — Viewed item
  - `portion` number, double, required — Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). It should be the actual viewed part of the item, no matter the seeking. For example, if the user seeked immediately to half of the item and then viewed 10% of the item, the `portion` should still be `0.1`.
  - `sessionId` string — ID of the session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc., depending on the language).
  - `timestamp` union — UTC timestamp of the view portion as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
    - string, double
    - number, double
  - `cascadeCreate` boolean — Sets whether the given user/item should be created if not present in the database.
  - `recommId` string — If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
  - `additionalData` object — A dictionary of additional data for the interaction.
  - `autoPresented` boolean — Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`.
  - `timeSpent` number, double — The duration (in seconds) that the user viewed the item. In update requests, this value may only increase and is required only if it has changed.

## Response `200`

Successful operation.

## Other responses

- `400` — The `userId`, `itemId` or `sessionId` does not match ^[a-zA-Z0-9_\-:@\.]+$, or the `portion` is not a real number from [0.0,1.0].
- `404` — The `cascadeCreate` is not set true and the `userId` or the `itemId` were found in the database. If there is no additional info in the JSON response, you probably have an error in your URL.
- `409` — A view portion of the exact same `userId`, `itemId`, and a greater or equal `timestamp` (or a greater `portion`) is already present in the database. In many cases, you may consider this code a success – it only tells you that nothing has been written to the database.

---

[API](https://skmtc.dev/recombee/apis/recombee-api.md) · [All operations](https://skmtc.dev/recombee/apis/recombee-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/recombee/recombee-api/revisions/a9c9c33eb2e8/schema)
