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

# Create Document

> Ingests a PDF into the AI knowledge base. Provide the document as exactly one of document.url, document.base64 or document.file.



## OpenAPI

````yaml api-reference/openapi-generated.json POST /v1/knowledge-base/document/create
openapi: 3.0.3
info:
  title: Periskope API
  version: 1.0.0
  description: >-
    Periskope external API.


    Responses use a flat, unwrapped shape: most endpoints return the resource at
    the top level, and list endpoints return a wrapper object with pagination
    inline (e.g. `{ from, to, count, chats: [...] }`). The documented response
    schemas describe these shapes directly.
servers:
  - url: https://api.periskope.app
security:
  - bearerAuth: []
paths:
  /v1/knowledge-base/document/create:
    post:
      tags:
        - Knowledge Base
      summary: Upload a PDF document
      description: >-
        Ingests a PDF into the AI knowledge base. Provide the document as
        exactly one of document.url, document.base64 or document.file.
      operationId: createDocument
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                document:
                  type: object
                  properties:
                    url:
                      type: string
                      description: >-
                        Publicly accessible HTTP(S) URL of the PDF to ingest.
                        Provide exactly one of url, base64 or file.
                      example: https://example.com/files/product-faq.pdf
                    base64:
                      type: string
                      description: >-
                        PDF content as a base64 string or a data: URI
                        (data:application/pdf;base64,<content>). Data URIs must
                        have the application/pdf MIME type. Provide exactly one
                        of url, base64 or file.
                      example: JVBERi0xLjQKJcTl8uXrp...
                    file:
                      type: string
                      description: >-
                        PDF content as a base64 string or a data: URI,
                        equivalent to base64. Provide exactly one of url, base64
                        or file.
                      example: JVBERi0xLjQKJcTl8uXrp...
                    filename:
                      type: string
                      description: >-
                        Name to store the document under. A .pdf extension is
                        appended when missing. Defaults to the last path segment
                        of url when it ends in .pdf, otherwise to a generated
                        'document_<timestamp>.pdf' name.
                      example: product-faq.pdf
                  description: >-
                    The PDF document to ingest. Must contain exactly one content
                    source (url, base64 or file) and may include a filename.
                is_active:
                  type: boolean
                  description: >-
                    Whether the document chunks are active immediately. Defaults
                    to false — the entries stay inactive until approved.
                  example: false
              required:
                - document
      responses:
        '200':
          description: The processing result for the uploaded document
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/KnowledgeBaseDocument'
                description: >-
                  One processing result per uploaded file — always a single
                  element for this route
              examples:
                default:
                  summary: Response body
                  value:
                    - file_name: product-faq.pdf
                      document_id: 00000000-0000-0000-0000-000000000000
                      file_path: >-
                        org-assets/00000000-0000-0000-0000-000000000000/ai_assets/documents/00000000-0000-0000-0000-000000000000/product-faq.pdf
                      chunks_count: 12
        '400':
          description: >-
            Invalid document input — an invalid or unreachable URL, a file that
            is not a valid PDF, or a PDF larger than 50 MB
          content:
            application/json:
              examples:
                error:
                  summary: >-
                    Invalid document input — an invalid or unreachable URL, a
                    file that is not a valid PDF, or a PDF larger than 50 MB
                  value:
                    code: ERROR
                    message: >-
                      Invalid document input — an invalid or unreachable URL, a
                      file that is not a valid PDF, or a PDF larger than 50 MB
                    status: 400
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: ERROR
                  message:
                    type: string
                    example: >-
                      Invalid document input — an invalid or unreachable URL, a
                      file that is not a valid PDF, or a PDF larger than 50 MB
                  status:
                    type: integer
                    example: 400
                example:
                  code: ERROR
                  message: >-
                    Invalid document input — an invalid or unreachable URL, a
                    file that is not a valid PDF, or a PDF larger than 50 MB
                  status: 400
        '401':
          description: Invalid, expired or missing API token
          content:
            application/json:
              examples:
                error:
                  summary: Invalid, expired or missing API token
                  value:
                    code: UNAUTHORIZED_ERROR
                    message: Invalid bearer auth token
                    status: 401
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: UNAUTHORIZED_ERROR
                  message:
                    type: string
                    example: Invalid bearer auth token
                  status:
                    type: integer
                    example: 401
                example:
                  code: UNAUTHORIZED_ERROR
                  message: Invalid bearer auth token
                  status: 401
        '422':
          description: Request validation failed
          content:
            application/json:
              examples:
                error:
                  summary: Request validation failed
                  value:
                    code: VALIDATION_ERROR
                    message: Request validation failed
                    status: 422
                    fields:
                      body.chat_id:
                        message: chat_id is required
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: VALIDATION_ERROR
                  message:
                    type: string
                    example: Request validation failed
                  status:
                    type: integer
                    example: 422
                  fields:
                    type: object
                    additionalProperties:
                      type: object
                      properties:
                        message:
                          type: string
                        value: {}
                    example:
                      body.chat_id:
                        message: chat_id is required
                example:
                  code: VALIDATION_ERROR
                  message: Request validation failed
                  status: 422
                  fields:
                    body.chat_id:
                      message: chat_id is required
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              examples:
                error:
                  summary: Rate limit exceeded
                  value:
                    code: RATE_LIMIT_ERROR
                    message: You can only make 100 requests per second
                    status: 429
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: RATE_LIMIT_ERROR
                  message:
                    type: string
                    example: You can only make 100 requests per second
                  status:
                    type: integer
                    example: 429
                example:
                  code: RATE_LIMIT_ERROR
                  message: You can only make 100 requests per second
                  status: 429
        '500':
          description: Internal server error
          content:
            application/json:
              examples:
                error:
                  summary: Internal server error
                  value:
                    code: UNKNOWN_ERROR
                    message: Internal server error
                    status: 500
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: UNKNOWN_ERROR
                  message:
                    type: string
                    example: Internal server error
                  status:
                    type: integer
                    example: 500
                example:
                  code: UNKNOWN_ERROR
                  message: Internal server error
                  status: 500
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: typescript
          label: TypeScript
          source: |-
            import { PeriskopeApi } from '@periskope/periskope-client';

            const client = new PeriskopeApi({
              authToken: 'YOUR_API_KEY',
            });

            async function main() {
              const response = await client.knowledgeBase.createDocument({
                document: {
                  url: 'https://example.com/files/product-faq.pdf',
                },
              });
              console.log(response);
            }

            main();
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            'https://api.periskope.app/v1/knowledge-base/document/create' \
              -H 'Authorization: Bearer YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "document": {
                  "url": "https://example.com/files/product-faq.pdf"
                }
              }'
components:
  schemas:
    KnowledgeBaseDocument:
      type: object
      properties:
        file_name:
          type: string
          description: Filename the document was stored under
          example: product-faq.pdf
        document_id:
          type: string
          description: >-
            Id assigned to the uploaded document. Use it with the GET/DELETE
            /knowledge-base/document/{document_id} routes to fetch or delete the
            document and its chunks.
          example: 00000000-0000-0000-0000-000000000000
        file_path:
          type: string
          description: Storage path of the uploaded PDF in the org assets bucket
          example: >-
            org-assets/00000000-0000-0000-0000-000000000000/ai_assets/documents/00000000-0000-0000-0000-000000000000/product-faq.pdf
        chunks_count:
          type: integer
          description: >-
            Number of knowledge-base entries (chunks) extracted from the
            document
          example: 12
      description: >-
        The result of ingesting a PDF into the knowledge base: where the file
        was stored and how many knowledge-base entries (chunks) were extracted
        from it.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your Periskope API token, sent as `Authorization: Bearer <token>`.
        Generate one from the Periskope dashboard under **Settings → API &
        Webhooks**. API access requires an active Pro or Enterprise plan.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.