# 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/ | Create Campaign Message Assign 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_message**](CampaignsApi.md#get_campaign_message) | **GET** /api/campaign-messages/{id}/ | Get Campaign Message | | [**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**](CampaignsApi.md#get_campaign_relationships) | **GET** /api/campaigns/{id}/relationships/{related_resource}/ | Get Campaign Relationships | | [**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/{campaign_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::CampaignCreateQueryAsSubResource.new({type: 'campaign', attributes: KlaviyoAPI::CampaignCreateQueryAsSubResourceAttributes.new({name: 'My new campaign', channel: 'email', audiences: KlaviyoAPI::AudiencesSubObject.new, send_strategy: KlaviyoAPI::SendStrategySubObject.new({method: 'static'}), send_options: KlaviyoAPI::SendOptionsSubObject.new})})}) # 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::CampaignCloneQueryAsSubResource.new({type: 'campaign', attributes: KlaviyoAPI::CampaignCloneQueryAsSubResourceAttributes.new({id: 'id_example'})})}) # 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) Create Campaign Message Assign 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::CampaignMessageAssignTemplateQueryAsSubResource.new({type: 'campaign-message', attributes: KlaviyoAPI::CampaignMessageAssignTemplateQueryAsSubResourceAttributes.new({id: 'id_example', template_id: 'RipRmi'})})}) # CampaignMessageAssignTemplateQuery | Takes a reusable template, clones it, and assigns the non-reusable clone to the message. begin # Create Campaign Message Assign 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 # Create Campaign Message Assign 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::CampaignRecipientEstimationJobCreateQueryAsSubResource.new({type: 'campaign-recipient-estimation-job', attributes: KlaviyoAPI::CampaignRecipientEstimationJobCreateQueryAsSubResourceAttributes.new({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::CampaignSendJobCreateQueryAsSubResource.new({type: 'campaign-send-job', attributes: KlaviyoAPI::CampaignSendJobCreateQueryAsSubResourceAttributes.new({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: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets fields_tag: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets include: ['tags'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/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** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets | [optional] | | **fields_tag** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets | [optional] | | **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/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-02-22/reference/api-overview#sparse-fieldsets } 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-02-22/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-02-22/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-02-22/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-02-22/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-02-22/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 > Hash<String, Object> get_campaign_relationships(id, related_resource) Get Campaign Relationships If the `related_resource` is `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 | related_resource = 'related_resource_example' # String | begin # Get Campaign Relationships result = api_instance.get_campaign_relationships(id, related_resource) p result rescue KlaviyoAPI::ApiError => e puts "Error when calling CampaignsApi->get_campaign_relationships: #{e}" end ``` #### Using the get_campaign_relationships_with_http_info variant This returns an Array which contains the response data, status code and headers. > get_campaign_relationships_with_http_info(id, related_resource) ```ruby begin # Get Campaign Relationships data, status_code, headers = api_instance.get_campaign_relationships_with_http_info(id, related_resource) p status_code # => 2xx p headers # => { ... } p data # => Hash<String, Object> rescue KlaviyoAPI::ApiError => e puts "Error when calling CampaignsApi->get_campaign_relationships_with_http_info: #{e}" end ``` ### Parameters | Name | Type | Description | Notes | | ---- | ---- | ----------- | ----- | | **id** | **String** | | | | **related_resource** | **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-02-22/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-02-22/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(campaign_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 campaign_id = 'campaign_id_example' # String | opts = { fields_tag: ['name'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets } begin # Get Campaign Tags result = api_instance.get_campaign_tags(campaign_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(campaign_id, opts) ```ruby begin # Get Campaign Tags data, status_code, headers = api_instance.get_campaign_tags_with_http_info(campaign_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 | | ---- | ---- | ----------- | ----- | | **campaign_id** | **String** | | | | **fields_tag** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/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(opts) Get Campaigns Returns some or all campaigns based on [optional] filters

*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 opts = { fields_campaign: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets fields_tag: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets filter: 'filter_example', # String | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering
Allowed field(s)/operator(s):
`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` include: ['tags'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships page_cursor: 'page_cursor_example', # String | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination sort: 'created_at' # String | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sorting } begin # Get Campaigns result = api_instance.get_campaigns(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(opts) ```ruby begin # Get Campaigns data, status_code, headers = api_instance.get_campaigns_with_http_info(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 | | ---- | ---- | ----------- | ----- | | **fields_campaign** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets | [optional] | | **fields_tag** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#sparse-fieldsets | [optional] | | **filter** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<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` | [optional] | | **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#relationships | [optional] | | **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/reference/api-overview#pagination | [optional] | | **sort** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-02-22/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::CampaignPartialUpdateQueryAsSubResource.new({type: 'campaign', id: 'id_example', attributes: KlaviyoAPI::CampaignPartialUpdateQueryAsSubResourceAttributes.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::CampaignMessagePartialUpdateQueryAsSubResource.new({type: 'campaign-message', id: 'id_example', attributes: KlaviyoAPI::CampaignMessagePartialUpdateQueryAsSubResourceAttributes.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::CampaignSendJobPartialUpdateQueryAsSubResource.new({type: 'campaign-send-job', id: 'id_example', attributes: KlaviyoAPI::CampaignSendJobPartialUpdateQueryAsSubResourceAttributes.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