---
title: "Batch upsert extension reports"
method: POST
path: "/api/v1/extension/reports/batch-upsert/"
tags: ["Extension Reports"]
---

# Batch upsert extension reports

`POST /api/v1/extension/reports/batch-upsert/`

Create or update multiple Integrito report-data records in one request. Each item in the JSON array may include an optional `id` and/or `item_id` field. When `id` is present, the matching record is updated by id and `item_id` (if provided) is written as the new value. When `id` is absent but `item_id` is provided, the record owned by the current user with that `item_id` is updated, or a new record is created with that `item_id` when none matches. When both are absent, a new record is created. `updated_at` is set to the current server time on updates; `created_at` is set on creates. Returns `201 CREATED` if at least one item was newly created; returns `200 OK` if all items were updates. Returns `400` if any `item_id` collides with another record owned by the authenticated user or appears more than once for distinct records inside the batch. Returns `403` if any referenced text or report `id` exists but belongs to another user. Returns `404` if any referenced text or report `id` does not exist.

## Request body

- object[]
  - `id` integer, nullable — Existing report ID. When present, the record with this id is looked up and updated (`item_id` in the body is written as the new value but is not used for lookup). Pass only `id` or `item_id` when an update is needed.
  - `item_id` string, nullable — External item identifier. When `id` is absent, used as the upsert lookup key for records owned by the current user: matches update an existing record, misses create a new record with this `item_id`. Must be unique among records owned by the authenticated user; `null` is allowed multiple times per user.
  - `text_id` integer, required — ID of the text this report belongs to. Must be owned by the authenticated user.
  - `plagiarism` number, float, nullable — Plagiarism percentage (0–100). Omit or pass `null` to store `null`.
  - `plagiarism_error` string, nullable — Error message from the plagiarism check. Omit or pass `null` to store `null`.
  - `ai` number, float, nullable — AI-detection score (0–100). Omit or pass `null` to store `null`.
  - `ai_error` string, nullable — Error message from the AI check. Omit or pass `null` to store `null`.
  - `checking` boolean — Whether the record is currently being checked. Defaults to `false`.

## Response `200`

The result of a batch create-or-update operation.

- object
  - `success` boolean
  - `data` object
    - `reports` IntegritoReportData[]
      - `id` string, nullable — Numeric report ID serialised as a string.
      - `text_id` string, nullable — ID of the associated text, serialised as a string.
      - `item_id` string, nullable — External item identifier set by the API consumer. Unique per owning user; `null` when no value was provided.
      - `plagiarism` number, float, nullable — Plagiarism percentage (0–100), or `null` when not yet checked.
      - `plagiarism_error` string, nullable — Error message from the plagiarism check, or `null` when no error occurred.
      - `ai` number, float, nullable — AI-detection score (0–100), or `null` when not yet checked.
      - `ai_error` string, nullable — Error message from the AI check, or `null` when no error occurred.
      - `checking` boolean — Whether the record is currently in a checking state.
      - `created_at` string, nullable — Creation Unix timestamp in milliseconds, serialised as a string.
      - `updated_at` string, nullable — Last-update Unix timestamp in milliseconds, serialised as a string. `null` until the record is updated.

## Other responses

- `201` — The result of a batch create-or-update operation.
- `400` — The request is invalid. Check required fields, field formats, and resource ownership.
- `403` — Authentication or authorization failed because the token is missing, invalid, blocked, or not allowed to access the resource.
- `404` — The requested resource was not found.

---

[API](https://skmtc.net/plagiarismcheck/apis/plagiarismcheck-org-api.md) · [All operations](https://skmtc.net/plagiarismcheck/apis/plagiarismcheck-org-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/plagiarismcheck/plagiarismcheck-org-api/revisions/034b4999350e/schema)
