Skip to content

Upload from a URL

POST /public/v1/upload-from-url

Fetches media from a URL and stores it in your media library, returning the same media row upload a file does. Useful when the asset already lives somewhere public and you would rather not download and re-upload it.

Doing this in the app? See the media library. Also available as uploadFromUrlTool (MCP); the CLI has no command for it.

Field Required Description
url Yes A public HTTPS URL ending in an accepted extension.
Terminal window
curl -X POST https://dash.sharek.app/api/public/v1/upload-from-url \
-H "Authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{ "url": "https://media.example.com/launch.png" }'
{
"id": "media-id",
"name": "a1b2c3d4e5.png",
"originalName": null,
"path": "https://media.example.com/a1b2c3d4e5.png",
"thumbnail": null,
"alt": null,
"status": "ready"
}

Sharek stores the file under a generated name with the extension taken from the detected type, so the filename in the URL is not kept.

status reads ready, so the file can go into a post straight away. To read it again later, GET /public/v1/media/:id/status with the media id returns that file’s id, path and status, or 404 Media not found when the id is not in your library.

The file stays in your media library. To reuse an existing upload in a later post, list media returns its id and path again, so there is no need to fetch the URL twice.

The URL is checked before anything is fetched, and the content is checked afterwards. All of these apply:

  1. The path must end in an accepted extension: .png, .jpg, .jpeg, .gif, .webp or .mp4. A query string is ignored for this check, so .../photo.png?v=2 passes.
  2. HTTPS, and a public host. URLs pointing at internal or private network addresses are refused, which rules out fetching from localhost or a private range.
  3. The bytes must match an accepted type, detected after download exactly as for a direct upload. A .png URL serving HTML is refused.
  4. Size caps apply: 10 MB for images, 1 GB for video. Sharek checks the declared Content-Length before downloading and the real size afterwards, so a lying header does not get through.
Response Meaning
400 field validation The url failed the extension or public-HTTPS check, so nothing was fetched.
400 {"msg": "Failed to fetch URL"} The host could not be reached, or answered with a non-success status.
400 {"msg": "Unsupported file type."} Downloaded fine, but the bytes are not an accepted type.
400 {"msg": "Failed to read file"} Sharek could not read the start of the download to detect its type.
400 {"msg": "File is too large."} Over the cap for its type.