# Create Image

This endpoint allows users to create images for hotels by providing either an image URL or a `su_imageid`. This API supports both standard and extranet image uploads.

***

### <mark style="color:yellow;">Endpoint</mark>

<mark style="color:green;background-color:green;">**`POST`**</mark>&#x20;

<div align="left"><figure><img src="https://958347541-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM9bn2UcBkeqtqixkl5eF%2Fuploads%2FpsybX0n39kUB8Z8WOk4X%2FSandbox%20image.png?alt=media&#x26;token=4ae73d0f-0d1a-4d73-a4e2-673dbc081d6a" alt="" width="56"><figcaption></figcaption></figure></div>

{% code overflow="wrap" %}
```url
https://connect-sandbox.su-api.com/SUAPI/jservice/bdc/photo/create
```
{% endcode %}

#### <mark style="color:yellow;">Header</mark>

```xml
-app-id: YOUR_APP_ID
Authorization: YOUR_API_KEY
Content-Type:application/json
```

<table><thead><tr><th width="185">Header</th><th width="85">Type</th><th width="101">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>app-id</code></td><td>string</td><td>Yes</td><td>Your application ID. Required for authentication.</td></tr><tr><td><code>Authorization</code></td><td>string</td><td>Yes</td><td>Your API key. for authorization. Required for authentication.</td></tr><tr><td><code>Content-Type</code></td><td>string</td><td>Yes</td><td>Must be set to <code>application/json</code>.</td></tr></tbody></table>

***

#### <mark style="color:yellow;">Attributes</mark>

`hotel_id` <mark style="color:orange;">**string (Required)**</mark>

The unique property ID as assigned by the provider upon creation of the property.

***

`channel_hotel_id` <mark style="color:orange;">**string (Required)**</mark>

The unique id for the hotel on the specific channel.&#x20;

***

`images` <mark style="color:orange;">**array (Required)**</mark>

List of image objects to be created.

{% hint style="info" %}
Must contain at least one image object.
{% endhint %}

***

<mark style="color:purple;">**Image Object Attributes**</mark>

<table><thead><tr><th width="141">Attribute</th><th width="115">Data Type</th><th>Required/Conditional</th><th>Description</th></tr></thead><tbody><tr><td><code>url</code></td><td>String</td><td>Conditional (if <code>su_imageid</code> is not provided)</td><td>URL of the image to be uploaded.</td></tr><tr><td><code>su_imageid</code></td><td>String</td><td>Conditional (if <code>url</code> is not provided)</td><td>Unique identifier of an existing image.</td></tr><tr><td><code>tags</code></td><td>Array</td><td>Optional</td><td><p>List of the image tag(s) that describe the photo content.</p><p></p><p><strong>Must contain integers; no duplicates.</strong></p><p></p><p>To retrieve all the photo tags used on Booking.com, see <a href="broken-reference">retrieving all photo tags</a>.</p></td></tr></tbody></table>

***

## <mark style="color:yellow;">**Sample Request**</mark>

### <mark style="color:yellow;">Create Image by Providing Image URL</mark>

```json
{
   "hotel_id": "NT7",
   "channel_hotel_id":"12837615",
   "images":[
       {
           "url": "https://www.xxxxxxx.com/xxxx/roadblue/xxxx.jpg",
           "tags": [3,6]
       },
       {
           "url": "https://www.xxxxxxx.com/xxxx/roadblue/xxxx.jpg",
           "tags": [2,4]
       }
   ]
}
```

### <mark style="color:yellow;">Create Image by Providing su\_imageid</mark>

```json
{
   "hotel_id": "NT7",
   "channel_hotel_id":"12837615",
   "images":[
       {
           "su_imageid": "123",
           "tags": [3,6]
       },
       {
           "url": "https://www.xxxxxxx.com/xxxx/roadblue/xxxx.jpg",
           "tags": [2,4]
       }
   ]
}
```

***

## <mark style="color:yellow;">Response</mark>

#### <mark style="color:green;">**Sample Success Response**</mark>

```json
{
   "Status": "Success",
   "Data": [
       {
           "Photo_Batch_Id": "bAmubCUYjSQ"
       }
   ],
   "Message": ""
}
```

#### <mark style="color:yellow;">Success Response Body Elements</mark>

Indicates the result of the API call.&#x20;

{% hint style="info" %}
Will be `"Success"` for successful operations.
{% endhint %}

***

`Data` <mark style="color:orange;">**array**</mark>

An array containing data related to the successful image creation. This typically includes identifiers for the created images.

***

`Photo_Batch_Id` <mark style="color:orange;">**string**</mark>

A unique identifier assigned to a batch of photos upon creation. This identifier serves as a reference for performing subsequent operations related to the photos, including retrieval and updates.

`Message` <mark style="color:orange;">**string**</mark>

A message receives within the response body. This will generally be an empty string if no additional information is needed.

#### <mark style="color:red;">Errors</mark>

<mark style="color:red;">**Sample Error Response 1 - Invalid Hotel Code**</mark>

```json
{
   "Errors": [
       {
           "Code": "400",
           "ShortText": "HotelCode: Invalid HotelCode ('NT711')"
       }
   ],
   "Status": "Fail"
}
```

<mark style="color:red;">**Sample Error Response 2 - Channel Mapping Not Found**</mark>

```json
{
   "Errors": [
       {
           "Code": "573",
           "ShortText": "channel-mapping not found for this property!"
       }
   ],
   "Status": "Fail"
}
```

<mark style="color:red;">**Sample Error Response 3 - Access Denied**</mark>

```json
{
   "Status": "Fail",
   "Errors": [],
   "Message": "Access denied"
}
```

***

<mark style="color:yellow;">**Error Response Body Elements**</mark>

`Status` <mark style="color:orange;">**string**</mark>

Indicates the result of the API call, which will be always `"Fail"` in case of an error response.

***

`Error` <mark style="color:orange;">**array**</mark>

Array that contains details about any errors that occurred during the API call. Each object in the `Errors` array contains the following properties:

`Code` <mark style="color:orange;">**string**</mark>

Specific error code that helps identify the type of error.

{% hint style="info" %}
For example: `"400"` indicates a bad request.
{% endhint %}

`ShortText` <mark style="color:orange;">**string**</mark>

A short description of the error.

***

`Message` <mark style="color:orange;">**string**</mark>

A message providing more information about the error.
