# KlaviyoAPI::CampaignsApi
All URIs are relative to *https://a.klaviyo.com*
| Method | HTTP request | Description |
| ------ | ------------ | ----------- |
| [**create_campaign**](CampaignsApi.md#create_campaign) | **POST** /api/campaigns/ | Create Campaign |
| [**create_campaign_clone**](CampaignsApi.md#create_campaign_clone) | **POST** /api/campaign-clone/ | Create Campaign Clone |
| [**create_campaign_message_assign_template**](CampaignsApi.md#create_campaign_message_assign_template) | **POST** /api/campaign-message-assign-template/ | Assign Campaign Message Template |
| [**create_campaign_recipient_estimation_job**](CampaignsApi.md#create_campaign_recipient_estimation_job) | **POST** /api/campaign-recipient-estimation-jobs/ | Create Campaign Recipient Estimation Job |
| [**create_campaign_send_job**](CampaignsApi.md#create_campaign_send_job) | **POST** /api/campaign-send-jobs/ | Create Campaign Send Job |
| [**delete_campaign**](CampaignsApi.md#delete_campaign) | **DELETE** /api/campaigns/{id}/ | Delete Campaign |
| [**get_campaign**](CampaignsApi.md#get_campaign) | **GET** /api/campaigns/{id}/ | Get Campaign |
| [**get_campaign_campaign_messages**](CampaignsApi.md#get_campaign_campaign_messages) | **GET** /api/campaigns/{id}/campaign-messages/ | Get Campaign Campaign Messages |
| [**get_campaign_message**](CampaignsApi.md#get_campaign_message) | **GET** /api/campaign-messages/{id}/ | Get Campaign Message |
| [**get_campaign_message_campaign**](CampaignsApi.md#get_campaign_message_campaign) | **GET** /api/campaign-messages/{id}/campaign/ | Get Campaign Message Campaign |
| [**get_campaign_message_relationships_campaign**](CampaignsApi.md#get_campaign_message_relationships_campaign) | **GET** /api/campaign-messages/{id}/relationships/campaign/ | Get Campaign Message Relationships Campaign |
| [**get_campaign_message_relationships_template**](CampaignsApi.md#get_campaign_message_relationships_template) | **GET** /api/campaign-messages/{id}/relationships/template/ | Get Campaign Message Relationships Template |
| [**get_campaign_message_template**](CampaignsApi.md#get_campaign_message_template) | **GET** /api/campaign-messages/{id}/template/ | Get Campaign Message Template |
| [**get_campaign_recipient_estimation**](CampaignsApi.md#get_campaign_recipient_estimation) | **GET** /api/campaign-recipient-estimations/{id}/ | Get Campaign Recipient Estimation |
| [**get_campaign_recipient_estimation_job**](CampaignsApi.md#get_campaign_recipient_estimation_job) | **GET** /api/campaign-recipient-estimation-jobs/{id}/ | Get Campaign Recipient Estimation Job |
| [**get_campaign_relationships_campaign_messages**](CampaignsApi.md#get_campaign_relationships_campaign_messages) | **GET** /api/campaigns/{id}/relationships/campaign-messages/ | Get Campaign Relationships Campaign Messages |
| [**get_campaign_relationships_tags**](CampaignsApi.md#get_campaign_relationships_tags) | **GET** /api/campaigns/{id}/relationships/tags/ | Get Campaign Relationships Tags |
| [**get_campaign_send_job**](CampaignsApi.md#get_campaign_send_job) | **GET** /api/campaign-send-jobs/{id}/ | Get Campaign Send Job |
| [**get_campaign_tags**](CampaignsApi.md#get_campaign_tags) | **GET** /api/campaigns/{id}/tags/ | Get Campaign Tags |
| [**get_campaigns**](CampaignsApi.md#get_campaigns) | **GET** /api/campaigns/ | Get Campaigns |
| [**update_campaign**](CampaignsApi.md#update_campaign) | **PATCH** /api/campaigns/{id}/ | Update Campaign |
| [**update_campaign_message**](CampaignsApi.md#update_campaign_message) | **PATCH** /api/campaign-messages/{id}/ | Update Campaign Message |
| [**update_campaign_send_job**](CampaignsApi.md#update_campaign_send_job) | **PATCH** /api/campaign-send-jobs/{id}/ | Update Campaign Send Job |
## create_campaign
> Hash<String, Object> create_campaign(campaign_create_query)
Create Campaign
Creates a campaign given a set of parameters, then returns it.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
campaign_create_query = KlaviyoAPI::CampaignCreateQuery.new({data: KlaviyoAPI::CampaignCreateQueryResourceObject.new({type: KlaviyoAPI::CampaignEnum::CAMPAIGN, attributes: KlaviyoAPI::CampaignCreateQueryResourceObjectAttributes.new({name: 'My new campaign', audiences: KlaviyoAPI::AudiencesSubObject.new, campaign_messages: KlaviyoAPI::CampaignCreateQueryResourceObjectAttributesCampaignMessages.new({data: [KlaviyoAPI::CampaignMessageCreateQueryResourceObject.new({type: KlaviyoAPI::CampaignMessageEnum::CAMPAIGN_MESSAGE, attributes: KlaviyoAPI::CampaignMessageCreateQueryResourceObjectAttributes.new({channel: 'email'})})]})})})}) # CampaignCreateQuery | Creates a campaign from parameters
begin
# Create Campaign
result = api_instance.create_campaign(campaign_create_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign: #{e}"
end
```
#### Using the create_campaign_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> create_campaign_with_http_info(campaign_create_query)
```ruby
begin
# Create Campaign
data, status_code, headers = api_instance.create_campaign_with_http_info(campaign_create_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **campaign_create_query** | [**CampaignCreateQuery**](CampaignCreateQuery.md) | Creates a campaign from parameters | |
### 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_campaign_clone
> Hash<String, Object> create_campaign_clone(campaign_clone_query)
Create Campaign Clone
Clones an existing campaign, returning a new campaign based on the original with a new ID and name.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
campaign_clone_query = KlaviyoAPI::CampaignCloneQuery.new({data: KlaviyoAPI::CampaignCloneQueryResourceObject.new({type: KlaviyoAPI::CampaignEnum::CAMPAIGN, id: 'id_example', attributes: KlaviyoAPI::CampaignCloneQueryResourceObjectAttributes.new})}) # CampaignCloneQuery | Clones a campaign from an existing campaign
begin
# Create Campaign Clone
result = api_instance.create_campaign_clone(campaign_clone_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_clone: #{e}"
end
```
#### Using the create_campaign_clone_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> create_campaign_clone_with_http_info(campaign_clone_query)
```ruby
begin
# Create Campaign Clone
data, status_code, headers = api_instance.create_campaign_clone_with_http_info(campaign_clone_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_clone_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **campaign_clone_query** | [**CampaignCloneQuery**](CampaignCloneQuery.md) | Clones a campaign from an existing campaign | |
### 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_campaign_message_assign_template
> Hash<String, Object> create_campaign_message_assign_template(campaign_message_assign_template_query)
Assign Campaign Message Template
Creates a non-reusable version of the template and assigns it to the message.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
campaign_message_assign_template_query = KlaviyoAPI::CampaignMessageAssignTemplateQuery.new({data: KlaviyoAPI::CampaignMessageAssignTemplateQueryResourceObject.new({type: KlaviyoAPI::CampaignMessageEnum::CAMPAIGN_MESSAGE, id: 'id_example', relationships: KlaviyoAPI::CampaignMessageAssignTemplateQueryResourceObjectRelationships.new({template: KlaviyoAPI::CampaignMessageAssignTemplateQueryResourceObjectRelationshipsTemplate.new({data: KlaviyoAPI::CampaignMessageAssignTemplateQueryResourceObjectRelationshipsTemplateData.new({type: KlaviyoAPI::TemplateEnum::TEMPLATE, id: 'RipRmi'})})})})}) # CampaignMessageAssignTemplateQuery | Takes a reusable template, clones it, and assigns the non-reusable clone to the message.
begin
# Assign Campaign Message Template
result = api_instance.create_campaign_message_assign_template(campaign_message_assign_template_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_message_assign_template: #{e}"
end
```
#### Using the create_campaign_message_assign_template_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> create_campaign_message_assign_template_with_http_info(campaign_message_assign_template_query)
```ruby
begin
# Assign Campaign Message Template
data, status_code, headers = api_instance.create_campaign_message_assign_template_with_http_info(campaign_message_assign_template_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_message_assign_template_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **campaign_message_assign_template_query** | [**CampaignMessageAssignTemplateQuery**](CampaignMessageAssignTemplateQuery.md) | Takes a reusable template, clones it, and assigns the non-reusable clone to the message. | |
### 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_campaign_recipient_estimation_job
> Hash<String, Object> create_campaign_recipient_estimation_job(campaign_recipient_estimation_job_create_query)
Create Campaign Recipient Estimation Job
Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the `Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
campaign_recipient_estimation_job_create_query = KlaviyoAPI::CampaignRecipientEstimationJobCreateQuery.new({data: KlaviyoAPI::CampaignRecipientEstimationJobCreateQueryResourceObject.new({type: KlaviyoAPI::CampaignRecipientEstimationJobEnum::CAMPAIGN_RECIPIENT_ESTIMATION_JOB, id: 'id_example'})}) # CampaignRecipientEstimationJobCreateQuery | Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the `Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign.
begin
# Create Campaign Recipient Estimation Job
result = api_instance.create_campaign_recipient_estimation_job(campaign_recipient_estimation_job_create_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_recipient_estimation_job: #{e}"
end
```
#### Using the create_campaign_recipient_estimation_job_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> create_campaign_recipient_estimation_job_with_http_info(campaign_recipient_estimation_job_create_query)
```ruby
begin
# Create Campaign Recipient Estimation Job
data, status_code, headers = api_instance.create_campaign_recipient_estimation_job_with_http_info(campaign_recipient_estimation_job_create_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_recipient_estimation_job_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **campaign_recipient_estimation_job_create_query** | [**CampaignRecipientEstimationJobCreateQuery**](CampaignRecipientEstimationJobCreateQuery.md) | Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the `Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign. | |
### 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_campaign_send_job
> Hash<String, Object> create_campaign_send_job(campaign_send_job_create_query)
Create Campaign Send Job
Trigger a campaign to send asynchronously
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
campaign_send_job_create_query = KlaviyoAPI::CampaignSendJobCreateQuery.new({data: KlaviyoAPI::CampaignSendJobCreateQueryResourceObject.new({type: KlaviyoAPI::CampaignSendJobEnum::CAMPAIGN_SEND_JOB, id: 'id_example'})}) # CampaignSendJobCreateQuery | Trigger the campaign to send asynchronously
begin
# Create Campaign Send Job
result = api_instance.create_campaign_send_job(campaign_send_job_create_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_send_job: #{e}"
end
```
#### Using the create_campaign_send_job_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> create_campaign_send_job_with_http_info(campaign_send_job_create_query)
```ruby
begin
# Create Campaign Send Job
data, status_code, headers = api_instance.create_campaign_send_job_with_http_info(campaign_send_job_create_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->create_campaign_send_job_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **campaign_send_job_create_query** | [**CampaignSendJobCreateQuery**](CampaignSendJobCreateQuery.md) | Trigger the campaign to send asynchronously | |
### 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_campaign
> delete_campaign(id)
Delete Campaign
Delete a campaign with the given campaign ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The campaign ID to be deleted
begin
# Delete Campaign
api_instance.delete_campaign(id)
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->delete_campaign: #{e}"
end
```
#### Using the delete_campaign_with_http_info variant
This returns an Array which contains the response data (`nil` in this case), status code and headers.
> delete_campaign_with_http_info(id)
```ruby
begin
# Delete Campaign
data, status_code, headers = api_instance.delete_campaign_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => nil
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->delete_campaign_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The campaign ID to be deleted | |
### 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_campaign
> Hash<String, Object> get_campaign(id, opts)
Get Campaign
Returns a specific campaign based on a required id.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The campaign ID to be retrieved
opts = {
fields_campaign_message: ['label'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_campaign: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_tag: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
include: ['campaign-messages'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#relationships
}
begin
# Get Campaign
result = api_instance.get_campaign(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign: #{e}"
end
```
#### Using the get_campaign_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_with_http_info(id, opts)
```ruby
begin
# Get Campaign
data, status_code, headers = api_instance.get_campaign_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The campaign ID to be retrieved | |
| **fields_campaign_message** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_campaign** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_tag** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-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_campaign_campaign_messages
> Hash<String, Object> get_campaign_campaign_messages(id, opts)
Get Campaign Campaign Messages
Return all messages that belong to the given campaign.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String |
opts = {
fields_campaign_message: ['label'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_campaign: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_template: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
include: ['campaign'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#relationships
}
begin
# Get Campaign Campaign Messages
result = api_instance.get_campaign_campaign_messages(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_campaign_messages: #{e}"
end
```
#### Using the get_campaign_campaign_messages_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_campaign_messages_with_http_info(id, opts)
```ruby
begin
# Get Campaign Campaign Messages
data, status_code, headers = api_instance.get_campaign_campaign_messages_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_campaign_messages_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **fields_campaign_message** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_campaign** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_template** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-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_campaign_message
> Hash<String, Object> get_campaign_message(id, opts)
Get Campaign Message
Returns a specific message based on a required id.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The message ID to be retrieved
opts = {
fields_campaign_message: ['label'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_campaign: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_template: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
include: ['campaign'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#relationships
}
begin
# Get Campaign Message
result = api_instance.get_campaign_message(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message: #{e}"
end
```
#### Using the get_campaign_message_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_message_with_http_info(id, opts)
```ruby
begin
# Get Campaign Message
data, status_code, headers = api_instance.get_campaign_message_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The message ID to be retrieved | |
| **fields_campaign_message** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_campaign** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_template** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-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_campaign_message_campaign
> Hash<String, Object> get_campaign_message_campaign(id, opts)
Get Campaign Message Campaign
Return the related campaign
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String |
opts = {
fields_campaign_message: ['label'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Campaign Message Campaign
result = api_instance.get_campaign_message_campaign(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_campaign: #{e}"
end
```
#### Using the get_campaign_message_campaign_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_message_campaign_with_http_info(id, opts)
```ruby
begin
# Get Campaign Message Campaign
data, status_code, headers = api_instance.get_campaign_message_campaign_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_campaign_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **fields_campaign_message** | [**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_campaign_message_relationships_campaign
> Hash<String, Object> get_campaign_message_relationships_campaign(id)
Get Campaign Message Relationships Campaign
Returns the ID of the related campaign
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String |
begin
# Get Campaign Message Relationships Campaign
result = api_instance.get_campaign_message_relationships_campaign(id)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_relationships_campaign: #{e}"
end
```
#### Using the get_campaign_message_relationships_campaign_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_message_relationships_campaign_with_http_info(id)
```ruby
begin
# Get Campaign Message Relationships Campaign
data, status_code, headers = api_instance.get_campaign_message_relationships_campaign_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_relationships_campaign_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_campaign_message_relationships_template
> Hash<String, Object> get_campaign_message_relationships_template(id)
Get Campaign Message Relationships Template
Returns the ID of the related template
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `templates: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::CampaignsApi.new
id = 'id_example' # String |
begin
# Get Campaign Message Relationships Template
result = api_instance.get_campaign_message_relationships_template(id)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_relationships_template: #{e}"
end
```
#### Using the get_campaign_message_relationships_template_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_message_relationships_template_with_http_info(id)
```ruby
begin
# Get Campaign Message Relationships Template
data, status_code, headers = api_instance.get_campaign_message_relationships_template_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_relationships_template_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_campaign_message_template
> Hash<String, Object> get_campaign_message_template(id, opts)
Get Campaign Message Template
Return the related template
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `templates: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::CampaignsApi.new
id = 'id_example' # String |
opts = {
fields_template: ['name'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Campaign Message Template
result = api_instance.get_campaign_message_template(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_template: #{e}"
end
```
#### Using the get_campaign_message_template_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_message_template_with_http_info(id, opts)
```ruby
begin
# Get Campaign Message Template
data, status_code, headers = api_instance.get_campaign_message_template_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_message_template_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **fields_template** | [**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_campaign_recipient_estimation
> Hash<String, Object> get_campaign_recipient_estimation(id, opts)
Get Campaign Recipient Estimation
Get the estimated recipient count for a campaign with the provided campaign ID. You can refresh this count by using the `Create Campaign Recipient Estimation Job` endpoint.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The ID of the campaign for which to get the estimated number of recipients
opts = {
fields_campaign_recipient_estimation: ['estimated_recipient_count'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Campaign Recipient Estimation
result = api_instance.get_campaign_recipient_estimation(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_recipient_estimation: #{e}"
end
```
#### Using the get_campaign_recipient_estimation_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_recipient_estimation_with_http_info(id, opts)
```ruby
begin
# Get Campaign Recipient Estimation
data, status_code, headers = api_instance.get_campaign_recipient_estimation_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_recipient_estimation_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The ID of the campaign for which to get the estimated number of recipients | |
| **fields_campaign_recipient_estimation** | [**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_campaign_recipient_estimation_job
> Hash<String, Object> get_campaign_recipient_estimation_job(id, opts)
Get Campaign Recipient Estimation Job
Retrieve the status of a recipient estimation job triggered with the `Create Campaign Recipient Estimation Job` endpoint.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The ID of the campaign to get recipient estimation status
opts = {
fields_campaign_recipient_estimation_job: ['status'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Campaign Recipient Estimation Job
result = api_instance.get_campaign_recipient_estimation_job(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_recipient_estimation_job: #{e}"
end
```
#### Using the get_campaign_recipient_estimation_job_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_recipient_estimation_job_with_http_info(id, opts)
```ruby
begin
# Get Campaign Recipient Estimation Job
data, status_code, headers = api_instance.get_campaign_recipient_estimation_job_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_recipient_estimation_job_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The ID of the campaign to get recipient estimation status | |
| **fields_campaign_recipient_estimation_job** | [**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_campaign_relationships_campaign_messages
> Hash<String, Object> get_campaign_relationships_campaign_messages(id)
Get Campaign Relationships Campaign Messages
Returns the IDs of all messages associated with the given campaign.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String |
begin
# Get Campaign Relationships Campaign Messages
result = api_instance.get_campaign_relationships_campaign_messages(id)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_relationships_campaign_messages: #{e}"
end
```
#### Using the get_campaign_relationships_campaign_messages_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_relationships_campaign_messages_with_http_info(id)
```ruby
begin
# Get Campaign Relationships Campaign Messages
data, status_code, headers = api_instance.get_campaign_relationships_campaign_messages_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_relationships_campaign_messages_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_campaign_relationships_tags
> Hash<String, Object> get_campaign_relationships_tags(id)
Get Campaign Relationships Tags
Returns the IDs of all tags associated with the given campaign.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:read` `tags: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::CampaignsApi.new
id = 'id_example' # String |
begin
# Get Campaign Relationships Tags
result = api_instance.get_campaign_relationships_tags(id)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_relationships_tags: #{e}"
end
```
#### Using the get_campaign_relationships_tags_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_relationships_tags_with_http_info(id)
```ruby
begin
# Get Campaign Relationships Tags
data, status_code, headers = api_instance.get_campaign_relationships_tags_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_relationships_tags_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_campaign_send_job
> Hash<String, Object> get_campaign_send_job(id, opts)
Get Campaign Send Job
Get a campaign send job
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The ID of the campaign to send
opts = {
fields_campaign_send_job: ['status'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Campaign Send Job
result = api_instance.get_campaign_send_job(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_send_job: #{e}"
end
```
#### Using the get_campaign_send_job_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_send_job_with_http_info(id, opts)
```ruby
begin
# Get Campaign Send Job
data, status_code, headers = api_instance.get_campaign_send_job_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_send_job_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The ID of the campaign to send | |
| **fields_campaign_send_job** | [**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_campaign_tags
> Hash<String, Object> get_campaign_tags(id, opts)
Get Campaign Tags
Return all tags that belong to the given campaign.
*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:read` `tags: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::CampaignsApi.new
id = 'id_example' # String |
opts = {
fields_tag: ['name'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Campaign Tags
result = api_instance.get_campaign_tags(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_tags: #{e}"
end
```
#### Using the get_campaign_tags_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaign_tags_with_http_info(id, opts)
```ruby
begin
# Get Campaign Tags
data, status_code, headers = api_instance.get_campaign_tags_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaign_tags_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **fields_tag** | [**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_campaigns
> Hash<String, Object> get_campaigns(filter, opts)
Get Campaigns
Returns some or all campaigns based on filters. A channel filter is required to list campaigns. Please provide either: `?filter=equals(messages.channel,'email')` to list email campaigns, or `?filter=equals(messages.channel,'sms')` to list SMS campaigns.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
filter = 'equals(messages.channel,'sms')' # String | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#filtering
Allowed field(s)/operator(s):
`messages.channel`: `equals`
`name`: `contains`
`status`: `any`, `equals`
`archived`: `equals`
`created_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
`scheduled_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
`updated_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
opts = {
fields_campaign_message: ['label'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_campaign: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
fields_tag: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets
include: ['campaign-messages'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#relationships
page_cursor: 'page_cursor_example', # String | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#pagination
sort: 'created_at' # String | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sorting
}
begin
# Get Campaigns
result = api_instance.get_campaigns(filter, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaigns: #{e}"
end
```
#### Using the get_campaigns_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_campaigns_with_http_info(filter, opts)
```ruby
begin
# Get Campaigns
data, status_code, headers = api_instance.get_campaigns_with_http_info(filter, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->get_campaigns_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **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>`messages.channel`: `equals`<br>`name`: `contains`<br>`status`: `any`, `equals`<br>`archived`: `equals`<br>`created_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`scheduled_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` | |
| **fields_campaign_message** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_campaign** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_tag** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#sparse-fieldsets | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#relationships | [optional] |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-12-15/reference/api-overview#pagination | [optional] |
| **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_campaign
> Hash<String, Object> update_campaign(id, campaign_partial_update_query)
Update Campaign
Update a campaign with the given campaign ID.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The campaign ID to be retrieved
campaign_partial_update_query = KlaviyoAPI::CampaignPartialUpdateQuery.new({data: KlaviyoAPI::CampaignPartialUpdateQueryResourceObject.new({type: KlaviyoAPI::CampaignEnum::CAMPAIGN, id: 'id_example', attributes: KlaviyoAPI::CampaignPartialUpdateQueryResourceObjectAttributes.new})}) # CampaignPartialUpdateQuery | Update a campaign and return it
begin
# Update Campaign
result = api_instance.update_campaign(id, campaign_partial_update_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->update_campaign: #{e}"
end
```
#### Using the update_campaign_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> update_campaign_with_http_info(id, campaign_partial_update_query)
```ruby
begin
# Update Campaign
data, status_code, headers = api_instance.update_campaign_with_http_info(id, campaign_partial_update_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->update_campaign_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The campaign ID to be retrieved | |
| **campaign_partial_update_query** | [**CampaignPartialUpdateQuery**](CampaignPartialUpdateQuery.md) | Update a campaign and return it | |
### 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_campaign_message
> Hash<String, Object> update_campaign_message(id, campaign_message_partial_update_query)
Update Campaign Message
Update a campaign message
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The message ID to be retrieved
campaign_message_partial_update_query = KlaviyoAPI::CampaignMessagePartialUpdateQuery.new({data: KlaviyoAPI::CampaignMessagePartialUpdateQueryResourceObject.new({type: KlaviyoAPI::CampaignMessageEnum::CAMPAIGN_MESSAGE, id: 'id_example', attributes: KlaviyoAPI::CampaignMessagePartialUpdateQueryResourceObjectAttributes.new})}) # CampaignMessagePartialUpdateQuery | Update a message and return it
begin
# Update Campaign Message
result = api_instance.update_campaign_message(id, campaign_message_partial_update_query)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->update_campaign_message: #{e}"
end
```
#### Using the update_campaign_message_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> update_campaign_message_with_http_info(id, campaign_message_partial_update_query)
```ruby
begin
# Update Campaign Message
data, status_code, headers = api_instance.update_campaign_message_with_http_info(id, campaign_message_partial_update_query)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->update_campaign_message_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The message ID to be retrieved | |
| **campaign_message_partial_update_query** | [**CampaignMessagePartialUpdateQuery**](CampaignMessagePartialUpdateQuery.md) | Update a message and return it | |
### 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_campaign_send_job
> update_campaign_send_job(id, campaign_send_job_partial_update_query)
Update Campaign Send Job
Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns: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::CampaignsApi.new
id = 'id_example' # String | The ID of the currently sending campaign to cancel or revert
campaign_send_job_partial_update_query = KlaviyoAPI::CampaignSendJobPartialUpdateQuery.new({data: KlaviyoAPI::CampaignSendJobPartialUpdateQueryResourceObject.new({type: KlaviyoAPI::CampaignSendJobEnum::CAMPAIGN_SEND_JOB, id: 'id_example', attributes: KlaviyoAPI::CampaignSendJobPartialUpdateQueryResourceObjectAttributes.new({action: 'cancel'})})}) # CampaignSendJobPartialUpdateQuery | Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT
begin
# Update Campaign Send Job
api_instance.update_campaign_send_job(id, campaign_send_job_partial_update_query)
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->update_campaign_send_job: #{e}"
end
```
#### Using the update_campaign_send_job_with_http_info variant
This returns an Array which contains the response data (`nil` in this case), status code and headers.
> update_campaign_send_job_with_http_info(id, campaign_send_job_partial_update_query)
```ruby
begin
# Update Campaign Send Job
data, status_code, headers = api_instance.update_campaign_send_job_with_http_info(id, campaign_send_job_partial_update_query)
p status_code # => 2xx
p headers # => { ... }
p data # => nil
rescue KlaviyoAPI::ApiError => e
puts "Error when calling CampaignsApi->update_campaign_send_job_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | The ID of the currently sending campaign to cancel or revert | |
| **campaign_send_job_partial_update_query** | [**CampaignSendJobPartialUpdateQuery**](CampaignSendJobPartialUpdateQuery.md) | Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT | |
### Return type
nil (empty response body)
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json