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

# Create an upload link

> Get a short-lived link where a person, or an app that runs commands, sends files into a workspace's media library.

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

Makes a link for files an AI app can't pass to PostSyncer itself, like a video attached in Claude or a file on the user's computer. The MCP tool `create-media-upload-link` does the same.

* `url` is a page. The person opens it, with no PostSyncer sign-in, and drops their files on it.
* `upload_url` takes files by `POST`, with no API key. An app that runs commands sends each file there with curl: one request for a file up to 95 MB, or chunks for a bigger one. [Files from AI chats](https://docs.postsyncer.com/guides/files-from-ai-chats.md) has the commands.

Files go into the workspace's library, in `folder_id` when you send one, with the same type rules as [Upload a file](https://docs.postsyncer.com/api-reference/media/upload-file.md): pictures (JPEG, PNG, GIF, WebP), videos (MP4, MOV, WebM) and documents (PDF, DOC, DOCX, PPT, PPTX).

| Limit | Value |
| - | - |
| Works for | 60 minutes (`expires_at`) |
| Files | 10 (`max_files`) |
| One file | 500 MB (`max_file_size`, in bytes) |

The link can only upload: it can't read the library or change anything else. This answer is the only one with `url` and `upload_url`. [Get an upload link](https://docs.postsyncer.com/api-reference/media/upload-link-get.md) gives the link's files, never its addresses, so keep them until the upload is done. A lost link can't be found again: make a new one.

When the person says the upload is done, [get the link](https://docs.postsyncer.com/api-reference/media/upload-link-get.md) for the media ids and put them in a post's `content[].media`.

## 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 | | The workspace isn't one the key can reach, or the folder isn't in it. No link was made. | No: fix the request. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |

## Related

* [Get an upload link](https://docs.postsyncer.com/api-reference/media/upload-link-get.md): the files that arrived.
* [Files from AI chats](https://docs.postsyncer.com/guides/files-from-ai-chats.md): the page, curl, chunks and every answer the upload gives.
* [Upload a file](https://docs.postsyncer.com/api-reference/media/upload-file.md): send a file yourself, with your API key.


## OpenAPI

````yaml POST /media/upload-links
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.
paths:
  /media/upload-links:
    post:
      tags:
        - Media
      summary: Create an upload link
      description: >-
        Needs `media:create`. Your role in the workspace must also let you add
        media. Makes a short-lived link where files go into the workspace's
        media library, for an AI app that can't pass a file to PostSyncer
        itself: a video attached in Claude, say, or a file on the user's
        computer. Give `url` to the person: they open it, with no PostSyncer
        sign-in, and drop the files. An app that runs commands can send each
        file to `upload_url` instead, with no API key. The link works for 60
        minutes and takes up to 10 files of up to 500 MB each. It can only
        upload: it reads and changes nothing else. This answer is the only one
        that gives `url` and `upload_url`; [Get an upload
        link](/api-reference/media/upload-link-get) never does. See [Files from
        AI chats](/guides/files-from-ai-chats) for the upload itself.
      operationId: createMediaUploadLink
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MediaUploadLinkRequest'
            examples:
              default:
                summary: A link for a workspace
                value:
                  workspace_id: 12
              folder:
                summary: Files into a folder
                value:
                  workspace_id: 12
                  folder_id: 41
      responses:
        '201':
          description: The link was made. `media` is empty until a file arrives.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaUploadLinkCreateResponse'
              examples:
                default:
                  summary: A new link
                  value:
                    upload_link:
                      id: 318
                      url: >-
                        https://app.postsyncer.com/upload/Hk3vQ9wLr2TnB7xYc4ZpM8dJf6sAe1Gu5oKi0WqXt2yNb7Rm
                      upload_url: >-
                        https://postsyncer.com/api/media-upload-links/Hk3vQ9wLr2TnB7xYc4ZpM8dJf6sAe1Gu5oKi0WqXt2yNb7Rm/files
                      expires_at: '2030-03-15T10:00:00+00:00'
                      max_files: 10
                      max_file_size: 524288000
                      media: []
        '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 workspace isn't one the key can reach, or the
            folder isn't in it. No link was made.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                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.'
        '429':
          $ref: '#/components/responses/RateLimited429'
components:
  schemas:
    MediaUploadLinkRequest:
      type: object
      required:
        - workspace_id
      properties:
        workspace_id:
          type: integer
          description: >-
            The workspace whose library gets the files. It must be one the key
            can reach.
        folder_id:
          type: integer
          nullable: true
          description: >-
            A folder of the same workspace to put the files in. Left out: the
            top of the library.
    MediaUploadLinkCreateResponse:
      type: object
      required:
        - upload_link
      properties:
        upload_link:
          type: object
          required:
            - id
            - url
            - upload_url
            - expires_at
            - max_files
            - max_file_size
            - media
          properties:
            id:
              type: integer
              description: >-
                The link's id. Read it back with [Get an upload
                link](/api-reference/media/upload-link-get).
            url:
              type: string
              format: uri
              description: >-
                The page a person opens to upload: no PostSyncer sign-in needed.
                Give it as a link they can click. Only this answer has it.
            upload_url:
              type: string
              format: uri
              description: >-
                Where an app that runs commands sends files with `POST`, as
                `multipart/form-data`: see [Files from AI
                chats](/guides/files-from-ai-chats). Only this answer has it.
            expires_at:
              type: string
              format: date-time
              description: 'When the link stops taking files: 60 minutes after it was made.'
            max_files:
              type: integer
              description: 'How many files the link takes: 10.'
            max_file_size:
              type: integer
              description: 'The largest file it takes, in bytes: 524288000 (500 MB).'
            media:
              type: array
              items:
                $ref: '#/components/schemas/APIMedia'
              description: 'Empty: no file has arrived yet.'
    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.
    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.