> ## Documentation Index
> Fetch the complete documentation index at: https://docs.instaview.sk/llms.txt
> Use this file to discover all available pages before exploring further.

# Complete Knowledge Upload

> Confirms the file was uploaded to the presigned URL. The stored object is verified — it must exist, be within the size limit, and carry the content type the URL was issued for — and only then does the document become usable on calls. Safe to retry: completing an already-completed document returns it unchanged.

Confirms that the file was uploaded to the presigned URL, and makes the document usable on calls.

## Overview

This is the third step of the [upload flow](/api-reference/agents/knowledge/start-upload). Until it succeeds the document stays `PENDING` and no call will consult it.

## What Gets Verified

The stored object is checked before the document is accepted:

* it exists — a completion call for a file that was never uploaded is rejected
* it is within the 20 MiB (20,971,520 bytes) size limit
* it carries the content type the upload URL was issued for

A file that fails verification is deleted from storage, and the document slot is released. Fix the problem and start a new upload.

<Info>
  The size you declared when reserving the slot is a fast pre-check, not the
  authoritative one. What is measured here is the object storage actually holds.
</Info>

## Idempotency

Completing a document that is already `READY` returns it unchanged, with no error. A completion call that times out on your side is safe to retry.

## After Completion

The document is `READY` and `isActive: true`. It is attached to the agent's next call automatically — there is no publish step, and no need to update the agent itself.

To park a document without deleting it, [deactivate it](/api-reference/agents/knowledge/update-knowledge).

## Error Scenarios

* **400 Bad Request**: Nothing was uploaded to the URL, or the stored file failed verification
* **404 Not Found**: No such document on that agent
* **429 Too Many Requests**: Rate limit exceeded — wait for `Retry-After` seconds

## Related Resources

* [Start Knowledge Upload](/api-reference/agents/knowledge/start-upload)
* [List Knowledge Documents](/api-reference/agents/knowledge/list-knowledge)


## OpenAPI

````yaml POST /agents/{id}/knowledge/{documentId}/complete
openapi: 3.0.0
info:
  title: InstaView API
  description: |-
    InstaView API Documentation

    ## Authentication

    All endpoints require API key authentication using Bearer token:
    ```
    Authorization: Bearer sk_your_api_key_here
    ```

    ## API Key Management

    The API Key module provides comprehensive key management for:
    - **Direct Client Keys**: Company-scoped keys for your applications
    - **ATS Partner Keys**: Resource-scoped keys for ATS integrations

    ### Key Features
    - HMAC-SHA256 hashing for API key storage
    - Configurable rate limiting
    - Comprehensive audit logging
    - Company-level isolation
    - Resource scoping for ATS partners
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.instaview.sk
    description: Production API Gateway
security: []
tags: []
paths:
  /agents/{id}/knowledge/{documentId}/complete:
    post:
      tags:
        - Agents
      summary: Complete a knowledge base upload
      description: >-
        Confirms the file was uploaded to the presigned URL. The stored object
        is verified — it must exist, be within the size limit, and carry the
        content type the URL was issued for — and only then does the document
        become usable on calls. Safe to retry: completing an already-completed
        document returns it unchanged.
      operationId: PublicAgentKnowledgeController_completeUpload_v1
      parameters:
        - name: id
          required: true
          in: path
          description: Agent the knowledge base belongs to.
          schema:
            type: string
            format: uuid
        - name: documentId
          required: true
          in: path
          description: Knowledge document id.
          schema:
            type: string
            format: uuid
        - name: companyId
          required: false
          in: query
          description: >-
            Required for ATS API keys to specify which company to access.
            Ignored for standard company API keys.
          schema:
            type: string
      responses:
        '200':
          description: Upload verified; the document is now READY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicKnowledgeDocumentDto'
        '400':
          description: >-
            Nothing was uploaded to the URL, or the stored file failed
            verification. A file that fails verification is deleted.
        '404':
          description: No such document on that agent.
        '429':
          description: >-
            Upload rate limit exceeded. This endpoint has a lower limit than the
            rest of the API — wait for the number of seconds in the
            `Retry-After` header before retrying.
      security:
        - bearer: []
components:
  schemas:
    PublicKnowledgeDocumentDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
          example: 123e4567-e89b-12d3-a456-426614174000
          description: Document ID
        title:
          type: string
          example: Benefits and perks
          description: Human-readable label for the document
        fileName:
          type: string
          example: benefits-and-perks.pdf
          description: Original file name as uploaded
        mimeType:
          type: string
          example: application/pdf
          description: MIME type of the stored file
        sizeBytes:
          type: number
          example: 482133
          description: >-
            Size of the stored file in bytes, as verified against storage.
            Absent until the upload is READY.
        status:
          type: string
          enum:
            - PENDING
            - READY
          example: READY
          description: >-
            `PENDING` while waiting for the file to be uploaded to the presigned
            URL and the upload to be completed; `READY` once the file is
            confirmed stored. Only READY documents are attached to calls.
        isActive:
          type: boolean
          example: true
          description: >-
            Whether the agent may consult this document during a call. Always
            false while the upload is PENDING.
        createdAt:
          format: date-time
          type: string
          example: '2026-08-08T10:15:00.000Z'
          description: When the document was created
      required:
        - id
        - title
        - status
        - isActive
        - createdAt
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: API key for authentication using Bearer scheme

````