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

# Upload a media file

> Upload a media file to AssemblyAI's servers.

<Note>To upload a media file to our EU server, replace `api.assemblyai.com` with `api.eu.assemblyai.com`.</Note>
<Warning>Requests to transcribe uploaded files must use an API key from the same project as the key that was used to upload the file. If you use an API key from a different project you will get a `403` error and "Cannot access uploaded file" message.</Warning>




## OpenAPI

````yaml openapi.yaml POST /v2/upload
openapi: 3.1.0
info:
  title: AssemblyAI API
  description: AssemblyAI API
  version: 1.3.4
  termsOfService: https://www.assemblyai.com/legal/terms-of-service
  contact:
    name: API Support
    email: support@assemblyai.com
    url: https://www.assemblyai.com/docs/
servers:
  - url: https://api.assemblyai.com
    description: AssemblyAI API
    x-fern-server-name: Default
security:
  - ApiKey: []
tags:
  - name: transcript
    description: Transcript related operations
    externalDocs:
      url: https://www.assemblyai.com/docs/guides/transcribing-an-audio-file
  - name: streaming
    description: Streaming Speech-to-Text
    externalDocs:
      url: https://www.assemblyai.com/docs/streaming/universal-streaming
paths:
  /v2/upload:
    post:
      tags:
        - transcript
      summary: Upload a media file
      description: >
        Upload a media file to AssemblyAI's servers.


        <Note>To upload a media file to our EU server, replace
        `api.assemblyai.com` with `api.eu.assemblyai.com`.</Note>

        <Warning>Requests to transcribe uploaded files must use an API key from
        the same project as the key that was used to upload the file. If you use
        an API key from a different project you will get a `403` error and
        "Cannot access uploaded file" message.</Warning>
      operationId: uploadFile
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '200':
          x-label: Media file uploaded
          description: Media file uploaded successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadedFile'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/CannotAccessUploadedFile'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          x-label: Upload failed
          description: >
            Upload failed (for example, when the request body is empty). The
            response body is plain text, not JSON.
          content:
            text/plain:
              schema:
                type: string
              example: >-
                Upload failed, please try again. If you continue to have issues
                please reach out to support@assemblyai.com
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '504':
          $ref: '#/components/responses/GatewayTimeout'
components:
  schemas:
    UploadedFile:
      x-label: Uploaded file
      type: object
      x-fern-sdk-group-name: files
      additionalProperties: false
      required:
        - upload_url
      properties:
        upload_url:
          x-label: Uploaded file URL
          description: >
            A URL that points to your audio file, accessible only by
            AssemblyAI's servers
          type: string
          format: url
      example:
        upload_url: https://cdn.assemblyai.com/upload/f756988d-47e2-4ca3-96ce-04bb168f8f2a
    Error:
      x-label: Error
      type: object
      additionalProperties: true
      required:
        - error
      properties:
        error:
          x-label: Error message
          description: Error message
          type: string
        status:
          x-label: Status
          type: string
          const: error
      example:
        error: Transcript creation error, audio_url not found
  responses:
    BadRequest:
      x-label: Bad request
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: This is a sample error message
    Unauthorized:
      x-label: Unauthorized
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Authentication error, API token missing/invalid
    CannotAccessUploadedFile:
      x-label: Cannot access uploaded file
      description: Cannot access uploaded file
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Cannot access uploaded file
    NotFound:
      x-label: Not found
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Not found
    TooManyRequests:
      x-label: Too many requests
      description: Too many requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Too Many Requests
      headers:
        Retry-After:
          description: The number of seconds to wait before retrying the request
          schema:
            type: integer
    InternalServerError:
      x-label: Internal server error
      description: An error occurred while processing the request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: >-
              Internal server error. Please retry your request. If the error
              persists, please contact support@assemblyai.com for more
              information.
    ServiceUnavailable:
      x-label: Service unavailable
      description: Service unavailable
    GatewayTimeout:
      x-label: Gateway timeout
      description: Gateway timeout
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

````