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

# Create upload

> POST /v1/uploads returns a signed URL to upload one image, video, or audio file of up to 100 MB to Mage storage.

A signed URL to `PUT` one file onto Mage storage, for inputs too large for a data URL. Request bodies are capped at 4.5 MB on the platform, so a data URL carries about 3 MB; an upload takes up to 100 MB.

Create a ticket with the file's `content_type`, `PUT` the bytes to `upload_url` with exactly the `headers` returned, then send `url` in any media field of a generate request, or as the `voice` or `audio` of a character or audio reference you create. The upload URL is valid for 15 minutes (`upload_url_expires_at`); the file lives 30 days (`url_expires_at`), like every input and result. See [Inputs and uploads](https://docs.mage.space/api/inputs.md) for the full flow.


## OpenAPI

````yaml api/openapi.json POST /v1/uploads
openapi: 3.1.0
info:
  title: Mage API
  version: v1
  description: >-
    Run Mage models from your own code: submit a generation, poll its status,
    download the result. Every request is paid in gems.
  contact:
    name: Mage
    url: https://www.mage.space
    email: mage@mage.space
servers:
  - url: https://api.mage.space
    description: Production
security:
  - apiKey: []
tags:
  - name: Requests
    description: Submit, poll, and cancel generations.
  - name: Catalog
    description: What the API can generate with.
  - name: Account
    description: The gems balance.
  - name: Uploads
    description: Large input files.
  - name: Characters
    description: Saved characters a prompt mentions by `@handle`.
  - name: References
    description: Saved image and audio references a prompt mentions by `@handle`.
  - name: Image models
    description: One endpoint per image architecture.
  - name: Video models
    description: One endpoint per video architecture.
  - name: Audio models
    description: One endpoint per audio architecture.
paths:
  /v1/uploads:
    post:
      tags:
        - Uploads
      summary: Create upload
      description: >-
        A signed URL to upload one input file, for files too large for a data
        URL.
      operationId: create_upload
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UploadRequest'
            example:
              content_type: video/mp4
      responses:
        '200':
          description: The upload ticket.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadTicket'
              example:
                upload_url: >-
                  https://storage.googleapis.com/mage/temp/30d/uploads/user/video/6f1c.mp4?X-Goog-Signature=…
                method: PUT
                headers:
                  Content-Type: video/mp4
                  x-goog-content-length-range: 0,104857600
                  x-goog-if-generation-match: '0'
                url: https://cdn3.mage.space/temp/30d/uploads/user/video/6f1c.mp4
                content_type: video/mp4
                max_bytes: 104857600
                upload_url_expires_at: '2026-09-17T15:07:48.000Z'
                url_expires_at: '2026-10-17T14:52:48.000Z'
        '400':
          description: >-
            The body is not a JSON object, or `content_type` is missing or not
            an accepted image or video type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_request
                  message: >-
                    `content_type` must be one of: image/jpeg, image/png,
                    video/mp4, video/quicktime, video/webm, audio/mpeg,
                    audio/mp3, audio/wav, audio/wave, audio/x-wav.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '500':
          $ref: '#/components/responses/InternalError'
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import { readFile } from 'node:fs/promises';

            import Mage from '@mage-space/sdk';


            const mage = new Mage(); // reads MAGE_API_KEY


            // Creates the ticket and uploads the file to it.

            const ticket = await mage.uploads.upload(await readFile('clip.mp4'),
            {
              contentType: 'video/mp4',
            });


            console.log(ticket.url); // send this in any media field
        - lang: python
          label: Python SDK
          source: >-
            from mage_space import Mage


            mage = Mage()  # reads MAGE_API_KEY


            # Creates the ticket and uploads the file to it.

            ticket = mage.uploads.upload("clip.mp4")  # a path, bytes, or a
            binary file


            print(ticket["url"])  # send this in any media field
components:
  schemas:
    UploadRequest:
      type: object
      properties:
        content_type:
          type: string
          enum:
            - image/jpeg
            - image/png
            - video/mp4
            - video/quicktime
            - video/webm
            - audio/mpeg
            - audio/mp3
            - audio/wav
            - audio/wave
            - audio/x-wav
          description: >-
            The media type of the file you will upload: an image or video for a
            generate request, or an audio clip for a character voice or an audio
            reference.
      required:
        - content_type
      additionalProperties: false
    UploadTicket:
      type: object
      properties:
        upload_url:
          type: string
          format: uri
          description: PUT the file here.
        method:
          type: string
          const: PUT
        headers:
          type: object
          propertyNames:
            type: string
          additionalProperties:
            type: string
          description: >-
            Headers the PUT must carry exactly; storage checks them against the
            signature.
        url:
          type: string
          format: uri
          description: >-
            The URL the file has once the PUT succeeds. Send it in any media
            field, or as `voice` or `audio` when creating a character or an
            audio reference.
        content_type:
          type: string
          description: The media type the PUT must declare.
        max_bytes:
          type: integer
          description: 'The largest body the upload accepts: 100 MB.'
        upload_url_expires_at:
          type: string
          format: date-time
          description: When `upload_url` stops accepting the PUT.
        url_expires_at:
          type: string
          format: date-time
          description: 'When the uploaded file is deleted: 30 days after the ticket.'
      required:
        - upload_url
        - method
        - headers
        - url
        - content_type
        - max_bytes
        - upload_url_expires_at
        - url_expires_at
      additionalProperties: false
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - unauthorized
                - invalid_request
                - invalid_config
                - architecture_not_found
                - architecture_retired
                - request_not_found
                - character_not_found
                - reference_not_found
                - not_found
                - insufficient_gems
                - payment_required
                - forbidden
                - content_blocked
                - request_finished
                - handle_taken
                - too_many_requests
                - generation_failed
                - preprocess_refused
                - internal_error
              description: A stable error code; treat an unknown code by its HTTP status.
            message:
              type: string
              description: What went wrong, for a person.
            request_id:
              description: >-
                The request the refusal belongs to, when one was recorded before
                the refusal.
              type: string
              format: uuid
            gems_required:
              description: The price of the refused generation, on `insufficient_gems`.
              type: number
            docs_url:
              description: Where to read the API reference, on `not_found`.
              type: string
              format: uri
            handle:
              description: The handle that is taken, on `handle_taken`.
              type: string
          required:
            - code
            - message
          additionalProperties: true
          description: Further fields depend on the code.
      required:
        - error
      additionalProperties: false
  responses:
    Unauthorized:
      description: The key is missing, malformed, unknown, or revoked.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: The API key is invalid or has been revoked.
    PaymentRequired:
      description: >-
        The account has no successful payment yet: the API and the MCP server
        need one first (any Gem pack or plan). Signup bonus Gems work in the
        Mage app only.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: payment_required
              message: >-
                The Mage API and MCP server need a successful payment on this
                account first: buy any Gem pack or start a plan at
                https://www.mage.space/gems, then retry. Signup bonus Gems work
                in the Mage app only.
    InternalError:
      description: >-
        Something failed on Mage's side. Retry, and contact support if it
        persists.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: internal_error
              message: >-
                Something went wrong on our side. Retry, and contact support if
                it persists.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        Create a key in [API → API
        Keys](https://www.mage.space/api?tab=api-keys): select **Create API
        key**, name it in the popup, then select **Create key**. Copy the
        one-time key and send it as `Authorization: Bearer mage_sk_…`. Keys are
        for server-side code only.

````

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