# KlaviyoAPI::CouponsApi
All URIs are relative to *https://a.klaviyo.com*
| Method | HTTP request | Description |
| ------ | ------------ | ----------- |
| [**create_coupon**](CouponsApi.md#create_coupon) | **POST** /api/coupons/ | Create Coupon |
| [**create_coupon_code**](CouponsApi.md#create_coupon_code) | **POST** /api/coupon-codes/ | Create Coupon Code |
| [**delete_coupon**](CouponsApi.md#delete_coupon) | **DELETE** /api/coupons/{id}/ | Delete Coupon |
| [**delete_coupon_code**](CouponsApi.md#delete_coupon_code) | **DELETE** /api/coupon-codes/{id}/ | Delete Coupon Code |
| [**get_coupon**](CouponsApi.md#get_coupon) | **GET** /api/coupons/{id}/ | Get Coupon |
| [**get_coupon_code**](CouponsApi.md#get_coupon_code) | **GET** /api/coupon-codes/{id}/ | Get Coupon Code |
| [**get_coupon_code_bulk_create_job**](CouponsApi.md#get_coupon_code_bulk_create_job) | **GET** /api/coupon-code-bulk-create-jobs/{job_id}/ | Get Coupon Code Bulk Create Job |
| [**get_coupon_code_bulk_create_jobs**](CouponsApi.md#get_coupon_code_bulk_create_jobs) | **GET** /api/coupon-code-bulk-create-jobs/ | Get Coupon Code Bulk Create Jobs |
| [**get_coupon_code_relationships_coupon**](CouponsApi.md#get_coupon_code_relationships_coupon) | **GET** /api/coupons/{id}/relationships/coupon-codes/ | Get Coupon Code Relationships Coupon |
| [**get_coupon_codes**](CouponsApi.md#get_coupon_codes) | **GET** /api/coupon-codes/ | Get Coupon Codes |
| [**get_coupon_codes_for_coupon**](CouponsApi.md#get_coupon_codes_for_coupon) | **GET** /api/coupons/{id}/coupon-codes/ | Get Coupon Codes For Coupon |
| [**get_coupon_for_coupon_code**](CouponsApi.md#get_coupon_for_coupon_code) | **GET** /api/coupon-codes/{id}/coupon/ | Get Coupon For Coupon Code |
| [**get_coupon_relationships_coupon_codes**](CouponsApi.md#get_coupon_relationships_coupon_codes) | **GET** /api/coupon-codes/{id}/relationships/coupon/ | Get Coupon Relationships Coupon Codes |
| [**get_coupons**](CouponsApi.md#get_coupons) | **GET** /api/coupons/ | Get Coupons |
| [**spawn_coupon_code_bulk_create_job**](CouponsApi.md#spawn_coupon_code_bulk_create_job) | **POST** /api/coupon-code-bulk-create-jobs/ | Spawn Coupon Code Bulk Create Job |
| [**update_coupon**](CouponsApi.md#update_coupon) | **PATCH** /api/coupons/{id}/ | Update Coupon |
| [**update_coupon_code**](CouponsApi.md#update_coupon_code) | **PATCH** /api/coupon-codes/{id}/ | Update Coupon Code |
## create_coupon
> Hash<String, Object> create_coupon(coupon_create_query)
Create Coupon
Creates a new coupon.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `coupons: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::CouponsApi.new
coupon_create_query = KlaviyoAPI::CouponCreateQuery.new({data: KlaviyoAPI::CouponCreateQueryResourceObject.new({type: KlaviyoAPI::CouponEnum::COUPON, attributes: KlaviyoAPI::CouponCreateQueryResourceObjectAttributes.new({external_id: '10OFF'})})}) # CouponCreateQuery |
begin
# Create Coupon
result = api_instance.create_coupon(coupon_create_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->create_coupon: #{e}"
end
```
#### Using the create_coupon_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> create_coupon_with_http_info(coupon_create_query)
```ruby
begin
# Create Coupon
data, status_code, headers = api_instance.create_coupon_with_http_info(coupon_create_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->create_coupon_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **coupon_create_query** | [**CouponCreateQuery**](CouponCreateQuery.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
## create_coupon_code
> Hash<String, Object> create_coupon_code(coupon_code_create_query)
Create Coupon Code
Synchronously creates a coupon code for the given coupon.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `coupon-codes: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::CouponsApi.new
coupon_code_create_query = KlaviyoAPI::CouponCodeCreateQuery.new({data: KlaviyoAPI::CouponCodeCreateQueryResourceObject.new({type: KlaviyoAPI::CouponCodeEnum::COUPON_CODE, attributes: KlaviyoAPI::CouponCodeCreateQueryResourceObjectAttributes.new({unique_code: 'ASD325FHK324UJDOI2M3JNES99'})})}) # CouponCodeCreateQuery |
begin
# Create Coupon Code
result = api_instance.create_coupon_code(coupon_code_create_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->create_coupon_code: #{e}"
end
```
#### Using the create_coupon_code_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> create_coupon_code_with_http_info(coupon_code_create_query)
```ruby
begin
# Create Coupon Code
data, status_code, headers = api_instance.create_coupon_code_with_http_info(coupon_code_create_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->create_coupon_code_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **coupon_code_create_query** | [**CouponCodeCreateQuery**](CouponCodeCreateQuery.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
## delete_coupon
> delete_coupon(id)
Delete Coupon
Delete the coupon with the given coupon ID.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `coupons: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::CouponsApi.new
id = '10OFF' # String | The internal id of a Coupon is equivalent to its external id stored within an integration.
begin
# Delete Coupon
api_instance.delete_coupon(id)
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->delete_coupon: #{e}"
end
```
#### Using the delete_coupon_with_http_info variant
This returns an Array which contains the response data (`nil` in this case), status code and headers.
> delete_coupon_with_http_info(id)
```ruby
begin
# Delete Coupon
data, status_code, headers = api_instance.delete_coupon_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => nil
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->delete_coupon_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The internal id of a Coupon is equivalent to its external id stored within an integration. | |
### Return type
nil (empty response body)
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## delete_coupon_code
> delete_coupon_code(id)
Delete Coupon Code
Deletes a coupon code specified by the given identifier synchronously. If a profile has been assigned to the coupon code, an exception will be raised
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `coupon-codes: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::CouponsApi.new
id = '10OFF-ASD325FHK324UJDOI2M3JNES99' # String | The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.
begin
# Delete Coupon Code
api_instance.delete_coupon_code(id)
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->delete_coupon_code: #{e}"
end
```
#### Using the delete_coupon_code_with_http_info variant
This returns an Array which contains the response data (`nil` in this case), status code and headers.
> delete_coupon_code_with_http_info(id)
```ruby
begin
# Delete Coupon Code
data, status_code, headers = api_instance.delete_coupon_code_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => nil
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->delete_coupon_code_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with. | |
### Return type
nil (empty response body)
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## get_coupon
> Hash<String, Object> get_coupon(id, opts)
Get Coupon
Get a specific coupon with the given coupon ID.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupons: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::CouponsApi.new
id = '10OFF' # String | The internal id of a Coupon is equivalent to its external id stored within an integration.
opts = {
fields_coupon: ['external_id'] # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Coupon
result = api_instance.get_coupon(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon: #{e}"
end
```
#### Using the get_coupon_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_with_http_info(id, opts)
```ruby
begin
# Get Coupon
data, status_code, headers = api_instance.get_coupon_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The internal id of a Coupon is equivalent to its external id stored within an integration. | |
| **fields_coupon** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-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_coupon_code
> Hash<String, Object> get_coupon_code(id, opts)
Get Coupon Code
Returns a Coupon Code specified by the given identifier.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `coupon-codes: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::CouponsApi.new
id = '10OFF-ASD325FHK324UJDOI2M3JNES99' # String | The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.
opts = {
fields_coupon_code: ['unique_code'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
fields_coupon: ['external_id'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
include: ['coupon'] # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#relationships
}
begin
# Get Coupon Code
result = api_instance.get_coupon_code(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code: #{e}"
end
```
#### Using the get_coupon_code_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_code_with_http_info(id, opts)
```ruby
begin
# Get Coupon Code
data, status_code, headers = api_instance.get_coupon_code_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with. | |
| **fields_coupon_code** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_coupon** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#relationships | [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_coupon_code_bulk_create_job
> Hash<String, Object> get_coupon_code_bulk_create_job(job_id, opts)
Get Coupon Code Bulk Create Job
Get a coupon code bulk create job with the given job ID.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupon-codes: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::CouponsApi.new
job_id = '01GSQPBF74KQ5YTDEPP41T1BZH' # String | ID of the job to retrieve.
opts = {
fields_coupon_code_bulk_create_job: ['status'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
fields_coupon_code: ['unique_code'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
include: ['coupon-codes'] # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#relationships
}
begin
# Get Coupon Code Bulk Create Job
result = api_instance.get_coupon_code_bulk_create_job(job_id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code_bulk_create_job: #{e}"
end
```
#### Using the get_coupon_code_bulk_create_job_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_code_bulk_create_job_with_http_info(job_id, opts)
```ruby
begin
# Get Coupon Code Bulk Create Job
data, status_code, headers = api_instance.get_coupon_code_bulk_create_job_with_http_info(job_id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code_bulk_create_job_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **job_id** | **String** | ID of the job to retrieve. | |
| **fields_coupon_code_bulk_create_job** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_coupon_code** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#relationships | [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_coupon_code_bulk_create_jobs
> Hash<String, Object> get_coupon_code_bulk_create_jobs(opts)
Get Coupon Code Bulk Create Jobs
Get all coupon code bulk create jobs. Returns a maximum of 100 jobs per request.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupon-codes: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::CouponsApi.new
opts = {
fields_coupon_code_bulk_create_job: ['status'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
filter: 'filter_example', # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#filtering
Allowed field(s)/operator(s):
`status`: `equals`
page_cursor: 'page_cursor_example' # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination
}
begin
# Get Coupon Code Bulk Create Jobs
result = api_instance.get_coupon_code_bulk_create_jobs(opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code_bulk_create_jobs: #{e}"
end
```
#### Using the get_coupon_code_bulk_create_jobs_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_code_bulk_create_jobs_with_http_info(opts)
```ruby
begin
# Get Coupon Code Bulk Create Jobs
data, status_code, headers = api_instance.get_coupon_code_bulk_create_jobs_with_http_info(opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code_bulk_create_jobs_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **fields_coupon_code_bulk_create_job** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **filter** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`status`: `equals` | [optional] |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination | [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_coupon_code_relationships_coupon
> Hash<String, Object> get_coupon_code_relationships_coupon(id, opts)
Get Coupon Code Relationships Coupon
Gets a list of coupon code relationships associated with the given coupon id
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupon-codes: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::CouponsApi.new
id = 'id_example' # String |
opts = {
page_cursor: 'page_cursor_example' # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination
}
begin
# Get Coupon Code Relationships Coupon
result = api_instance.get_coupon_code_relationships_coupon(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code_relationships_coupon: #{e}"
end
```
#### Using the get_coupon_code_relationships_coupon_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_code_relationships_coupon_with_http_info(id, opts)
```ruby
begin
# Get Coupon Code Relationships Coupon
data, status_code, headers = api_instance.get_coupon_code_relationships_coupon_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_code_relationships_coupon_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination | [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_coupon_codes
> Hash<String, Object> get_coupon_codes(opts)
Get Coupon Codes
Gets a list of coupon codes associated with a coupon/coupons or a profile/profiles. A coupon/coupons or a profile/profiles must be provided as required filter params.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `coupon-codes: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::CouponsApi.new
opts = {
fields_coupon_code: ['unique_code'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
fields_coupon: ['external_id'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
filter: 'filter_example', # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#filtering
Allowed field(s)/operator(s):
`expires_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
`status`: `equals`
`coupon.id`: `any`, `equals`
`profile.id`: `any`, `equals`
include: ['coupon'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#relationships
page_cursor: 'page_cursor_example' # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination
}
begin
# Get Coupon Codes
result = api_instance.get_coupon_codes(opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_codes: #{e}"
end
```
#### Using the get_coupon_codes_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_codes_with_http_info(opts)
```ruby
begin
# Get Coupon Codes
data, status_code, headers = api_instance.get_coupon_codes_with_http_info(opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_codes_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **fields_coupon_code** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_coupon** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **filter** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`expires_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`status`: `equals`<br>`coupon.id`: `any`, `equals`<br>`profile.id`: `any`, `equals` | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#relationships | [optional] |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination | [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_coupon_codes_for_coupon
> Hash<String, Object> get_coupon_codes_for_coupon(id, opts)
Get Coupon Codes For Coupon
Gets a list of coupon codes associated with the given coupon id
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupon-codes: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::CouponsApi.new
id = 'id_example' # String |
opts = {
fields_coupon_code: ['unique_code'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
filter: 'filter_example', # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#filtering
Allowed field(s)/operator(s):
`expires_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
`status`: `equals`
`coupon.id`: `any`, `equals`
`profile.id`: `any`, `equals`
page_cursor: 'page_cursor_example' # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination
}
begin
# Get Coupon Codes For Coupon
result = api_instance.get_coupon_codes_for_coupon(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_codes_for_coupon: #{e}"
end
```
#### Using the get_coupon_codes_for_coupon_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_codes_for_coupon_with_http_info(id, opts)
```ruby
begin
# Get Coupon Codes For Coupon
data, status_code, headers = api_instance.get_coupon_codes_for_coupon_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_codes_for_coupon_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **fields_coupon_code** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **filter** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`expires_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`status`: `equals`<br>`coupon.id`: `any`, `equals`<br>`profile.id`: `any`, `equals` | [optional] |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination | [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_coupon_for_coupon_code
> Hash<String, Object> get_coupon_for_coupon_code(id, opts)
Get Coupon For Coupon Code
Get the coupon associated with a given coupon code ID.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupons: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::CouponsApi.new
id = 'id_example' # String |
opts = {
fields_coupon: ['external_id'] # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Coupon For Coupon Code
result = api_instance.get_coupon_for_coupon_code(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_for_coupon_code: #{e}"
end
```
#### Using the get_coupon_for_coupon_code_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_for_coupon_code_with_http_info(id, opts)
```ruby
begin
# Get Coupon For Coupon Code
data, status_code, headers = api_instance.get_coupon_for_coupon_code_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_for_coupon_code_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **fields_coupon** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-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_coupon_relationships_coupon_codes
> Hash<String, Object> get_coupon_relationships_coupon_codes(id)
Get Coupon Relationships Coupon Codes
Gets the coupon relationship associated with the given coupon code id
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupons: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::CouponsApi.new
id = 'id_example' # String |
begin
# Get Coupon Relationships Coupon Codes
result = api_instance.get_coupon_relationships_coupon_codes(id)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_relationships_coupon_codes: #{e}"
end
```
#### Using the get_coupon_relationships_coupon_codes_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupon_relationships_coupon_codes_with_http_info(id)
```ruby
begin
# Get Coupon Relationships Coupon Codes
data, status_code, headers = api_instance.get_coupon_relationships_coupon_codes_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupon_relationships_coupon_codes_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
### 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_coupons
> Hash<String, Object> get_coupons(opts)
Get Coupons
Get all coupons in an account. To learn more, see our [Coupons API guide](https://developers.klaviyo.com/en/docs/use_klaviyos_coupons_api).
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupons: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::CouponsApi.new
opts = {
fields_coupon: ['external_id'], # Array | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets
page_cursor: 'page_cursor_example' # String | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination
}
begin
# Get Coupons
result = api_instance.get_coupons(opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupons: #{e}"
end
```
#### Using the get_coupons_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_coupons_with_http_info(opts)
```ruby
begin
# Get Coupons
data, status_code, headers = api_instance.get_coupons_with_http_info(opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->get_coupons_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **fields_coupon** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#sparse-fieldsets | [optional] |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2024-07-15/reference/api-overview#pagination | [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
## spawn_coupon_code_bulk_create_job
> Hash<String, Object> spawn_coupon_code_bulk_create_job(coupon_code_create_job_create_query)
Spawn Coupon Code Bulk Create Job
Create a coupon-code-bulk-create-job to bulk create a list of coupon codes. Max number of jobs queued at once we allow for is 100.
*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `coupon-codes: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::CouponsApi.new
coupon_code_create_job_create_query = KlaviyoAPI::CouponCodeCreateJobCreateQuery.new({data: KlaviyoAPI::CouponCodeCreateJobCreateQueryResourceObject.new({type: KlaviyoAPI::CouponCodeBulkCreateJobEnum::COUPON_CODE_BULK_CREATE_JOB, attributes: KlaviyoAPI::CouponCodeCreateJobCreateQueryResourceObjectAttributes.new({coupon_codes: KlaviyoAPI::CouponCodeCreateJobCreateQueryResourceObjectAttributesCouponCodes.new({data: [KlaviyoAPI::CouponCodeCreateQueryResourceObject.new({type: KlaviyoAPI::CouponCodeEnum::COUPON_CODE, attributes: KlaviyoAPI::CouponCodeCreateQueryResourceObjectAttributes.new({unique_code: 'ASD325FHK324UJDOI2M3JNES99'})})]})})})}) # CouponCodeCreateJobCreateQuery |
begin
# Spawn Coupon Code Bulk Create Job
result = api_instance.spawn_coupon_code_bulk_create_job(coupon_code_create_job_create_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->spawn_coupon_code_bulk_create_job: #{e}"
end
```
#### Using the spawn_coupon_code_bulk_create_job_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> spawn_coupon_code_bulk_create_job_with_http_info(coupon_code_create_job_create_query)
```ruby
begin
# Spawn Coupon Code Bulk Create Job
data, status_code, headers = api_instance.spawn_coupon_code_bulk_create_job_with_http_info(coupon_code_create_job_create_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->spawn_coupon_code_bulk_create_job_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **coupon_code_create_job_create_query** | [**CouponCodeCreateJobCreateQuery**](CouponCodeCreateJobCreateQuery.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
## update_coupon
> Hash<String, Object> update_coupon(id, coupon_update_query)
Update Coupon
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `coupons: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::CouponsApi.new
id = '10OFF' # String | The internal id of a Coupon is equivalent to its external id stored within an integration.
coupon_update_query = KlaviyoAPI::CouponUpdateQuery.new({data: KlaviyoAPI::CouponUpdateQueryResourceObject.new({type: KlaviyoAPI::CouponEnum::COUPON, id: '10OFF', attributes: KlaviyoAPI::CouponUpdateQueryResourceObjectAttributes.new})}) # CouponUpdateQuery |
begin
# Update Coupon
result = api_instance.update_coupon(id, coupon_update_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->update_coupon: #{e}"
end
```
#### Using the update_coupon_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> update_coupon_with_http_info(id, coupon_update_query)
```ruby
begin
# Update Coupon
data, status_code, headers = api_instance.update_coupon_with_http_info(id, coupon_update_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->update_coupon_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The internal id of a Coupon is equivalent to its external id stored within an integration. | |
| **coupon_update_query** | [**CouponUpdateQuery**](CouponUpdateQuery.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
## update_coupon_code
> Hash<String, Object> update_coupon_code(id, coupon_code_update_query)
Update Coupon Code
Updates a coupon code specified by the given identifier synchronously. We allow updating the 'status' and 'expires_at' of coupon codes.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `coupon-codes: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::CouponsApi.new
id = '10OFF-ASD325FHK324UJDOI2M3JNES99' # String | The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.
coupon_code_update_query = KlaviyoAPI::CouponCodeUpdateQuery.new({data: KlaviyoAPI::CouponCodeUpdateQueryResourceObject.new({type: KlaviyoAPI::CouponCodeEnum::COUPON_CODE, id: '10OFF-ASD325FHK324UJDOI2M3JNES99', attributes: KlaviyoAPI::CouponCodeUpdateQueryResourceObjectAttributes.new})}) # CouponCodeUpdateQuery |
begin
# Update Coupon Code
result = api_instance.update_coupon_code(id, coupon_code_update_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->update_coupon_code: #{e}"
end
```
#### Using the update_coupon_code_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> update_coupon_code_with_http_info(id, coupon_code_update_query)
```ruby
begin
# Update Coupon Code
data, status_code, headers = api_instance.update_coupon_code_with_http_info(id, coupon_code_update_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CouponsApi->update_coupon_code_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with. | |
| **coupon_code_update_query** | [**CouponCodeUpdateQuery**](CouponCodeUpdateQuery.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