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

# Upload a file

> Uploads a JSONL batch input file, up to 50,000 lines and 200 MB. Every
line is validated before the file is stored. Files expire after 30 days;
`expires_after` is not supported and is rejected with a 400.




## OpenAPI

````yaml post /v1/files
openapi: 3.1.0
info:
  title: Perplexity AI API
  description: Perplexity AI API
  version: 1.0.0
servers:
  - url: https://api.perplexity.ai
    description: Perplexity AI API
security: []
paths:
  /v1/files:
    post:
      tags:
        - Batches
      summary: Upload a file
      description: |
        Uploads a JSONL batch input file, up to 50,000 lines and 200 MB. Every
        line is validated before the file is stored. Files expire after 30 days;
        `expires_after` is not supported and is rejected with a 400.
      operationId: createFile
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - purpose
              properties:
                file:
                  type: string
                  format: binary
                  description: The JSONL file
                purpose:
                  type: string
                  enum:
                    - batch
                  description: Only `batch` is accepted
      responses:
        '200':
          description: The stored file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchFile'
        '400':
          description: Invalid request or file contents
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: Batch is not available to organizations with zero data retention
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '413':
          description: File exceeds 200 MB
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          description: Rate limit or upload concurrency limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      security:
        - HTTPBearer: []
components:
  schemas:
    BatchFile:
      type: object
      required:
        - id
        - object
        - bytes
        - created_at
        - filename
        - purpose
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - file
        bytes:
          format: int64
          type: integer
        created_at:
          type: integer
          format: int64
          description: Unix seconds
        expires_at:
          type: integer
          format: int64
          nullable: true
          description: Unix seconds
        filename:
          type: string
        purpose:
          type: string
          enum:
            - batch
            - batch_output
          description: '`batch` for uploads, `batch_output` for output and error files'
    ApiError:
      type: object
      properties:
        error:
          type: object
          required:
            - message
            - type
            - code
          properties:
            message:
              description: Human-readable error message
              type: string
            type:
              type: string
              description: Error type identifier
            code:
              type: integer
              description: HTTP status code
            param:
              type: string
              description: Parameter that caused the error
              nullable: true
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````