# KlaviyoAPI::ImagesApi
All URIs are relative to *https://a.klaviyo.com*
| Method | HTTP request | Description |
| ------ | ------------ | ----------- |
| [**get_image**](ImagesApi.md#get_image) | **GET** /api/images/{id}/ | Get Image |
| [**get_images**](ImagesApi.md#get_images) | **GET** /api/images/ | Get Images |
| [**update_image**](ImagesApi.md#update_image) | **PATCH** /api/images/{id}/ | Update Image |
| [**upload_image_from_file**](ImagesApi.md#upload_image_from_file) | **POST** /api/image-upload/ | Upload Image From File |
| [**upload_image_from_url**](ImagesApi.md#upload_image_from_url) | **POST** /api/images/ | Upload Image From URL |
## get_image
> Hash<String, Object> get_image(id, opts)
Get Image
Get the image with the given image ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `images:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::ImagesApi.new
id = '7' # String | The ID of the image
opts = {
fields_image: ['name'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Image
result = api_instance.get_image(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->get_image: #{e}"
end
```
#### Using the get_image_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_image_with_http_info(id, opts)
```ruby
begin
# Get Image
data, status_code, headers = api_instance.get_image_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->get_image_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The ID of the image | |
| **fields_image** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## get_images
> Hash<String, Object> get_images(opts)
Get Images
Get all images in an account.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `images:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::ImagesApi.new
opts = {
fields_image: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
filter: 'filter_example', # String | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#filtering
Allowed field(s)/operator(s):
`id`: `any`, `equals`
`updated_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
`format`: `any`, `equals`
`name`: `any`, `contains`, `ends-with`, `equals`, `starts-with`
`size`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
`hidden`: `any`, `equals`
page_cursor: 'page_cursor_example', # String | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#pagination
page_size: 56, # Integer | Default: 20. Min: 1. Max: 100.
sort: 'format' # String | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sorting
}
begin
# Get Images
result = api_instance.get_images(opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->get_images: #{e}"
end
```
#### Using the get_images_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_images_with_http_info(opts)
```ruby
begin
# Get Images
data, status_code, headers = api_instance.get_images_with_http_info(opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->get_images_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **fields_image** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **filter** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`, `equals`<br>`updated_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`format`: `any`, `equals`<br>`name`: `any`, `contains`, `ends-with`, `equals`, `starts-with`<br>`size`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`hidden`: `any`, `equals` | [optional] |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#pagination | [optional] |
| **page_size** | **Integer** | Default: 20. Min: 1. Max: 100. | [optional][default to 20] |
| **sort** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sorting | [optional] |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## update_image
> Hash<String, Object> update_image(id, image_partial_update_query)
Update Image
Update the image with the given image ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `images:write`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::ImagesApi.new
id = '7' # String | The ID of the image
image_partial_update_query = KlaviyoAPI::ImagePartialUpdateQuery.new({data: KlaviyoAPI::ImagePartialUpdateQueryResourceObject.new({type: KlaviyoAPI::ImageEnum::IMAGE, id: '7', attributes: KlaviyoAPI::ImagePartialUpdateQueryResourceObjectAttributes.new})}) # ImagePartialUpdateQuery |
begin
# Update Image
result = api_instance.update_image(id, image_partial_update_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->update_image: #{e}"
end
```
#### Using the update_image_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> update_image_with_http_info(id, image_partial_update_query)
```ruby
begin
# Update Image
data, status_code, headers = api_instance.update_image_with_http_info(id, image_partial_update_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->update_image_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The ID of the image | |
| **image_partial_update_query** | [**ImagePartialUpdateQuery**](ImagePartialUpdateQuery.md) | | |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
## upload_image_from_file
> Hash<String, Object> upload_image_from_file(file, opts)
Upload Image From File
Upload an image from a file. If you want to import an image from an existing url or a data uri, use the Upload Image From URL endpoint instead.
*Rate limits*:
Burst: `3/s`
Steady: `100/m`
Daily: `100/d` **Scopes:** `images:write`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::ImagesApi.new
file = File.new('/path/to/some/file') # File | The image file to upload. Supported image formats: jpeg,png,gif. Maximum image size: 5MB.
opts = {
name: 'name_example', # String | A name for the image. Defaults to the filename if not provided. If the name matches an existing image, a suffix will be added.
hidden: true # Boolean | If true, this image is not shown in the asset library.
}
begin
# Upload Image From File
result = api_instance.upload_image_from_file(file, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->upload_image_from_file: #{e}"
end
```
#### Using the upload_image_from_file_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> upload_image_from_file_with_http_info(file, opts)
```ruby
begin
# Upload Image From File
data, status_code, headers = api_instance.upload_image_from_file_with_http_info(file, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->upload_image_from_file_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **file** | **File** | The image file to upload. Supported image formats: jpeg,png,gif. Maximum image size: 5MB. | |
| **name** | **String** | A name for the image. Defaults to the filename if not provided. If the name matches an existing image, a suffix will be added. | [optional] |
| **hidden** | **Boolean** | If true, this image is not shown in the asset library. | [optional][default to false] |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
## upload_image_from_url
> Hash<String, Object> upload_image_from_url(image_create_query)
Upload Image From URL
Import an image from a url or data uri. If you want to upload an image from a file, use the Upload Image From File endpoint instead.
*Rate limits*:
Burst: `3/s`
Steady: `100/m`
Daily: `100/d` **Scopes:** `images:write`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::ImagesApi.new
image_create_query = KlaviyoAPI::ImageCreateQuery.new({data: KlaviyoAPI::ImageCreateQueryResourceObject.new({type: KlaviyoAPI::ImageEnum::IMAGE, attributes: KlaviyoAPI::ImageCreateQueryResourceObjectAttributes.new({import_from_url: 'https://www.example.com/example.jpg'})})}) # ImageCreateQuery |
begin
# Upload Image From URL
result = api_instance.upload_image_from_url(image_create_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->upload_image_from_url: #{e}"
end
```
#### Using the upload_image_from_url_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> upload_image_from_url_with_http_info(image_create_query)
```ruby
begin
# Upload Image From URL
data, status_code, headers = api_instance.upload_image_from_url_with_http_info(image_create_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling ImagesApi->upload_image_from_url_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **image_create_query** | [**ImageCreateQuery**](ImageCreateQuery.md) | | |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json