# Images

### ListImages (GET /:login/images) <a href="#listimages" id="listimages"></a>

Provides a list of images available in this datacenter.

Note: Currently, *Docker* images are not included in this endpoint's responses. You must use `docker images` against the [docker](https://apidocs.joyent.com/docker) service for this datacenter.

#### Inputs <a href="#inputs-30" id="inputs-30"></a>

The following optional query parameters are available to filter the list of images:

| **Field** | **Type** | **Description**                                                                                                                                       |
| --------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| name      | String   | The "friendly" name for this image                                                                                                                    |
| os        | String   | The underlying operating system for this image                                                                                                        |
| version   | String   | The version for this image                                                                                                                            |
| public    | Boolean  | Filter public/private images                                                                                                                          |
| state     | String   | Filter on image [state](https://images.joyent.com/docs/#manifest-state). By default only active images are shown. Use `?state=all` to list all images |
| owner     | String   | Filter on owner UUID                                                                                                                                  |
| type      | String   | Filter on image type. The types changed in v8.0.0                                                                                                     |

#### Returns <a href="#returns-30" id="returns-30"></a>

An array of images. Image objects include the following fields:

| **Field**                | **Type**     | **Description**                                                                                                                                                                                                                                 |
| ------------------------ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id                       | UUID         | Unique id for this image                                                                                                                                                                                                                        |
| name                     | String       | The "friendly" name for this image                                                                                                                                                                                                              |
| os                       | String       | The underlying operating system for this image                                                                                                                                                                                                  |
| version                  | String       | The version for this image                                                                                                                                                                                                                      |
| type                     | String       | What kind of image this is. The values differ after v8.0.0+                                                                                                                                                                                     |
| requirements             | Object       | Contains a grouping of various minimum requirements for provisioning an instance with this image. For example 'password' indicates that a password must be provided                                                                             |
| requirements.max\_ram    | String       | Indicates the maximum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.max\_memory | String       | Indicates the maximum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.min\_ram    | String       | Indicates the minimum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.min\_memory | String       | Indicates the minimum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.brand       | String       | Indicates which brand has to be used in the VM manifest to provision a VM based on this image.                                                                                                                                                  |
| homepage                 | String       | The URL for a web page with more detailed information for this image                                                                                                                                                                            |
| files                    | Array        | An array of image files that make up each image. Currently only a single file per image is supported                                                                                                                                            |
| files\[0].compression    | String       | The type of file compression used for the image file. One of 'bzip2', 'gzip', 'none'                                                                                                                                                            |
| files\[0].sha1           | String       | SHA-1 hex digest of the file content. Used for corruption checking                                                                                                                                                                              |
| files\[0].size           | Number       | File size in bytes                                                                                                                                                                                                                              |
| published\_at            | ISO8859 date | The time this image has been made publicly available                                                                                                                                                                                            |
| owner                    | String       | The UUID of the user who owns this image                                                                                                                                                                                                        |
| public                   | Boolean      | Indicates if this image is publicly available                                                                                                                                                                                                   |
| state                    | String       | The current state of the image. One of 'active', 'unactivated', 'disabled', 'creating', 'failed'                                                                                                                                                |
| tags                     | Object       | An object of key/value pairs that allows clients to categorize images by any given criteria                                                                                                                                                     |
| eula                     | String       | URL of the End User License Agreement (EULA) for the image                                                                                                                                                                                      |
| acl                      | Array        | Access Control List. An array of account UUIDs given access to a private image. The field is only relevant to private images.                                                                                                                   |
| error                    | Object       | If `state=="failed"`, resulting from [CreateImageFromMachine](https://apidocs.joyent.com/cloudapi/#CreateImageFromMachine) failure, then there may be an error object of the form `{"code": "<string error code>", "message": "<string desc>"}` |
| error.code               | String       | A CamelCase string code for this error, e.g. "PrepareImageDidNotRun". See [GetImage](https://apidocs.joyent.com/cloudapi/#GetImage) docs for a table of error.code values                                                                       |
| error.message            | String       | A short description of the image creation failure                                                                                                                                                                                               |

#### Errors <a href="#errors-30" id="errors-30"></a>

For all possible errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses).

| **Error Code**   | **Description**           |
| ---------------- | ------------------------- |
| ResourceNotFound | If `login` does not exist |

#### CLI Command <a href="#cli-command-33" id="cli-command-33"></a>

```
triton image list
```

or

```
sdc-listimages
```

#### Example Request <a href="#example-request-28" id="example-request-28"></a>

```
GET /my/images HTTP/1.1
Host: api.example.com
Authorization: Signature keyId...
Accept: application/json
Api-Version: ~8
```

#### Example Response <a href="#example-response-28" id="example-response-28"></a>

```
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 611
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: 9eDxMdIxc+3aED7Z3qyL8w==
Date: Thu, 21 Jan 2016 07:57:59 GMT
Server: Joyent Triton 8.0.0
Api-Version: 8.0.0
Request-Id: af34a510-c014-11e5-9c73-6767e338bf5d
Response-Time: 1506

[
  {
    "id": "2b683a82-a066-11e3-97ab-2faa44701c5a",
    "name": "base",
    "version": "13.4.0",
    "os": "smartos",
    "requirements": {},
    "type": "zone-dataset",
    "description": "A 32-bit SmartOS image with just essential packages installed. Ideal for users who are comfortable with setting up their own environment and tools.",
    "files": [
      {
        "compression": "gzip",
        "sha1": "3bebb6ae2cdb26eef20cfb30fdc4a00a059a0b7b",
        "size": 110742036
      }
    ],
    "tags": {
      "role": "os",
      "group": "base-32"
    },
    "homepage": "https://docs.joyent.com/images/smartos/base",
    "published_at": "2014-02-28T10:50:42Z",
    "owner": "930896af-bf8c-48d4-885c-6573a94b1853",
    "public": true,
    "state": "active"
  },
  ...
]
```

### GetImage (GET /:login/images/:id) <a href="#getimage" id="getimage"></a>

Gets an individual image by `id`.

#### Inputs <a href="#inputs-31" id="inputs-31"></a>

None

#### Returns <a href="#returns-31" id="returns-31"></a>

| **Field**                | **Type**     | **Description**                                                                                                                                                                                                                                 |
| ------------------------ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id                       | UUID         | Unique id for this image                                                                                                                                                                                                                        |
| name                     | String       | The "friendly" name for this image                                                                                                                                                                                                              |
| os                       | String       | The underlying operating system for this image                                                                                                                                                                                                  |
| version                  | String       | The version for this image                                                                                                                                                                                                                      |
| type                     | String       | What kind of image this is. The values differ after v8.0.0+                                                                                                                                                                                     |
| requirements             | Object       | Contains a grouping of various minimum requirements for provisioning an instance with this image. For example 'password' indicates that a password must be provided                                                                             |
| requirements.max\_ram    | String       | Indicates the maximum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.max\_memory | String       | Indicates the maximum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.min\_ram    | String       | Indicates the minimum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.min\_memory | String       | Indicates the minimum RAM requirement that must be provided in the VM manifest to provision a VM based on this image.                                                                                                                           |
| requirements.brand       | String       | Indicates which brand has to be used in the VM manifest to provision a VM based on this image.                                                                                                                                                  |
| homepage                 | String       | The URL for a web page with more detailed information for this image                                                                                                                                                                            |
| files                    | Array        | An array of image files that make up each image. Currently only a single file per image is supported                                                                                                                                            |
| files\[0].compression    | String       | The type of file compression used for the image file. One of 'bzip2', 'gzip', 'none'                                                                                                                                                            |
| files\[0].sha1           | String       | SHA-1 hex digest of the file content. Used for corruption checking                                                                                                                                                                              |
| files\[0].size           | Number       | File size in bytes                                                                                                                                                                                                                              |
| published\_at            | ISO8859 date | The time this image has been made publicly available                                                                                                                                                                                            |
| owner                    | String       | The UUID of the user who owns this image                                                                                                                                                                                                        |
| public                   | Boolean      | Indicates if this image is publicly available                                                                                                                                                                                                   |
| state                    | String       | The current state of the image. One of 'active', 'unactivated', 'disabled', 'creating', 'failed'                                                                                                                                                |
| tags                     | Object       | An object of key/value pairs that allows clients to categorize images by any given criteria                                                                                                                                                     |
| eula                     | String       | URL of the End User License Agreement (EULA) for the image                                                                                                                                                                                      |
| acl                      | Array        | Access Control List. An array of account UUIDs given access to a private image. The field is only relevant to private images.                                                                                                                   |
| error                    | Object       | If `state=="failed"`, resulting from [CreateImageFromMachine](https://apidocs.joyent.com/cloudapi/#CreateImageFromMachine) failure, then there may be an error object of the form `{"code": "<string error code>", "message": "<string desc>"}` |
| error.code               | String       | A CamelCase string code for this error, e.g. "PrepareImageDidNotRun". See [GetImage](https://apidocs.joyent.com/cloudapi/#GetImage) docs for a table of error.code values                                                                       |
| error.message            | String       | A short description of the image creation failure                                                                                                                                                                                               |

Possible `error.code` values:

| **error.code**        | **Details**                                                                                                                                                                                                                                                                                                                                                         |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PrepareImageDidNotRun | This typically means that the target harware virtual machine (e.g. Linux) has old guest tools that pre-date the image creation feature. Guest tools can be upgraded with installers at <https://download.joyent.com/pub/guest-tools/>. Other possibilities are: a boot time greater than the five-minute timeout, or a bug or crash in the image-preparation script |
| VmHasNoOrigin         | Origin image data could not be found for the instance. Typically this is for an instance *migrated* before image creation support was added                                                                                                                                                                                                                         |
| NotSupported          | Indicates an error due to functionality that isn't currently supported. One example is that custom image creation of an instance based on a custom image isn't currently supported                                                                                                                                                                                  |
| InternalError         | A catch-all error for unexpected or internal errors                                                                                                                                                                                                                                                                                                                 |

#### Errors <a href="#errors-31" id="errors-31"></a>

For all possible errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses).

#### CLI Command <a href="#cli-command-34" id="cli-command-34"></a>

```
triton image get 2b683a82-a066-11e3-97ab-2faa44701c5a
```

or

```
sdc-getimage 2b683a82-a066-11e3-97ab-2faa44701c5a
```

**Example Request**

```
GET /my/images/2b683a82-a066-11e3-97ab-2faa44701c5a HTTP/1.1
Host: api.example.com
Authorization: Signature keyId...
Accept: application/json
Api-Version: ~8
```

**Example Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 609
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST, DELETE
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: 42n5PWY5xZP0lnjdMb7Omg==
Date: Thu, 21 Jan 2016 08:00:09 GMT
Server: Joyent Triton 8.0.0
Api-Version: 8.0.0
Request-Id: fd5679d0-c014-11e5-a8f8-951890fd520a
Response-Time: 876

{
  "id": "2b683a82-a066-11e3-97ab-2faa44701c5a",
  "name": "base",
  "version": "13.4.0",
  "os": "smartos",
  "requirements": {},
  "type": "zone-dataset",
  "description": "A 32-bit SmartOS image with just essential packages installed. Ideal for users who are comfortable with setting up their own environment and tools.",
  "files": [
    {
      "compression": "gzip",
      "sha1": "3bebb6ae2cdb26eef20cfb30fdc4a00a059a0b7b",
      "size": 110742036
    }
  ],
  "tags": {
    "role": "os",
    "group": "base-32"
  },
  "homepage": "https://docs.joyent.com/images/smartos/base",
  "published_at": "2014-02-28T10:50:42Z",
  "owner": "930896af-bf8c-48d4-885c-6573a94b1853",
  "public": true,
  "state": "active"
}
```

### DeleteImage (DELETE /:login/images/:id) <a href="#deleteimage" id="deleteimage"></a>

Delete an image. Caller must be the owner of the image to delete it.

#### Inputs <a href="#inputs-32" id="inputs-32"></a>

None

#### Returns <a href="#returns-32" id="returns-32"></a>

Responds with HTTP 204 'No Content'.

#### Errors <a href="#errors-32" id="errors-32"></a>

For all possible errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses).

| **Error Code**   | **Description**                     |
| ---------------- | ----------------------------------- |
| ResourceNotFound | If `:login` or `:id` does not exist |

#### CLI Command <a href="#cli-command-35" id="cli-command-35"></a>

```
triton image delete 2b683a82-a066-11e3-97ab-2faa44701c5a
```

or

```
sdc-deleteimage 2b683a82-a066-11e3-97ab-2faa44701c5a
```

**Example Request**

```
DELETE /my/images/2b683a82-a066-11e3-97ab-2faa44701c5a HTTP/1.1
Authorization: ...
Host: api.example.com
Accept: application/json
Api-Version: ~8
```

**Example Response**

```
HTTP/1.1 204 No Content
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST, DELETE
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: 83MuHssrpOMWvPXLB9stgg==
Date: Thu, 21 Jan 2016 08:02:08 GMT
Server: Joyent Triton 8.0.0
Api-Version: 8.0.0
Request-Id: 440f5590-c015-11e5-b5f9-2b49303f7fc4
Response-Time: 1262
```

### ExportImage (POST /:login/images/:id?action=export) <a href="#exportimage" id="exportimage"></a>

Exports an image to the specified Manta path. Caller must be the owner of the image, and the correspondent Manta path prefix, in order to export it. Both the image manifest and the image file will be exported, and their filenames will default to the following format when the specified manta path is a directory:

```
<manta_path>/NAME-VER.imgmanifest
<manta_path>/NAME-VER.zfs.FILE-EXT
```

Where NAME is the image name and VER is the image version. FILE-EXT is the file extension of the image file. As an example, exporting a foo-1.0.0 image to /user/stor/cloudapi would result in the following files being exported:

```
/user/stor/cloudapi/foo-1.0.0.imgmanifest
/user/stor/cloudapi/foo-1.0.0.zfs.gz
```

By contrast, if the basename of the given prefix is not a directory, then "MANTA\_PATH.imgmanifest" and "MANTA\_PATH.zfs\[.EXT]" are created. As an example, the following shows how to export foo-1.0.0 with a custom name:

```
/my/images/<uuid>?action=export&manta_path=/user/stor/my-image

/user/stor/my-image.imgmanifest
/user/stor/my-image.zfs.gz
```

#### Inputs <a href="#inputs-33" id="inputs-33"></a>

| **Field**   | **Type** | **Description**                                 |
| ----------- | -------- | ----------------------------------------------- |
| manta\_path | String   | Manta path prefix used when exporting the image |

#### Returns <a href="#returns-33" id="returns-33"></a>

A Manta location response object. It provides the properties that allow a CloudAPI user to retrieve the image file and manifest from Manta: manta\_url, image\_path, manifest\_path.

#### Errors <a href="#errors-33" id="errors-33"></a>

For all possible errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses).

| **Error Code**   | **Description**                     |
| ---------------- | ----------------------------------- |
| ResourceNotFound | If `:login` or `:id` does not exist |

#### CLI Command <a href="#cli-command-36" id="cli-command-36"></a>

```
sdc-exportimage --mantaPath=/user/stor/my-image 0c428eb9-7f03-4bb0-ac9f-c0718945d604
```

**Example Request**

```
POST /my/images/e42f8c84-bbea-11e2-b920-078fab2aab1f?action=export&manta_path=/user/stor/my-image HTTP/1.1
Authorization: ...
Host: api.example.com
Accept: application/json
Api-Version: ~8
```

**Example Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 150
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST, DELETE
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: qSUhN+dwdJKEFlcyrUdBiw==
Date: Thu, 21 Jan 2016 08:00:09 GMT
Server: Joyent Triton 8.0.0
Api-Version: 8.0.0
Request-Id: 8180ad80-14ef-11e3-a62d-89e8106c294e
Response-Time: 670

{
  "manta_url": "https://us-east.manta.joyent.com",
  "image_path": "/user/stor/my-image.zfs.gz",
  "manifest_path": "/user/stor/my-image.imgmanifest"
}
```

### CreateImageFromMachine (POST /:login/images) <a href="#createimagefrommachine" id="createimagefrommachine"></a>

Create a new custom image from an instance. The typical process is:

1. Customize an instance the way you want it.
2. Call this endpoint (CreateImageFromMachine) to create a new image.
3. Repeat from step 1 if more customizations are desired with different images.
4. Use the new image(s) for provisioning via [CreateMachine](https://apidocs.joyent.com/cloudapi/#CreateMachine).

#### Inputs <a href="#inputs-34" id="inputs-34"></a>

All inputs except `machine` are image manifest fields as defined by [the IMGAPI docs](https://images.joyent.com/docs/#image-manifests). Note that not all fields listed there can be specified here.

| **Field**   | **Type** | **Required?** | **Description**                                                                                                                    |
| ----------- | -------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| machine     | UUID     | Yes           | The prepared and stopped instance UUID from which the image is to be created                                                       |
| name        | String   | Yes           | The name of the custom image, e.g. "my-image". See the [IMGAPI docs](https://images.joyent.com/docs/#manifest-name) for details    |
| version     | String   | Yes           | The version of the custom image, e.g. "1.0.0". See the [IMGAPI docs](https://images.joyent.com/docs/#manifest-version) for details |
| description | String   | No            | The image [description](https://images.joyent.com/docs/#manifest-description)                                                      |
| homepage    | String   | No            | The image [homepage](https://images.joyent.com/docs/#manifest-homepage)                                                            |
| eula        | String   | No            | The image [eula](https://images.joyent.com/docs/#manifest-eula)                                                                    |
| acl         | String   | No            | The image [acl](https://images.joyent.com/docs/#manifest-acl)                                                                      |
| tags        | String   | No            | The image [tags](https://images.joyent.com/docs/#manifest-tags)                                                                    |

#### Returns <a href="#returns-34" id="returns-34"></a>

| **Field**             | **Type**     | **Description**                                                                                                                                                     |
| --------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id                    | UUID         | Unique id for this image                                                                                                                                            |
| name                  | String       | The "friendly" name for this image                                                                                                                                  |
| os                    | String       | The underlying operating system for this image                                                                                                                      |
| version               | String       | The version for this image                                                                                                                                          |
| type                  | String       | What kind of image this is. The values differ after v8.0.0+                                                                                                         |
| requirements          | Object       | Contains a grouping of various minimum requirements for provisioning an instance with this image. For example 'password' indicates that a password must be provided |
| homepage              | String       | The URL for a web page with more detailed information for this image                                                                                                |
| files                 | Array        | An array of image files that make up each image. Currently only a single file per image is supported                                                                |
| files\[0].compression | String       | The type of file compression used for the image file. One of 'bzip2', 'gzip', 'none'                                                                                |
| files\[0].sha1        | String       | SHA-1 hex digest of the file content. Used for corruption checking                                                                                                  |
| files\[0].size        | Number       | File size in bytes                                                                                                                                                  |
| published\_at         | ISO8859 date | The time this image has been made publicly available                                                                                                                |
| owner                 | String       | The UUID of the user who owns this image                                                                                                                            |
| public                | Boolean      | Indicates if this image is publicly available                                                                                                                       |
| state                 | String       | The current state of the image. One of 'active', 'unactivated', 'disabled', 'creating', 'failed'                                                                    |
| tags                  | Object       | An object of key/value pairs that allows clients to categorize images by any given criteria                                                                         |
| eula                  | String       | URL of the End User License Agreement (EULA) for the image                                                                                                          |
| acl                   | Array        | Access Control List. An array of account UUIDs given access to a private image. The field is only relevant to private images                                        |

#### Errors <a href="#errors-34" id="errors-34"></a>

For general errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses). Some typical and specific errors for this endpoint:

| **Error Code**                 | **Description**                                                                                                |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| InsufficientServerVersionError | The `machine` given is running on a server that is too old                                                     |
| NotAvailable                   | Typically this indicates that image creation is not supported for the OS of the given hardware virtual machine |

#### Example CLI Command <a href="#example-cli-command" id="example-cli-command"></a>

```
triton image create a44f2b9b-e7af-f548-b0ba-4d9270423f1a my-custom-image 1.0.0
```

or

```
sdc-createimagefrommachine --machine=a44f2b9b-e7af-f548-b0ba-4d9270423f1a --name=my-custom-image --imageVersion=1.0.0
```

**Example HTTP Request**

```
POST /my/images HTTP/1.1
Authorization: ...
Host: api.example.com
Accept: application/json
Api-Version: ~8

{
  "machine": "a44f2b9b-e7af-f548-b0ba-4d9270423f1a",
  "name": "my-custom-image",
  "version": "1.0.0"
}
```

**Example HTTP Response**

```
HTTP/1.1 201 Created
x-joyent-jobid: 0b30ef20-d622-436a-9c30-7376ba7d904c
Location: /admin/images/b87616a2-7a49-4e02-a71d-2e0ce5a2f037
Content-Type: application/json
Content-Length: 125
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: 2sEZ45LmhRiretMPn5sqVA==
Date: Thu, 21 Jan 2016 08:00:09 GMT
Server: Joyent Triton 8.0.0
Api-Version: 8.0.0
Request-Id: 88af23b0-f952-11e2-8f2c-fff0ec35f4ce
Response-Time: 160

{
    "id": "62306cd7-7b8a-c5dd-d44e-8491c83b9974",
    "name": "my-custom-image",
    "version": "1.2.3",
    "requirements": {},
    "owner": "47034e57-42d1-0342-b302-00db733e8c8a",
    "public": false,
    "state": "creating"
}
```

### ImportImageFromDatacenter (POST /:login/images?action=import-from-datacenter) <a href="#importimagefromdatacenter" id="importimagefromdatacenter"></a>

This will copy the image with `id` from the source `datacenter` into this datacenter. The copied image will retain all fields (e.g. `id`, `published_at`) as the original image. All incremental images in the origin chain will also be copied.

You can use [triton datacenters](https://apidocs.joyent.com/cloudapi/#ListDatacenters) to view the list of datacenter names in the current cloud.

#### Inputs <a href="#inputs-35" id="inputs-35"></a>

The following query parameters are required, these parameters will be used to identify the image to be copied.

| **Field**  | **Type** | **Description**                                               |
| ---------- | -------- | ------------------------------------------------------------- |
| datacenter | String   | The datacenter name from where the image will be copied from. |
| id         | UUID     | The id of the image to be copied.                             |

#### Returns <a href="#returns-35" id="returns-35"></a>

On success, an Image object is returned. See [GetImage](https://apidocs.joyent.com/cloudapi/#GetImage) for the fields that are returned in the image object.

#### Errors <a href="#errors-35" id="errors-35"></a>

For general errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses). Some typical and specific errors for this endpoint:

| **Error Code**              | **Description**                                             |
| --------------------------- | ----------------------------------------------------------- |
| ImageUuidAlreadyExistsError | The image with `id` already exists in this datacenter.      |
| UnauthorizedError           | If the source image is owned by the admin.                  |
| OriginIsNotActiveError      | If one of the incremental (origin) images is not activated. |

#### Example CLI Command <a href="#example-cli-command-2" id="example-cli-command-2"></a>

```
triton image copy 7eed8e50-e452-428d-9131-bf056aa911bd us-west-1
```

**Example HTTP Request**

```
POST /my/images?action=import-from-datacenter&datacenter=us-west-1&id=7eed8e50-e452-428d-9131-bf056aa911bd HTTP/1.1
Authorization: ...
Host: api.example.com
Accept: application/json
Api-Version: ~9

{}
```

**Example HTTP Response**

```
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 125
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: 2sEZ45LmhRiretMPn5sqVA==
Date: Thu, 21 Jan 2018 08:00:09 GMT
Server: cloudapi/9.2.0
Api-Version: 9.0.0
Request-Id: 49af23b0-f952-11e2-8f2c-fff0ec35f4ce
Response-Time: 460

{
  "id": "7eed8e50-e452-428d-9131-bf056aa911bd",
  "name": "myimage",
  "version": "1.4.0",
  "os": "smartos",
  "requirements": {},
  "type": "zone-dataset",
  "description": "A custom image used to test stuff.",
  "files": [
    {
      "compression": "gzip",
      "sha1": "3bebb6ae2cdb26eef20cfb30fdc4a00a059a0b7b",
      "size": 110742036
    }
  ],
  "published_at": "2015-02-28T10:50:42Z",
  "owner": "930896af-bf8c-48d4-885c-6573a94b1853",
  "public": false,
  "state": "active"
}
```

### UpdateImage (POST /:login/images/:id?action=update) <a href="#updateimage" id="updateimage"></a>

Updates metadata about an image.

#### Inputs <a href="#inputs-36" id="inputs-36"></a>

Only the image attributes listed below can be updated.

| **Field**   | **Type** | **Description**                                                                                                                    |
| ----------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| name        | String   | The name of the custom image, e.g. "my-image". See the [IMGAPI docs](https://images.joyent.com/docs/#manifest-name) for details    |
| version     | String   | The version of the custom image, e.g. "1.0.0". See the [IMGAPI docs](https://images.joyent.com/docs/#manifest-version) for details |
| description | String   | The image [description](https://images.joyent.com/docs/#manifest-description)                                                      |
| homepage    | String   | The image [homepage](https://images.joyent.com/docs/#manifest-homepage)                                                            |
| eula        | String   | The image [eula](https://images.joyent.com/docs/#manifest-eula)                                                                    |
| acl         | String   | The image [acl](https://images.joyent.com/docs/#manifest-acl)                                                                      |
| tags        | String   | The image [tags](https://images.joyent.com/docs/#manifest-tags)                                                                    |

#### Returns <a href="#returns-36" id="returns-36"></a>

An updated image object.

| **Field**             | **Type**     | **Description**                                                                                                                                                     |
| --------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id                    | UUID         | Unique id for this image                                                                                                                                            |
| name                  | String       | The "friendly" name for this image                                                                                                                                  |
| os                    | String       | The underlying operating system for this image                                                                                                                      |
| version               | String       | The version for this image                                                                                                                                          |
| type                  | String       | What kind of image this is. The values differ after v8.0.0+                                                                                                         |
| requirements          | Object       | Contains a grouping of various minimum requirements for provisioning an instance with this image. For example 'password' indicates that a password must be provided |
| homepage              | String       | The URL for a web page with more detailed information for this image                                                                                                |
| files                 | Array        | An array of image files that make up each image. Currently only a single file per image is supported                                                                |
| files\[0].compression | String       | The type of file compression used for the image file. One of 'bzip2', 'gzip', 'none'                                                                                |
| files\[0].sha1        | String       | SHA-1 hex digest of the file content. Used for corruption checking                                                                                                  |
| files\[0].size        | Number       | File size in bytes                                                                                                                                                  |
| published\_at         | ISO8859 date | The time this image has been made publicly available                                                                                                                |
| owner                 | String       | The UUID of the user who owns this image                                                                                                                            |
| public                | Boolean      | Indicates if this image is publicly available                                                                                                                       |
| state                 | String       | The current state of the image. One of 'active', 'unactivated', 'disabled', 'creating', 'failed'                                                                    |
| tags                  | Object       | An object of key/value pairs that allows clients to categorize images by any given criteria                                                                         |
| eula                  | String       | URL of the End User License Agreement (EULA) for the image                                                                                                          |
| acl                   | Array        | Access Control List. An array of account UUIDs given access to a private image. The field is only relevant to private images                                        |

#### Errors <a href="#errors-36" id="errors-36"></a>

For general errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses). Some typical and specific errors for this endpoint:

| **Error Code**   | **Description**                     |
| ---------------- | ----------------------------------- |
| ResourceNotFound | If `:login` or `:id` does not exist |

#### Example CLI Command <a href="#example-cli-command-3" id="example-cli-command-3"></a>

```
sdc-updateimage --name=my-renamed-image eca995fe-b904-11e3-b05a-83a4899322dc
```

**Example HTTP Request**

```
POST /my/images/eca995fe-b904-11e3-b05a-83a4899322dc?action=update HTTP/1.1
Authorization: ...
Host: api.example.com
Accept: application/json
Api-Version: ~8

{
  "name": "my-renamed-image",
}
```

**Example HTTP Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 125
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: 2sEZ45LmhRiretMPn5sqVA==
Date: Thu, 21 Jan 2016 08:00:09 GMT
Server: Joyent Triton 8.0.0
Api-Version: 8.0.0
Request-Id: b8e43c60-b904-11e3-93b7-1f685001b0c3
Response-Time: 135

{
  "id": "eca995fe-b904-11e3-b05a-83a4899322dc",
  "name": "my-renamed-image",
  "version": "1.0.0",
  "os": "smartos",
  "requirements": {},
  "type": "zone-dataset",
  "published_at": "2013-11-25T17:44:54Z",
  "owner": "47034e57-42d1-0342-b302-00db733e8c8a",
  "public": true,
  "state": "active"
}
```

### CloneImage (POST /:login/images/:id?action=clone) <a href="#cloneimage" id="cloneimage"></a>

Creates an independent copy of the source image. The `login` account must be on the source image ACL to be able to make an image clone.

The resulting cloned image will have the same properties as the source image, but the cloned image will have a different id, it will be owned by the `login` account and the image will have an empty ACL.

All incremental images in the image origin chain that are not operator images (i.e. are not owned by admin) will also be cloned, though all cloned incremental images will have state `disabled` so that they are not visible in the default image listings.

#### Inputs <a href="#inputs-37" id="inputs-37"></a>

None.

#### Returns <a href="#returns-37" id="returns-37"></a>

A cloned image object. See [GetImage](https://apidocs.joyent.com/cloudapi/#GetImage) docs for the image fields returned.

#### Errors <a href="#errors-37" id="errors-37"></a>

For general errors, see [CloudAPI HTTP Responses](https://apidocs.joyent.com/cloudapi/#cloudapi-http-responses). Some typical and specific errors for this endpoint:

| **Error Code**     | **Description**                                       |
| ------------------ | ----------------------------------------------------- |
| ResourceNotFound   | If `:login` or `:id` does not exist.                  |
| NotImageOwnerError | If your account is not the owner of the image.        |
| ImageNotShared     | When the given image is not shared with your account. |

#### Example CLI Command <a href="#example-cli-command-4" id="example-cli-command-4"></a>

```
triton image clone eca995fe-b904-11e3-b05a-83a4899322dc
```

**Example HTTP Request**

```
POST /my/images/eca995fe-b904-11e3-b05a-83a4899322dc?action=clone HTTP/1.1
Authorization: ...
Host: api.example.com
Accept: application/json
Api-Version: ~8
```

**Example HTTP Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 125
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET, HEAD, POST
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: Keep-Alive
Content-MD5: 2sEZ45LmhRiretMPn5sqVA==
Date: Thu, 21 Jan 2016 08:00:09 GMT
Server: Joyent Triton 8.0.0
Api-Version: 8.0.0
Request-Id: f8e43c60-b904-11e3-93b7-1f685001b0c3
Response-Time: 135

{
  "id": "4ca995fe-b904-11e3-b05a-83a4899322dc",
  "name": "some-image",
  "version": "1.0.0",
  "os": "smartos",
  "requirements": {},
  "type": "zone-dataset",
  "published_at": "2017-11-25T17:44:54Z",
  "owner": "77034e57-42d1-0342-b302-00db733e8c8a",
  "public": true,
  "state": "active"
}
```
