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

# Upload a file

> Upload one picture, video or document to a workspace's media library.

> [!NOTE]
>
> Needs `media:create`, and a role in the workspace that can add media. See [Permissions](/docs/essentials/authentication.md#permissions).

> [!WARNING]
>
> Send uploads to the upload host, `https://upload.postsyncer.com/api/v1/media/upload/file`, not to `https://postsyncer.com/api/v1`. The API key is the same.

Send one file as `multipart/form-data`, with `workspace_id` and, if you like, a `folder_id` of the same workspace. The type is read from the file itself, so there is no type field:

* Pictures: JPEG, PNG, GIF, WebP.
* Videos: MP4, MOV, WebM. MKV, AVI and other video types are refused.
* Documents: PDF, DOC, DOCX, PPT, PPTX. They publish to LinkedIn only: see [Documents](/docs/api-reference/media/overview.md#documents).

A file can be up to 500 MB. Put the answer's `media.id` in a post's `content[].media`. For a file already on the web, use [Import media from links](/docs/api-reference/media/upload-url.md).

```bash cURL theme={null}
curl -X POST "https://upload.postsyncer.com/api/v1/media/upload/file" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F workspace_id=12 \
  -F file=@latte-art.jpg
```

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 401 | | No API key, or not a valid one. | No: fix the key. |
| 403 | | The key lacks `media:create`, or its user is inactive. | No: grant it in Settings → API. |
| 403 | | Your role in the workspace can't add media. | No. |
| 422 | | A field is wrong, the workspace or folder isn't one the key can reach, the file is over 500 MB, or it isn't a type that can be used. Nothing was stored. | No: fix the file or the request. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |
| 500 | | Something broke on PostSyncer's side: "Upload failed. Try again in a moment." Nothing was stored. | Yes: it is usually safe to send the file again. |

## Related

* [Media library](/docs/api-reference/media/overview.md): types, picture copies and documents.
* [Create a post](/docs/api-reference/posts/create.md): use `media.id`.


## OpenAPI

````yaml POST /media/upload/file
openapi: 3.0.3
info:
  title: PostSyncer API
  description: >-
    Post to 12 social networks from your code: posts, media, comments,
    analytics, webhooks and more.
  version: 1.0.0
servers:
  - url: https://postsyncer.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: The workspaces the key can reach.
  - name: Accounts
    description: Connected social accounts, links to connect more, and disconnecting them.
  - name: Posts
    description: Drafts, scheduled and published posts, approvals and a post's history.
  - name: Post settings
    description: A post's auto-plug, comment moderation and contact collection.
  - name: Media
    description: >-
      The media library: file uploads, URL imports, and reading videos and
      social posts' files.
  - name: Folders
    description: Folders that organise the media library.
  - name: Comments
    description: >-
      Comments on your posts: reading, replying, editing, hiding, deleting and
      syncing them.
  - name: Reviews
    description: Google Business Profile reviews and your replies to them.
  - name: Analytics
    description: Workspace, account and post performance.
  - name: Brand
    description: >-
      A workspace's brand: identity, voice, look, accounts, competitors,
      learnings and rules.
  - name: Labels
    description: Labels used to tag posts.
  - name: Campaigns
    description: Campaigns used to group posts.
  - name: Snippets
    description: Saved snippets and hashtag groups to drop into posts.
  - name: Webhooks
    description: Signed webhook endpoints that get your notification events.
  - name: Billing
    description: >-
      The owner's plan, invoices and the links that pay for, change or cancel
      it.
  - name: Team
    description: A workspace's teammates and invitations, and their roles.
  - name: Notifications
    description: >-
      Your bell and notification settings, and the workspace's Slack, Discord
      and Telegram channels.
  - name: Blog-to-social
    description: Blog feeds that turn a workspace's new articles into posts.
  - name: Products
    description: Products the workspace's posts can promote.
  - name: Contacts
    description: People who commented on the workspace's posts, and the lists they are on.
  - name: Profile
    description: 'The key''s user: their name and sign-in email.'
  - name: API keys
    description: 'Your API keys: listing and deleting them.'
  - name: Agent sign-up
    description: >-
      An AI agent signs a person up with a code emailed to them, and gets their
      first key. No key needed.
paths:
  /media/upload/file:
    servers:
      - url: https://upload.postsyncer.com/api/v1
        description: The upload host, for large files (the same API keys).
    post:
      tags:
        - Media
      summary: Upload a file
      description: >-
        Needs `media:create`. Your role in the workspace must also let you add
        media. Send one file as `multipart/form-data` to
        `https://upload.postsyncer.com/api/v1/media/upload/file`, the upload
        host. The type is read from the file: pictures (JPEG, PNG, GIF, WebP),
        videos (MP4, MOV, WebM; an MKV or AVI file is refused) and documents
        (PDF, DOC, DOCX, PPT, PPTX), up to 500 MB. A damaged picture (cut short,
        or its header can't be read) is refused with a `422`, before any post
        uses it. Documents publish to LinkedIn only. Use the answer's `media.id`
        in a post's `content[].media`.
      operationId: uploadMediaFile
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - workspace_id
                - file
              properties:
                workspace_id:
                  type: integer
                  description: >-
                    The workspace whose library gets the file. It must be one
                    the key can reach.
                file:
                  type: string
                  format: binary
                  description: The picture, video or document, up to 500 MB.
                folder_id:
                  type: integer
                  nullable: true
                  description: >-
                    A folder of the same workspace to put the file in. Left out:
                    the top of the library.
            examples:
              default:
                summary: A picture
                value:
                  workspace_id: 12
                  file: latte-art.jpg
              in_folder:
                summary: A video, in a folder
                value:
                  workspace_id: 12
                  file: pour-over.mp4
                  folder_id: 41
      responses:
        '201':
          description: The file is in the library.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaUploadFileResponse'
              examples:
                default:
                  summary: A picture
                  value:
                    media:
                      id: 9051
                      workspace_id: 12
                      folder_id: null
                      name: latte-art.jpg
                      url: https://cdn.postsyncer.com/examples/latte-art.jpg
                      mime_type: image/jpeg
                      size: 482113
                      is_processing: false
                      type: image
                      ai_generated_id: null
                      is_reference: false
                      progress: 100
                      alt: Latte art in a blue cup
                      duration_seconds: null
                video:
                  summary: A video
                  value:
                    media:
                      id: 9052
                      workspace_id: 12
                      folder_id: 41
                      name: pour-over.mp4
                      url: https://cdn.postsyncer.com/examples/pour-over.mp4
                      mime_type: video/mp4
                      size: 18874368
                      is_processing: false
                      type: video
                      ai_generated_id: null
                      is_reference: false
                      progress: 100
                      alt: null
                      duration_seconds: 42.6
        '401':
          $ref: '#/components/responses/Unauthorized401'
        '403':
          description: >-
            The key lacks `media:create`, its user is inactive, or your role in
            the workspace can't add media.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_permission:
                  summary: The key lacks media:create
                  value:
                    message: >-
                      This API key does not have the "media:create" permission.
                      Edit the key in PostSyncer under Settings → API to grant
                      it.
                role:
                  summary: The role can't add media
                  value:
                    message: >-
                      Your role in the workspace "Halden Coffee" does not allow
                      you to create media. Ask the workspace owner or a manager
                      to do it, or to change your role.
                inactive_account:
                  summary: The key's user is inactive
                  value:
                    message: Your account is inactive.
        '422':
          description: >-
            A field is wrong, the file is over 500 MB, it isn't a picture, video
            or document that can be used, or the picture is damaged (cut short,
            or its header can't be read). Nothing was stored.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ValidationError'
                  - $ref: '#/components/schemas/Error'
              examples:
                wrong_type:
                  summary: Not an allowed type
                  value:
                    message: >-
                      The file must be an allowed image, video, or document
                      (PDF, DOC, DOCX, PPT, PPTX) type.
                    errors:
                      file:
                        - >-
                          The file must be an allowed image, video, or document
                          (PDF, DOC, DOCX, PPT, PPTX) type.
                unreadable:
                  summary: The bytes aren't a known type
                  value:
                    message: >-
                      This file type is not supported. Upload an image, video,
                      audio file, PDF, Word or PowerPoint document.
                    errors:
                      file:
                        - >-
                          This file type is not supported. Upload an image,
                          video, audio file, PDF, Word or PowerPoint document.
                damaged_image:
                  summary: A damaged picture
                  value:
                    message: >-
                      The image "banner.png" is damaged: part of it declares
                      more data than the file holds, so it was cut short. Open
                      it, save or export it again, then upload the new file.
                    errors:
                      file:
                        - >-
                          The image "banner.png" is damaged: part of it declares
                          more data than the file holds, so it was cut short.
                          Open it, save or export it again, then upload the new
                          file.
                too_large:
                  summary: Over 500 MB
                  value:
                    message: The file field must not be greater than 512000 kilobytes.
                    errors:
                      file:
                        - >-
                          The file field must not be greater than 512000
                          kilobytes.
                workspace_id:
                  summary: Not a workspace the key can reach
                  value:
                    message: 'Workspace #99 is invalid or you do not have access to it.'
                    errors:
                      workspace_id:
                        - >-
                          Workspace #99 is invalid or you do not have access to
                          it.
                folder_id:
                  summary: A folder of another workspace
                  value:
                    message: 'Folder #77 does not belong to the specified workspace.'
                    errors:
                      folder_id:
                        - 'Folder #77 does not belong to the specified workspace.'
                nothing_stored:
                  summary: Nothing was stored
                  value:
                    message: 'Upload failed: no media was stored.'
        '429':
          $ref: '#/components/responses/RateLimited429'
        '500':
          description: >-
            Something broke on PostSyncer's side. Nothing was stored; it is
            usually safe to send the file again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                upload_failed:
                  summary: Upload failed
                  value:
                    message: Upload failed. Try again in a moment.
components:
  schemas:
    MediaUploadFileResponse:
      type: object
      required:
        - media
      properties:
        media:
          $ref: '#/components/schemas/APIMedia'
    Error:
      type: object
      description: >-
        An error answer. Every one has `message`, in plain words; some add an
        `error` code and fields of their own.
      required:
        - message
      properties:
        message:
          type: string
          description: What went wrong and what to do about it.
        error:
          type: string
          description: >-
            A code a few errors add, such as `rate_limited`. See [Handle
            errors](/essentials/error-handling#answers-with-an-error-code).
    ValidationError:
      type: object
      description: '422: the request didn''t pass validation, and nothing changed.'
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: >-
            The first error and, when there are more, how many: `(and 1 more
            error)`, `(and 2 more errors)`.
        errors:
          type: object
          description: >-
            The messages, by field. A field inside a list is named with dots:
            `accounts.0.id`.
          additionalProperties:
            type: array
            items:
              type: string
    APIMedia:
      type: object
      description: >-
        A file in the media library: what list, get and the uploads give, and
        what posts and comments hold.
      required:
        - id
        - workspace_id
        - folder_id
        - name
        - url
        - mime_type
        - size
        - is_processing
        - type
        - ai_generated_id
        - is_reference
        - progress
        - alt
        - duration_seconds
      properties:
        id:
          type: integer
          description: The file's id. Posts take it in `content[].media`.
        workspace_id:
          type: integer
        folder_id:
          type: integer
          nullable: true
          description: The folder it is in; null at the top of the library.
        name:
          type: string
          description: The file name.
        url:
          type: string
          format: uri
          description: The file itself, at a public link.
        thumb_url:
          type: string
          format: uri
          description: >-
            A picture's small copy (about 400 px on its long edge) for cards and
            lists, or a video's still. Left out until one is made: use `url`
            then. See [Picture
            copies](/api-reference/media/overview#picture-copies).
        medium_url:
          type: string
          format: uri
          description: >-
            A picture's medium copy (about 800 px on its long edge) for large
            tiles and previews. Left out until one is made, and for a picture no
            bigger than 800 px on its long edge, which needs none: use `url`
            then. Videos, GIFs and documents have none.
        mime_type:
          type: string
          nullable: true
          description: The file's type, like `image/jpeg`.
        size:
          type: integer
          nullable: true
          description: The size in bytes.
        is_processing:
          type: boolean
          description: >-
            True while the file is still being made (an AI video, for example).
            It can't go on a post or be deleted until it is ready.
        type:
          type: string
          nullable: true
          enum:
            - image
            - video
            - audio
            - document
            - null
          description: >-
            The kind of file, from `mime_type`: `document` is a PDF, Word or
            PowerPoint file. Null for any other type.
        ai_generated_id:
          type: integer
          nullable: true
          description: Set when PostSyncer's AI made the file; null for uploads.
        is_reference:
          type: boolean
          description: True for a reference picture kept for AI video, not for posting.
        progress:
          type: integer
          description: Always 100.
        alt:
          type: string
          nullable: true
          description: The alt text, when set.
        duration_seconds:
          type: number
          nullable: true
          description: >-
            A video's or sound's length in seconds, read when it was uploaded.
            Null for pictures and documents, and for files stored before lengths
            were read.
  responses:
    Unauthorized401:
      description: No API key, or not a valid one.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthenticated:
              summary: No valid API key
              value:
                message: Unauthenticated.
    RateLimited429:
      description: >-
        More than 60 requests in a minute from this key's user (the API and the
        MCP server share the count). Wait `Retry-After` seconds.
      headers:
        Retry-After:
          description: Seconds until requests are allowed again.
          schema:
            type: integer
        X-RateLimit-Limit:
          description: Requests allowed a minute.
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Requests left this minute.
          schema:
            type: integer
        X-RateLimit-Reset:
          description: When requests are allowed again, as a Unix timestamp.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            too_many_attempts:
              summary: Too many requests
              value:
                message: Too Many Attempts.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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