> For the complete documentation index, see [llms.txt](https://api-docs.devhub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.devhub.com/content-resources/images.md).

# Images

Covered in this doc:

* [List images](/content-resources/images.md#list-images)
* [Upload a new image (via an External URL)](/content-resources/images.md#upload-a-new-image-via-an-external-url)
* [Upload a new image (via base64)](/content-resources/images.md#upload-a-new-image-via-base64)

## List images

List all images uploaded within a Site

```
GET /api/v2/images/?site_id=12345
```

### Parameters

| Name      | Type     | Description                                                  |
| --------- | -------- | ------------------------------------------------------------ |
| `site_id` | `string` | **optional** ID of the `Site` you want to get the images for |

### Response

```javascript
{
  "meta": {
    "limit": 20,
    "next": "/api/v2/images/?limit=20&offset=20",
    "offset": 0,
    "previous": null,
    "total_count": 5
  },
  "objects": [
    {
      "added": "2012-06-01T09:28:46",
      "height": 1400,
      "id": 1194687,
      "image": "img/upload/c1_26.jpg",
      "mimetype": "image/jpeg",
      "modified": "2012-06-01T09:28:46",
      "resource_uri": "/api/v2/images/1194687/",
      "site_id": 12345,
      "sizes": {
        "big": "img/upload/c1_26.big.jpg",
        "large": "img/upload/c1_26.large.jpg",
        "medium": "img/upload/c1_26.medium.jpg",
        "original": "img/upload/c1_26.jpg",
        "small": "img/upload/c1_26.small.jpg",
        "thumbnail": "img/upload/c1_26.thumbnail.jpg"
      },
      "user_id": 54321,
      "width": 1304
    },
    ...
  ]
}
```

### Full URI of images

Any image file is available publicly using the `image` parameter from the response and prefixing it with the frontend hostname of your API instance.

**Example:**

```
https://yourprivatelabel.cloudfrontend.net/img/upload/c1_26.jpg
```

### Linking to images

If you are using uploaded images within hosted Sites (CSS, HTML, etc), you should reference these images by their local path. You do not want to directly link to `yourprivatelabel.cloudfrontend.net`.

```markup
<img src="/img/upload/c1_26.jpg">
```

```css
.body { background-image: url('/img/upload/c1_26.jpg'); }
```

## Upload a new image (via an External URL)

```
POST /api/v2/images/
```

### Parameters

| Name           | Type      | Description                                                                                 |
| -------------- | --------- | ------------------------------------------------------------------------------------------- |
| `site_id`      | `integer` | **optional** Site to upload the image to                                                    |
| `external_url` | `string`  | **required** Publicly accessible url for the image to be fetched by our system and uploaded |

#### Example

```javascript
{
  "site_id": 12345,
  "external_url": "http://www.examples.com/full/path/to/image.jpg"
}
```

### Response

A status code of `201 created` is returned on a successful creation and contains the created image object as JSON.

## Upload a new image (via base64)

```
POST /api/v2/images/
```

### Parameters

| Name      | Type     | Description  |
| --------- | -------- | ------------ |
| `upload`  | `object` | **required** |
| `site_id` | `int`    | optional     |

#### Example

```javascript
{
  "site_id": 12345,
  "upload": {
    "name": "image.jpg",
    "file": "iVBORw0KGgoAAAANSUhEUgAAASAAAABsCAIAAABFDPh0AAAAGXRFWHRTb2Z0d2F..."
  }
}
```

### Response

A status code of `201 created` is returned on a successful creation and contains the created image object as JSON.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://api-docs.devhub.com/content-resources/images.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
