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

# Upload File

> Upload a JSONL batch input file at /v1/files

## Overview

Uploads a JSONL file of chat-completion requests with `purpose: batch` and returns its `file_` id. Pass that id as `input_file_id` to [create a batch](/api-reference/endpoint/batches-create). Each line is a [`BatchInputLine`](/sdk/components/batch#input-file-format); files are capped at 100 MB and 50,000 lines.


## OpenAPI

````yaml POST /v1/files
openapi: 3.1.0
info:
  title: Morph API
  version: 1.2.0
  description: >-
    The Morph public API at api.morphllm.com: OpenAI- and Anthropic-compatible
    inference (chat completions, messages), the Batch API, Fast Apply code
    editing, Compact context compression, Reflex classification, and
    fine-tuning. Model ids, prices, and context windows are served live at
    https://www.morphllm.com/api/models/json.
  contact:
    name: Morph
    url: https://morphllm.com
    email: info@morphllm.com
  license:
    name: Proprietary
    url: https://morphllm.com/privacy/tos
servers:
  - url: https://api.morphllm.com
    description: Production
security: []
tags:
  - name: chat
    description: >-
      OpenAI- and Anthropic-compatible chat inference, including Fast Apply and
      WarpGrep models.
  - name: compact
    description: Context compression for long agent conversations.
  - name: reflex
    description: 'Per-turn classifiers: realtime prediction and batches.'
  - name: fine-tuning
    description: Reflex fine-tuning job lifecycle.
  - name: batch
    description: >-
      OpenAI-compatible Batch API: upload a JSONL file, run it at half price,
      download the results.
  - name: models
    description: Model listing and management.
  - name: telemetry
    description: Usage reporting hooks.
paths:
  /v1/files:
    post:
      tags:
        - batch
      summary: Upload a batch input file
      description: >-
        Upload a JSONL file of chat-completion requests, one `BatchInputLine`
        per line, with `purpose: batch`. Up to 100 MB and 50,000 lines. Files
        are deleted 30 days after upload unless you set `expires_after`, or 24
        hours on zero-data-retention accounts. Returns the file id to pass as
        `input_file_id`.
      operationId: uploadFile
      requestBody:
        required: true
        description: The file plus its purpose, as multipart form data.
        content:
          multipart/form-data:
            example:
              file: requests.jsonl
              purpose: batch
            schema:
              $ref: '#/components/schemas/FileUploadRequest'
      responses:
        '200':
          description: The stored file.
          content:
            application/json:
              example:
                id: file_9c2c1c3e-5b6a-4f0e-8d0f-2a1b3c4d5e6f
                object: file
                bytes: 48211
                created_at: 1780000000
                expires_at: 1782592000
                filename: requests.jsonl
                purpose: batch
                status: uploaded
              schema:
                $ref: '#/components/schemas/FileObject'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - bearerAuth: []
components:
  schemas:
    FileUploadRequest:
      type: object
      properties:
        file:
          type: string
          format: binary
          description: >-
            The JSONL file to upload. Up to 100 MB and 50,000 lines; every line
            is a `BatchInputLine`.
          example: requests.jsonl
        purpose:
          type: string
          enum:
            - batch
          description: Must be `batch`.
          example: batch
        expires_after[anchor]:
          type: string
          enum:
            - created_at
          description: >-
            Anchor for the expiry policy. Only `created_at` is supported. Send
            together with `expires_after[seconds]`.
          example: created_at
        expires_after[seconds]:
          type: integer
          minimum: 3600
          maximum: 2592000
          description: >-
            Seconds after the anchor at which the file is deleted, from 3600 (1
            hour) to 2592000 (30 days). Defaults to 30 days.
          example: 2592000
      required:
        - file
        - purpose
      description: Multipart form for uploading a batch input file.
      example:
        file: requests.jsonl
        purpose: batch
    FileObject:
      type: object
      properties:
        id:
          type: string
          description: >-
            File identifier, `file_` prefixed. Pass it as `input_file_id` when
            creating a batch.
          example: file_9c2c1c3e-5b6a-4f0e-8d0f-2a1b3c4d5e6f
        object:
          type: string
          description: Object type, always `file`.
          example: file
        bytes:
          type: integer
          description: Size of the file in bytes.
          example: 48211
        created_at:
          type: integer
          description: Unix timestamp (seconds) for when the file was uploaded.
          example: 1780000000
        expires_at:
          type:
            - integer
            - 'null'
          description: >-
            Unix timestamp (seconds) for when the file and its content are
            deleted. Defaults to 30 days after upload (24 hours on
            zero-data-retention accounts).
          example: 1782592000
        filename:
          type: string
          description: >-
            The filename you uploaded, or the generated name for batch output
            and error files.
          example: requests.jsonl
        purpose:
          type: string
          enum:
            - batch
            - batch_output
          description: >-
            `batch` for files you upload; `batch_output` for the output and
            error files a batch produces.
          example: batch
        status:
          type: string
          enum:
            - uploaded
            - processed
            - error
          description: >-
            Deprecated OpenAI field, kept for SDK compatibility. Always
            `uploaded`.
          example: uploaded
      required:
        - id
        - object
        - bytes
        - created_at
        - expires_at
        - filename
        - purpose
        - status
      description: A file you uploaded, or one a batch wrote for you.
      example:
        id: file_9c2c1c3e-5b6a-4f0e-8d0f-2a1b3c4d5e6f
        object: file
        bytes: 48211
        created_at: 1780000000
        expires_at: 1782592000
        filename: requests.jsonl
        purpose: batch
        status: uploaded
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: invalid_request_error
              description: Machine-readable error code.
            message:
              type: string
              example: The request body is missing the `model` field.
              description: Human-readable explanation of the failure.
          required:
            - code
            - message
      required:
        - error
      description: Standard error envelope returned by every non-2xx response.
      example:
        error:
          code: invalid_request_error
          message: The request body is missing the `model` field.
  responses:
    BadRequest:
      description: Malformed request — missing or invalid fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_request_error
              message: The request body is missing the `model` field.
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Invalid API key provided.
    RateLimited:
      description: Rate limited — retry after the interval in the Retry-After header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: rate_limited
              message: Too many requests. Retry in 12 seconds.
    InternalError:
      description: Internal error — safe to retry with backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: internal_error
              message: Something went wrong on our side.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: opaque
      description: >-
        Morph API key, passed as `Authorization: Bearer sk-...`. Create keys at
        https://www.morphllm.com/dashboard/api-keys.

````