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

# Upload File

> Create a presigned upload URL and the final public media URL for a file.

Use this upload endpoint for your post media and custom video thumbnail images.

Send the file's MIME type in `type` when you know it. For an MP4 video, use:

```json theme={null}
{
  "filename": "launch.mp4",
  "type": "video/mp4"
}
```

If you omit `type`, Mallary uses the filename extension to choose a supported MIME type. Files with unknown extensions need an explicit supported `type`.

Upload the file bytes to the returned `uploadUrl` with HTTP PUT. Use the returned `headers`, including `Content-Type`, without changing them. Wait for the upload to finish before passing `mediaUrl` to `POST /api/v1/post`.


## OpenAPI

````yaml POST /api/v1/upload
openapi: 3.0.3
info:
  title: Mallary API
  version: 1.6.0
  description: >
    Public API for multi-platform publishing, analytics, media upload, and
    webhooks.


    Authentication:

    - Use header `Authorization: Bearer {api_key}`.

    - API key identity is authoritative. Do not use `user_id` to identify a
    caller.


    Connection profiles:

    - Omit `profile_id` to use the authenticated user's default profile.

    - Send the profile's random public `profile_id` when you want to publish,
    list posts, read post analytics or audience counts, list platforms, update
    settings, or disconnect a platform for a non-default profile.

    - Use `GET /api/v1/profiles` to list profile IDs.

    - Total social media accounts: Starter 5 ($15/month), Pro 15 ($29/month),
    Business 100 ($95/month). Posts are unlimited. Scheduling, analytics, and AI
    auto-replies are included. X publishing and comments use credits at cost;
    analytics and account lookups use no credits. Existing customers keep their
    current terms; use the authenticated workspace limits.


    Rate limits (per user, per minute) depend on subscription plan:

    - plan_id 1: 75 req/min

    - plan_id 2: 150 req/min

    - plan_id 3: 750 req/min

    - plan_id 4: 1500 req/min
servers:
  - url: https://mallary.ai
    description: Production
security:
  - bearerAuth: []
externalDocs:
  description: Full product docs
  url: https://docs.mallary.ai/
paths:
  /api/v1/upload:
    post:
      summary: Create presigned upload URL
      description: >-
        Returns a temporary PUT URL and a public media URL for use in `POST
        /api/v1/post`.
      operationId: createUploadUrl
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUploadRequest'
      responses:
        '200':
          description: Upload metadata created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateUploadResponse'
        '400':
          description: >-
            Invalid request (missing filename, invalid size when provided,
            unsupported MIME type, or size exceeded)
        '401':
          description: Missing or invalid API key
        '403':
          description: Supplied `user_id` (if any) does not match API key owner
        '429':
          description: Rate limit exceeded
components:
  schemas:
    CreateUploadRequest:
      type: object
      required:
        - filename
      properties:
        filename:
          type: string
          example: launch-video.mp4
        size:
          type: integer
          minimum: 1
          description: >-
            Optional file size in bytes for early validation against the 5GB
            limit.
        type:
          type: string
          example: video/mp4
          description: >-
            File MIME type. Send it when known, such as `video/mp4` for an MP4
            video. If omitted, Mallary infers it from a supported filename
            extension. Files with unknown extensions need an explicit supported
            type.
    CreateUploadResponse:
      type: object
      required:
        - uploadUrl
        - mediaUrl
        - contentType
      properties:
        uploadUrl:
          type: string
          format: uri
        mediaUrl:
          type: string
          format: uri
        storageKey:
          type: string
        contentType:
          type: string
        size:
          type: integer
          description: Echoed back when a `size` value was supplied in the request.
        headers:
          type: object
          additionalProperties:
            type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Use `Authorization: Bearer {api_key}`'

````

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