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

# Import media from links

> Download files from links into 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).

Each link in `urls` is downloaded and stored now. A link can be:

* a file: a picture, video, PDF, Word or PowerPoint file, up to 500 MB;
* a Dropbox or Google Drive share link to a file (not a folder) that anyone with the link can view. Otherwise Dropbox or Drive answers with a page, and the link is refused;
* an Unsplash photo;
* a public social post: every photo and video in it is stored;
* a download link from [Get download links for a post's media](/docs/api-reference/media/download-url.md), while it still works.

The type is read from the file itself, not only from the server's `Content-Type`. Documents publish to LinkedIn only: see [Documents](/docs/api-reference/media/overview.md#documents).

It is all or nothing. When one link can't be used (it can't be reached, it is a web page or another type, it is over 500 MB, or the import takes longer than 75 seconds), nothing is stored, and the `422` names that link and why under `urls.N`. One link can give several files, so read `count_stored` and each `media[].id`.

## 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, or a link can't be used. Nothing was stored. | No: fix or drop that link. Except a social post that "could not be read right now": try it again in a minute. |
| 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 try again. |
| 503 | | A file was downloaded but couldn't be saved: "The media could not be saved. Please try again." Nothing was stored. | Yes. |

## Related

* [Upload a file](/docs/api-reference/media/upload-file.md): a file on disk.
* [Get download links for a post's media](/docs/api-reference/media/download-url.md): see a post's files before you import them.


## OpenAPI

````yaml POST /media/upload/url
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/url:
    post:
      tags:
        - Media
      summary: Import media from links
      description: >-
        Needs `media:create`. Your role in the workspace must also let you add
        media. Downloads each link in `urls` into the media library now: a file
        (a picture, video, PDF, Word or PowerPoint file, up to 500 MB), a
        Dropbox or Google Drive share link, an Unsplash photo, a public social
        post (every photo and video in it), or a download link from [Get
        download links](/api-reference/media/download-url). The type is read
        from the file itself. All or nothing: when one link can't be used,
        nothing is stored and the `422` names that link and why. The whole
        import has 75 seconds.
      operationId: uploadMediaFromUrl
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MediaUploadFromUrlRequest'
            examples:
              default:
                summary: A picture's link
                value:
                  workspace_id: 12
                  urls:
                    - https://cdn.postsyncer.com/examples/latte-art.jpg
              social_post:
                summary: An Instagram post, into a folder
                value:
                  workspace_id: 12
                  urls:
                    - https://www.instagram.com/p/C0ffeeSpr1ng/
                  folder_id: 41
      responses:
        '200':
          description: Every link was stored.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaUploadFromUrlResponse'
              examples:
                default:
                  summary: One 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
                    count_stored: 1
                social_post:
                  summary: A post's two photos
                  value:
                    media:
                      - id: 9054
                        workspace_id: 12
                        folder_id: 41
                        name: haldencoffee-spring-1.jpg
                        url: >-
                          https://cdn.postsyncer.com/examples/haldencoffee-spring-1.jpg
                        mime_type: image/jpeg
                        size: 356204
                        is_processing: false
                        type: image
                        ai_generated_id: null
                        is_reference: false
                        progress: 100
                        alt: null
                        duration_seconds: null
                      - id: 9055
                        workspace_id: 12
                        folder_id: 41
                        name: haldencoffee-spring-2.jpg
                        url: >-
                          https://cdn.postsyncer.com/examples/haldencoffee-spring-2.jpg
                        mime_type: image/jpeg
                        size: 341872
                        is_processing: false
                        type: image
                        ai_generated_id: null
                        is_reference: false
                        progress: 100
                        alt: null
                        duration_seconds: null
                    count_stored: 2
        '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, or a link can't be used (under `urls.N`, naming
            the link and why). Nothing was stored.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                web_page:
                  summary: A web page, not a file
                  value:
                    message: >-
                      The media URL https://haldencoffee.example/menu could not
                      be used: it returned a web page (text/html), not a file.
                      Link to the image or video file itself.
                    errors:
                      urls.0:
                        - >-
                          The media URL https://haldencoffee.example/menu could
                          not be used: it returned a web page (text/html), not a
                          file. Link to the image or video file itself.
                not_found:
                  summary: The link answers 404
                  value:
                    message: >-
                      The media URL
                      https://cdn.postsyncer.com/examples/missing.jpg could not
                      be used: the server answered HTTP 404.
                    errors:
                      urls.0:
                        - >-
                          The media URL
                          https://cdn.postsyncer.com/examples/missing.jpg could
                          not be used: the server answered HTTP 404.
                damaged_image:
                  summary: A damaged picture
                  value:
                    message: >-
                      The media URL https://haldencoffee.example/banner.png
                      could not be used: the image is damaged (part of it
                      declares more data than the file holds, so it was cut
                      short). Save or export it again and link the new file.
                    errors:
                      urls.0:
                        - >-
                          The media URL https://haldencoffee.example/banner.png
                          could not be used: the image is damaged (part of it
                          declares more data than the file holds, so it was cut
                          short). Save or export it again and link the new file.
                no_media_in_post:
                  summary: A post with no photo or video
                  value:
                    message: >-
                      No image or video was found in the post at
                      https://x.com/haldencoffee/status/1900812345678901234.
                    errors:
                      urls.0:
                        - >-
                          No image or video was found in the post at
                          https://x.com/haldencoffee/status/1900812345678901234.
                expired_download_link:
                  summary: An old download link
                  value:
                    message: >-
                      The download link
                      https://postsyncer.com/api/downloads/DOWNLOAD_TOKEN/haldencoffee-spring-1.jpg?expires=1899817200&signature=SIGNATURE
                      has expired or is not valid. Get a fresh link from the
                      post and try again.
                    errors:
                      urls.0:
                        - >-
                          The download link
                          https://postsyncer.com/api/downloads/DOWNLOAD_TOKEN/haldencoffee-spring-1.jpg?expires=1899817200&signature=SIGNATURE
                          has expired or is not valid. Get a fresh link from the
                          post and try again.
                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.
                urls:
                  summary: No links
                  value:
                    message: The urls field is required.
                    errors:
                      urls:
                        - The urls field is required.
        '429':
          $ref: '#/components/responses/RateLimited429'
        '500':
          description: >-
            Something broke on PostSyncer's side. Nothing was stored; it is
            usually safe to try again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                upload_failed:
                  summary: Upload failed
                  value:
                    message: Upload failed. Try again in a moment.
        '503':
          description: >-
            A file was downloaded but couldn't be saved. Nothing was stored; try
            again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                not_saved:
                  summary: The file couldn't be saved
                  value:
                    message: The media could not be saved. Please try again.
components:
  schemas:
    MediaUploadFromUrlRequest:
      type: object
      required:
        - workspace_id
        - urls
      properties:
        workspace_id:
          type: integer
          description: >-
            The workspace whose library gets the files. It must be one the key
            can reach.
        urls:
          type: array
          minItems: 1
          description: >-
            The links to import: files (pictures, videos, PDF, Word or
            PowerPoint), Dropbox and Google Drive share links, Unsplash photos,
            public social posts, and [download
            links](/api-reference/media/download-url) from a post.
          items:
            type: string
            format: uri
            maxLength: 2048
        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.
    MediaUploadFromUrlResponse:
      type: object
      required:
        - media
        - count_stored
      properties:
        media:
          type: array
          items:
            $ref: '#/components/schemas/APIMedia'
          description: >-
            The files stored, in the order of `urls`; a social post's videos
            come before its photos. A social post gives one for each of its
            files.
        count_stored:
          type: integer
          description: How many files were stored.
    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.