# Import file from URL

**Publié le** : 2026-05-08
**Catégorie** : Media & Files

## `POST /media/upload-from-url`

**Import file from URL**

Downloads a file from an external URL and stores it in your media
library. Useful for migrating content from other platforms.

Required permissions: `media.upload`

### Request Body

Content-Type: `multipart/form-data`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | Yes | Required |
| `name` | string | No | Display name |
| `alt` | string | No |  |
| `folderId` | string | No | Media folder UUID |
| `preset` | "fast" \| "optimized" \| "quality" | No | One of: fast, optimized, quality |
| `maxWidth` | number | No | Between 100 and 4000 |
| `quality` | number | No | Between 50 and 100 |


### Responses

| Status | Description |
| --- | --- |
| `201` | Successful response |
| `401` | Unauthorized — invalid or missing API token |
| `403` | Forbidden — insufficient permissions |
| `422` | Validation error |


> **Notes:** - The URL must be publicly accessible.
> 
> - Maximum download size: 50 MB.
> - The file is downloaded server-side — no client upload needed.

### Examples

```bash
curl -X POST https://api.lynkow.com/v1/media/upload-from-url \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://images.unsplash.com/photo-example.jpg",
    "alt": "Mountain landscape",
    "folderId": "uuid-of-folder"
  }'
```

### Response Example

```json
{
  "data": {
    "id": "c3d4e5f6-a7b8-9012-cdef-234567890123",
    "filename": "photo-example.jpg",
    "originalName": "photo-example.jpg",
    "mimeType": "image/jpeg",
    "size": 312400,
    "width": 2400,
    "height": 1600,
    "alt": "Mountain landscape",
    "url": "https://cdn.lynkow.com/sites/abc123/photo-example.jpg",
    "variants": {
      "thumbnail": "https://cdn.lynkow.com/sites/abc123/photo-example.jpg?w=150",
      "card": "https://cdn.lynkow.com/sites/abc123/photo-example.jpg?w=400",
      "content": "https://cdn.lynkow.com/sites/abc123/photo-example.jpg?w=800",
      "medium": "https://cdn.lynkow.com/sites/abc123/photo-example.jpg?w=1200"
    },
    "folderId": "uuid-of-folder",
    "createdAt": "2025-04-06T11:45:00.000Z"
  }
}
```

---