/** * Klaviyo API * The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details. * * Contact: developers@klaviyo.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ const axios = require('axios'); import {AxiosRequestConfig, AxiosResponse} from "axios"; import FormData from 'form-data' /* tslint:disable:no-unused-locals */ import { CampaignCloneQuery } from '../model/campaignCloneQuery'; import { CampaignCreateQuery } from '../model/campaignCreateQuery'; import { CampaignMessageAssignTemplateQuery } from '../model/campaignMessageAssignTemplateQuery'; import { CampaignMessageImageUpdateQuery } from '../model/campaignMessageImageUpdateQuery'; import { CampaignMessagePartialUpdateQuery } from '../model/campaignMessagePartialUpdateQuery'; import { CampaignPartialUpdateQuery } from '../model/campaignPartialUpdateQuery'; import { CampaignRecipientEstimationJobCreateQuery } from '../model/campaignRecipientEstimationJobCreateQuery'; import { CampaignSendJobCreateQuery } from '../model/campaignSendJobCreateQuery'; import { CampaignSendJobPartialUpdateQuery } from '../model/campaignSendJobPartialUpdateQuery'; import { GetAccounts4XXResponse } from '../model/getAccounts4XXResponse'; import { GetCampaignMessageCampaignRelationshipResponse } from '../model/getCampaignMessageCampaignRelationshipResponse'; import { GetCampaignMessageImageRelationshipResponse } from '../model/getCampaignMessageImageRelationshipResponse'; import { GetCampaignMessageResponseCollectionCompoundDocument } from '../model/getCampaignMessageResponseCollectionCompoundDocument'; import { GetCampaignMessageResponseCompoundDocument } from '../model/getCampaignMessageResponseCompoundDocument'; import { GetCampaignMessageTemplateRelationshipResponse } from '../model/getCampaignMessageTemplateRelationshipResponse'; import { GetCampaignMessagesRelationshipsResponseCollection } from '../model/getCampaignMessagesRelationshipsResponseCollection'; import { GetCampaignRecipientEstimationJobResponse } from '../model/getCampaignRecipientEstimationJobResponse'; import { GetCampaignRecipientEstimationResponse } from '../model/getCampaignRecipientEstimationResponse'; import { GetCampaignResponse } from '../model/getCampaignResponse'; import { GetCampaignResponseCollectionCompoundDocument } from '../model/getCampaignResponseCollectionCompoundDocument'; import { GetCampaignResponseCompoundDocument } from '../model/getCampaignResponseCompoundDocument'; import { GetCampaignSendJobResponse } from '../model/getCampaignSendJobResponse'; import { GetCampaignTagsRelationshipsResponseCollection } from '../model/getCampaignTagsRelationshipsResponseCollection'; import { GetImageResponse } from '../model/getImageResponse'; import { GetTagResponseCollection } from '../model/getTagResponseCollection'; import { GetTemplateResponse } from '../model/getTemplateResponse'; import { PatchCampaignMessageResponse } from '../model/patchCampaignMessageResponse'; import { PatchCampaignResponse } from '../model/patchCampaignResponse'; import { PostCampaignMessageResponse } from '../model/postCampaignMessageResponse'; import { PostCampaignRecipientEstimationJobResponse } from '../model/postCampaignRecipientEstimationJobResponse'; import { PostCampaignResponse } from '../model/postCampaignResponse'; import { PostCampaignSendJobResponse } from '../model/postCampaignSendJobResponse'; import { ObjectSerializer } from '../model/models'; import {RequestFile, queryParamPreProcessor, RetryWithExponentialBackoff, Session} from './apis'; let defaultBasePath = 'https://a.klaviyo.com'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export class CampaignsApi { session: Session protected _basePath = defaultBasePath; protected _defaultHeaders : any = {}; protected _useQuerystring : boolean = false; constructor(session: Session){ this.session = session } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } set defaultHeaders(defaultHeaders: any) { this._defaultHeaders = defaultHeaders; } get defaultHeaders() { return this._defaultHeaders; } get basePath() { return this._basePath; } /** * 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` * @summary Assign Template to Campaign Message * @param campaignMessageAssignTemplateQuery Takes a reusable template, clones it, and assigns the non-reusable clone to the message. */ public async assignTemplateToCampaignMessage (campaignMessageAssignTemplateQuery: CampaignMessageAssignTemplateQuery, ): Promise<{ response: AxiosResponse; body: PostCampaignMessageResponse; }> { const localVarPath = this.basePath + '/api/campaign-message-assign-template'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'campaignMessageAssignTemplateQuery' is not null or undefined if (campaignMessageAssignTemplateQuery === null || campaignMessageAssignTemplateQuery === undefined) { throw new Error('Required parameter campaignMessageAssignTemplateQuery was null or undefined when calling assignTemplateToCampaignMessage.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignMessageAssignTemplateQuery, "CampaignMessageAssignTemplateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostCampaignMessageResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostCampaignMessageResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * 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` * @summary Cancel Campaign Send * @param id The ID of the currently sending campaign to cancel or revert* @param campaignSendJobPartialUpdateQuery Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT */ public async cancelCampaignSend (id: string, campaignSendJobPartialUpdateQuery: CampaignSendJobPartialUpdateQuery, ): Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/api/campaign-send-jobs/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling cancelCampaignSend.'); } // verify required parameter 'campaignSendJobPartialUpdateQuery' is not null or undefined if (campaignSendJobPartialUpdateQuery === null || campaignSendJobPartialUpdateQuery === undefined) { throw new Error('Required parameter campaignSendJobPartialUpdateQuery was null or undefined when calling cancelCampaignSend.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'PATCH', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignSendJobPartialUpdateQuery, "CampaignSendJobPartialUpdateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body?: any; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Creates a campaign given a set of parameters, then returns it.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` * @summary Create Campaign * @param campaignCreateQuery Creates a campaign from parameters */ public async createCampaign (campaignCreateQuery: CampaignCreateQuery, ): Promise<{ response: AxiosResponse; body: PostCampaignResponse; }> { const localVarPath = this.basePath + '/api/campaigns'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'campaignCreateQuery' is not null or undefined if (campaignCreateQuery === null || campaignCreateQuery === undefined) { throw new Error('Required parameter campaignCreateQuery was null or undefined when calling createCampaign.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignCreateQuery, "CampaignCreateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostCampaignResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostCampaignResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * 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` * @summary Create Campaign Clone * @param campaignCloneQuery Clones a campaign from an existing campaign */ public async createCampaignClone (campaignCloneQuery: CampaignCloneQuery, ): Promise<{ response: AxiosResponse; body: PostCampaignResponse; }> { const localVarPath = this.basePath + '/api/campaign-clone'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'campaignCloneQuery' is not null or undefined if (campaignCloneQuery === null || campaignCloneQuery === undefined) { throw new Error('Required parameter campaignCloneQuery was null or undefined when calling createCampaignClone.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignCloneQuery, "CampaignCloneQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostCampaignResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostCampaignResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Delete a campaign with the given campaign ID.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` * @summary Delete Campaign * @param id The campaign ID to be deleted */ public async deleteCampaign (id: string, ): Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/api/campaigns/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling deleteCampaign.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'DELETE', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body?: any; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Returns a specific campaign based on a required id.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Campaign * @param id The campaign ID to be retrieved * @param fieldsCampaignMessage For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsCampaign For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsTag For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param include For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#relationships */ public async getCampaign (id: string, options: { fieldsCampaignMessage?: Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>, fieldsCampaign?: Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>, fieldsTag?: Array<'name'>, include?: Array<'campaign-messages' | 'tags'>, } = {}): Promise<{ response: AxiosResponse; body: GetCampaignResponseCompoundDocument; }> { const localVarPath = this.basePath + '/api/campaigns/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getCampaign.'); } if (options.fieldsCampaignMessage !== undefined) { localVarQueryParameters['fields[campaign-message]'] = ObjectSerializer.serialize(options.fieldsCampaignMessage, "Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>"); } if (options.fieldsCampaign !== undefined) { localVarQueryParameters['fields[campaign]'] = ObjectSerializer.serialize(options.fieldsCampaign, "Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>"); } if (options.fieldsTag !== undefined) { localVarQueryParameters['fields[tag]'] = ObjectSerializer.serialize(options.fieldsTag, "Array<'name'>"); } if (options.include !== undefined) { localVarQueryParameters['include'] = ObjectSerializer.serialize(options.include, "Array<'campaign-messages' | 'tags'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignResponseCompoundDocument; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignResponseCompoundDocument"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Return the related campaign

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Campaign for Campaign Message * @param id * @param fieldsCampaign For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getCampaignForCampaignMessage (id: string, options: { fieldsCampaign?: Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>, } = {}): Promise<{ response: AxiosResponse; body: GetCampaignResponse; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}/campaign' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getCampaignForCampaignMessage.'); } if (options.fieldsCampaign !== undefined) { localVarQueryParameters['fields[campaign]'] = ObjectSerializer.serialize(options.fieldsCampaign, "Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Returns the ID of the related campaign

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Campaign ID for Campaign Message * @param id */ public async getCampaignIdForCampaignMessage (id: string, ): Promise<{ response: AxiosResponse; body: GetCampaignMessageCampaignRelationshipResponse; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}/relationships/campaign' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getCampaignIdForCampaignMessage.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignMessageCampaignRelationshipResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignMessageCampaignRelationshipResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Returns a specific message based on a required id.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Campaign Message * @param id The message ID to be retrieved * @param fieldsCampaignMessage For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsCampaign For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsImage For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsTemplate For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param include For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#relationships */ public async getCampaignMessage (id: string, options: { fieldsCampaignMessage?: Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>, fieldsCampaign?: Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>, fieldsImage?: Array<'format' | 'hidden' | 'image_url' | 'name' | 'size' | 'updated_at'>, fieldsTemplate?: Array<'amp' | 'created' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>, include?: Array<'campaign' | 'image' | 'template'>, } = {}): Promise<{ response: AxiosResponse; body: GetCampaignMessageResponseCompoundDocument; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getCampaignMessage.'); } if (options.fieldsCampaignMessage !== undefined) { localVarQueryParameters['fields[campaign-message]'] = ObjectSerializer.serialize(options.fieldsCampaignMessage, "Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>"); } if (options.fieldsCampaign !== undefined) { localVarQueryParameters['fields[campaign]'] = ObjectSerializer.serialize(options.fieldsCampaign, "Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>"); } if (options.fieldsImage !== undefined) { localVarQueryParameters['fields[image]'] = ObjectSerializer.serialize(options.fieldsImage, "Array<'format' | 'hidden' | 'image_url' | 'name' | 'size' | 'updated_at'>"); } if (options.fieldsTemplate !== undefined) { localVarQueryParameters['fields[template]'] = ObjectSerializer.serialize(options.fieldsTemplate, "Array<'amp' | 'created' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>"); } if (options.include !== undefined) { localVarQueryParameters['include'] = ObjectSerializer.serialize(options.include, "Array<'campaign' | 'image' | 'template'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignMessageResponseCompoundDocument; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignMessageResponseCompoundDocument"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * 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` * @summary Get Campaign Recipient Estimation * @param id The ID of the campaign for which to get the estimated number of recipients * @param fieldsCampaignRecipientEstimation For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getCampaignRecipientEstimation (id: string, options: { fieldsCampaignRecipientEstimation?: Array<'estimated_recipient_count'>, } = {}): Promise<{ response: AxiosResponse; body: GetCampaignRecipientEstimationResponse; }> { const localVarPath = this.basePath + '/api/campaign-recipient-estimations/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getCampaignRecipientEstimation.'); } if (options.fieldsCampaignRecipientEstimation !== undefined) { localVarQueryParameters['fields[campaign-recipient-estimation]'] = ObjectSerializer.serialize(options.fieldsCampaignRecipientEstimation, "Array<'estimated_recipient_count'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignRecipientEstimationResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignRecipientEstimationResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * 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` * @summary Get Campaign Recipient Estimation Job * @param id The ID of the campaign to get recipient estimation status * @param fieldsCampaignRecipientEstimationJob For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getCampaignRecipientEstimationJob (id: string, options: { fieldsCampaignRecipientEstimationJob?: Array<'status'>, } = {}): Promise<{ response: AxiosResponse; body: GetCampaignRecipientEstimationJobResponse; }> { const localVarPath = this.basePath + '/api/campaign-recipient-estimation-jobs/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getCampaignRecipientEstimationJob.'); } if (options.fieldsCampaignRecipientEstimationJob !== undefined) { localVarQueryParameters['fields[campaign-recipient-estimation-job]'] = ObjectSerializer.serialize(options.fieldsCampaignRecipientEstimationJob, "Array<'status'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignRecipientEstimationJobResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignRecipientEstimationJobResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Get a campaign send job

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Campaign Send Job * @param id The ID of the campaign to send * @param fieldsCampaignSendJob For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getCampaignSendJob (id: string, options: { fieldsCampaignSendJob?: Array<'status'>, } = {}): Promise<{ response: AxiosResponse; body: GetCampaignSendJobResponse; }> { const localVarPath = this.basePath + '/api/campaign-send-jobs/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getCampaignSendJob.'); } if (options.fieldsCampaignSendJob !== undefined) { localVarQueryParameters['fields[campaign-send-job]'] = ObjectSerializer.serialize(options.fieldsCampaignSendJob, "Array<'status'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignSendJobResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignSendJobResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * 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. `?filter=equals(messages.channel,\'mobile_push\')` to list mobile push campaigns.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Campaigns * @param filter For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`<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` * @param fieldsCampaignMessage For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsCampaign For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsTag For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param include For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#relationships* @param pageCursor For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#pagination* @param sort For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sorting */ public async getCampaigns (filter: string, options: { fieldsCampaignMessage?: Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>, fieldsCampaign?: Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>, fieldsTag?: Array<'name'>, include?: Array<'campaign-messages' | 'tags'>, pageCursor?: string, sort?: 'created_at' | '-created_at' | 'id' | '-id' | 'name' | '-name' | 'scheduled_at' | '-scheduled_at' | 'updated_at' | '-updated_at', } = {}): Promise<{ response: AxiosResponse; body: GetCampaignResponseCollectionCompoundDocument; }> { const localVarPath = this.basePath + '/api/campaigns'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'filter' is not null or undefined if (filter === null || filter === undefined) { throw new Error('Required parameter filter was null or undefined when calling getCampaigns.'); } if (options.fieldsCampaignMessage !== undefined) { localVarQueryParameters['fields[campaign-message]'] = ObjectSerializer.serialize(options.fieldsCampaignMessage, "Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>"); } if (options.fieldsCampaign !== undefined) { localVarQueryParameters['fields[campaign]'] = ObjectSerializer.serialize(options.fieldsCampaign, "Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>"); } if (options.fieldsTag !== undefined) { localVarQueryParameters['fields[tag]'] = ObjectSerializer.serialize(options.fieldsTag, "Array<'name'>"); } localVarQueryParameters['filter'] = ObjectSerializer.serialize(filter, "string"); if (options.include !== undefined) { localVarQueryParameters['include'] = ObjectSerializer.serialize(options.include, "Array<'campaign-messages' | 'tags'>"); } if (options.pageCursor !== undefined) { localVarQueryParameters['page[cursor]'] = ObjectSerializer.serialize(options.pageCursor, "string"); } if (options.sort !== undefined) { localVarQueryParameters['sort'] = ObjectSerializer.serialize(options.sort, "'created_at' | '-created_at' | 'id' | '-id' | 'name' | '-name' | 'scheduled_at' | '-scheduled_at' | 'updated_at' | '-updated_at'"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignResponseCollectionCompoundDocument; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignResponseCollectionCompoundDocument"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Return the related image for a given campaign message

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `images:read` * @summary Get Image for Campaign Message * @param id * @param fieldsImage For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getImageForCampaignMessage (id: string, options: { fieldsImage?: Array<'format' | 'hidden' | 'image_url' | 'name' | 'size' | 'updated_at'>, } = {}): Promise<{ response: AxiosResponse; body: GetImageResponse; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}/image' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getImageForCampaignMessage.'); } if (options.fieldsImage !== undefined) { localVarQueryParameters['fields[image]'] = ObjectSerializer.serialize(options.fieldsImage, "Array<'format' | 'hidden' | 'image_url' | 'name' | 'size' | 'updated_at'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetImageResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetImageResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Returns the ID of the related image

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `images:read` * @summary Get Image ID for Campaign Message * @param id */ public async getImageIdForCampaignMessage (id: string, ): Promise<{ response: AxiosResponse; body: GetCampaignMessageImageRelationshipResponse; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}/relationships/image' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getImageIdForCampaignMessage.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignMessageImageRelationshipResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignMessageImageRelationshipResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Returns the IDs of all messages associated with the given campaign.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Message IDs for Campaign * @param id */ public async getMessageIdsForCampaign (id: string, ): Promise<{ response: AxiosResponse; body: GetCampaignMessagesRelationshipsResponseCollection; }> { const localVarPath = this.basePath + '/api/campaigns/{id}/relationships/campaign-messages' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getMessageIdsForCampaign.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignMessagesRelationshipsResponseCollection; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignMessagesRelationshipsResponseCollection"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Return all messages that belong to the given campaign.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` * @summary Get Messages for Campaign * @param id * @param fieldsCampaignMessage For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsCampaign For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsImage For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsTemplate For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param include For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#relationships */ public async getMessagesForCampaign (id: string, options: { fieldsCampaignMessage?: Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>, fieldsCampaign?: Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>, fieldsImage?: Array<'format' | 'hidden' | 'image_url' | 'name' | 'size' | 'updated_at'>, fieldsTemplate?: Array<'amp' | 'created' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>, include?: Array<'campaign' | 'image' | 'template'>, } = {}): Promise<{ response: AxiosResponse; body: GetCampaignMessageResponseCollectionCompoundDocument; }> { const localVarPath = this.basePath + '/api/campaigns/{id}/campaign-messages' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getMessagesForCampaign.'); } if (options.fieldsCampaignMessage !== undefined) { localVarQueryParameters['fields[campaign-message]'] = ObjectSerializer.serialize(options.fieldsCampaignMessage, "Array<'created_at' | 'definition' | 'definition.channel' | 'definition.content' | 'definition.content.bcc_email' | 'definition.content.body' | 'definition.content.cc_email' | 'definition.content.dynamic_image' | 'definition.content.from_email' | 'definition.content.from_label' | 'definition.content.media_url' | 'definition.content.preview_text' | 'definition.content.reply_to_email' | 'definition.content.subject' | 'definition.content.title' | 'definition.kv_pairs' | 'definition.label' | 'definition.notification_type' | 'definition.options' | 'definition.options.badge' | 'definition.options.badge.badge_options' | 'definition.options.badge.badge_options.badge_config' | 'definition.options.badge.badge_options.set_from_property' | 'definition.options.badge.badge_options.value' | 'definition.options.badge.display' | 'definition.options.on_open' | 'definition.options.on_open.android_deep_link' | 'definition.options.on_open.ios_deep_link' | 'definition.options.on_open.type' | 'definition.options.play_sound' | 'definition.render_options' | 'definition.render_options.add_info_link' | 'definition.render_options.add_opt_out_language' | 'definition.render_options.add_org_prefix' | 'definition.render_options.shorten_links' | 'send_times' | 'updated_at'>"); } if (options.fieldsCampaign !== undefined) { localVarQueryParameters['fields[campaign]'] = ObjectSerializer.serialize(options.fieldsCampaign, "Array<'archived' | 'audiences' | 'audiences.excluded' | 'audiences.included' | 'created_at' | 'name' | 'scheduled_at' | 'send_options' | 'send_options.use_smart_sending' | 'send_strategy' | 'send_strategy.date' | 'send_strategy.datetime' | 'send_strategy.method' | 'send_strategy.options' | 'send_strategy.options.is_local' | 'send_strategy.options.send_past_recipients_immediately' | 'send_strategy.throttle_percentage' | 'send_time' | 'status' | 'tracking_options' | 'tracking_options.add_tracking_params' | 'tracking_options.custom_tracking_params' | 'tracking_options.is_tracking_clicks' | 'tracking_options.is_tracking_opens' | 'updated_at'>"); } if (options.fieldsImage !== undefined) { localVarQueryParameters['fields[image]'] = ObjectSerializer.serialize(options.fieldsImage, "Array<'format' | 'hidden' | 'image_url' | 'name' | 'size' | 'updated_at'>"); } if (options.fieldsTemplate !== undefined) { localVarQueryParameters['fields[template]'] = ObjectSerializer.serialize(options.fieldsTemplate, "Array<'amp' | 'created' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>"); } if (options.include !== undefined) { localVarQueryParameters['include'] = ObjectSerializer.serialize(options.include, "Array<'campaign' | 'image' | 'template'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignMessageResponseCollectionCompoundDocument; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignMessageResponseCollectionCompoundDocument"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Returns the IDs of all tags associated with the given campaign.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` * @summary Get Tag IDs for Campaign * @param id */ public async getTagIdsForCampaign (id: string, ): Promise<{ response: AxiosResponse; body: GetCampaignTagsRelationshipsResponseCollection; }> { const localVarPath = this.basePath + '/api/campaigns/{id}/relationships/tags' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getTagIdsForCampaign.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignTagsRelationshipsResponseCollection; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignTagsRelationshipsResponseCollection"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Return all tags that belong to the given campaign.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` * @summary Get Tags for Campaign * @param id * @param fieldsTag For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getTagsForCampaign (id: string, options: { fieldsTag?: Array<'name'>, } = {}): Promise<{ response: AxiosResponse; body: GetTagResponseCollection; }> { const localVarPath = this.basePath + '/api/campaigns/{id}/tags' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getTagsForCampaign.'); } if (options.fieldsTag !== undefined) { localVarQueryParameters['fields[tag]'] = ObjectSerializer.serialize(options.fieldsTag, "Array<'name'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetTagResponseCollection; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetTagResponseCollection"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Return the related template

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `templates:read` * @summary Get Template for Campaign Message * @param id * @param fieldsTemplate For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getTemplateForCampaignMessage (id: string, options: { fieldsTemplate?: Array<'amp' | 'created' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>, } = {}): Promise<{ response: AxiosResponse; body: GetTemplateResponse; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}/template' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getTemplateForCampaignMessage.'); } if (options.fieldsTemplate !== undefined) { localVarQueryParameters['fields[template]'] = ObjectSerializer.serialize(options.fieldsTemplate, "Array<'amp' | 'created' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetTemplateResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetTemplateResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Returns the ID of the related template

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:read` `templates:read` * @summary Get Template ID for Campaign Message * @param id */ public async getTemplateIdForCampaignMessage (id: string, ): Promise<{ response: AxiosResponse; body: GetCampaignMessageTemplateRelationshipResponse; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}/relationships/template' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getTemplateIdForCampaignMessage.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetCampaignMessageTemplateRelationshipResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetCampaignMessageTemplateRelationshipResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * 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` * @summary Refresh Campaign Recipient Estimation * @param 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. */ public async refreshCampaignRecipientEstimation (campaignRecipientEstimationJobCreateQuery: CampaignRecipientEstimationJobCreateQuery, ): Promise<{ response: AxiosResponse; body: PostCampaignRecipientEstimationJobResponse; }> { const localVarPath = this.basePath + '/api/campaign-recipient-estimation-jobs'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'campaignRecipientEstimationJobCreateQuery' is not null or undefined if (campaignRecipientEstimationJobCreateQuery === null || campaignRecipientEstimationJobCreateQuery === undefined) { throw new Error('Required parameter campaignRecipientEstimationJobCreateQuery was null or undefined when calling refreshCampaignRecipientEstimation.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignRecipientEstimationJobCreateQuery, "CampaignRecipientEstimationJobCreateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostCampaignRecipientEstimationJobResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostCampaignRecipientEstimationJobResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Trigger a campaign to send asynchronously

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` * @summary Send Campaign * @param campaignSendJobCreateQuery Trigger the campaign to send asynchronously */ public async sendCampaign (campaignSendJobCreateQuery: CampaignSendJobCreateQuery, ): Promise<{ response: AxiosResponse; body: PostCampaignSendJobResponse; }> { const localVarPath = this.basePath + '/api/campaign-send-jobs'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'campaignSendJobCreateQuery' is not null or undefined if (campaignSendJobCreateQuery === null || campaignSendJobCreateQuery === undefined) { throw new Error('Required parameter campaignSendJobCreateQuery was null or undefined when calling sendCampaign.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignSendJobCreateQuery, "CampaignSendJobCreateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostCampaignSendJobResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostCampaignSendJobResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Update a campaign with the given campaign ID.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` * @summary Update Campaign * @param id The campaign ID to be retrieved* @param campaignPartialUpdateQuery Update a campaign and return it */ public async updateCampaign (id: string, campaignPartialUpdateQuery: CampaignPartialUpdateQuery, ): Promise<{ response: AxiosResponse; body: PatchCampaignResponse; }> { const localVarPath = this.basePath + '/api/campaigns/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling updateCampaign.'); } // verify required parameter 'campaignPartialUpdateQuery' is not null or undefined if (campaignPartialUpdateQuery === null || campaignPartialUpdateQuery === undefined) { throw new Error('Required parameter campaignPartialUpdateQuery was null or undefined when calling updateCampaign.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'PATCH', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignPartialUpdateQuery, "CampaignPartialUpdateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PatchCampaignResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PatchCampaignResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Update a campaign message

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` * @summary Update Campaign Message * @param id The message ID to be retrieved* @param campaignMessagePartialUpdateQuery Update a message and return it */ public async updateCampaignMessage (id: string, campaignMessagePartialUpdateQuery: CampaignMessagePartialUpdateQuery, ): Promise<{ response: AxiosResponse; body: PatchCampaignMessageResponse; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling updateCampaignMessage.'); } // verify required parameter 'campaignMessagePartialUpdateQuery' is not null or undefined if (campaignMessagePartialUpdateQuery === null || campaignMessagePartialUpdateQuery === undefined) { throw new Error('Required parameter campaignMessagePartialUpdateQuery was null or undefined when calling updateCampaignMessage.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'PATCH', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignMessagePartialUpdateQuery, "CampaignMessagePartialUpdateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PatchCampaignMessageResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PatchCampaignMessageResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Update a campaign message image

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `campaigns:write` `images:read` * @summary Update Image for Campaign Message * @param id * @param campaignMessageImageUpdateQuery */ public async updateImageForCampaignMessage (id: string, campaignMessageImageUpdateQuery: CampaignMessageImageUpdateQuery, ): Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/api/campaign-messages/{id}/relationships/image' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling updateImageForCampaignMessage.'); } // verify required parameter 'campaignMessageImageUpdateQuery' is not null or undefined if (campaignMessageImageUpdateQuery === null || campaignMessageImageUpdateQuery === undefined) { throw new Error('Required parameter campaignMessageImageUpdateQuery was null or undefined when calling updateImageForCampaignMessage.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'PATCH', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(campaignMessageImageUpdateQuery, "CampaignMessageImageUpdateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body?: any; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } } export interface CampaignsApi { /** * Alias of {@link CampaignsApi.assignTemplateToCampaignMessage} * * @deprecated Use {@link CampaignsApi.assignTemplateToCampaignMessage} instead */ createCampaignMessageAssignTemplate: typeof CampaignsApi.prototype.assignTemplateToCampaignMessage; } CampaignsApi.prototype.createCampaignMessageAssignTemplate = CampaignsApi.prototype.assignTemplateToCampaignMessage export interface CampaignsApi { /** * Alias of {@link CampaignsApi.cancelCampaignSend} * * @deprecated Use {@link CampaignsApi.cancelCampaignSend} instead */ updateCampaignSendJob: typeof CampaignsApi.prototype.cancelCampaignSend; } CampaignsApi.prototype.updateCampaignSendJob = CampaignsApi.prototype.cancelCampaignSend export interface CampaignsApi { /** * Alias of {@link CampaignsApi.createCampaignClone} * * @deprecated Use {@link CampaignsApi.createCampaignClone} instead */ cloneCampaign: typeof CampaignsApi.prototype.createCampaignClone; } CampaignsApi.prototype.cloneCampaign = CampaignsApi.prototype.createCampaignClone export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getCampaignForCampaignMessage} * * @deprecated Use {@link CampaignsApi.getCampaignForCampaignMessage} instead */ getCampaignMessageCampaign: typeof CampaignsApi.prototype.getCampaignForCampaignMessage; } CampaignsApi.prototype.getCampaignMessageCampaign = CampaignsApi.prototype.getCampaignForCampaignMessage export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getCampaignIdForCampaignMessage} * * @deprecated Use {@link CampaignsApi.getCampaignIdForCampaignMessage} instead */ getCampaignMessageRelationshipsCampaign: typeof CampaignsApi.prototype.getCampaignIdForCampaignMessage; } CampaignsApi.prototype.getCampaignMessageRelationshipsCampaign = CampaignsApi.prototype.getCampaignIdForCampaignMessage export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getImageForCampaignMessage} * * @deprecated Use {@link CampaignsApi.getImageForCampaignMessage} instead */ getCampaignMessageImage: typeof CampaignsApi.prototype.getImageForCampaignMessage; } CampaignsApi.prototype.getCampaignMessageImage = CampaignsApi.prototype.getImageForCampaignMessage export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getImageIdForCampaignMessage} * * @deprecated Use {@link CampaignsApi.getImageIdForCampaignMessage} instead */ getCampaignMessageRelationshipsImage: typeof CampaignsApi.prototype.getImageIdForCampaignMessage; } CampaignsApi.prototype.getCampaignMessageRelationshipsImage = CampaignsApi.prototype.getImageIdForCampaignMessage export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getMessageIdsForCampaign} * * @deprecated Use {@link CampaignsApi.getMessageIdsForCampaign} instead */ getCampaignRelationshipsCampaignMessages: typeof CampaignsApi.prototype.getMessageIdsForCampaign; } CampaignsApi.prototype.getCampaignRelationshipsCampaignMessages = CampaignsApi.prototype.getMessageIdsForCampaign export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getMessageIdsForCampaign} * * @deprecated Use {@link CampaignsApi.getMessageIdsForCampaign} instead */ getCampaignRelationshipsMessages: typeof CampaignsApi.prototype.getMessageIdsForCampaign; } CampaignsApi.prototype.getCampaignRelationshipsMessages = CampaignsApi.prototype.getMessageIdsForCampaign export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getMessagesForCampaign} * * @deprecated Use {@link CampaignsApi.getMessagesForCampaign} instead */ getCampaignCampaignMessages: typeof CampaignsApi.prototype.getMessagesForCampaign; } CampaignsApi.prototype.getCampaignCampaignMessages = CampaignsApi.prototype.getMessagesForCampaign export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getMessagesForCampaign} * * @deprecated Use {@link CampaignsApi.getMessagesForCampaign} instead */ getCampaignMessages: typeof CampaignsApi.prototype.getMessagesForCampaign; } CampaignsApi.prototype.getCampaignMessages = CampaignsApi.prototype.getMessagesForCampaign export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getTagIdsForCampaign} * * @deprecated Use {@link CampaignsApi.getTagIdsForCampaign} instead */ getCampaignRelationshipsTags: typeof CampaignsApi.prototype.getTagIdsForCampaign; } CampaignsApi.prototype.getCampaignRelationshipsTags = CampaignsApi.prototype.getTagIdsForCampaign export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getTagsForCampaign} * * @deprecated Use {@link CampaignsApi.getTagsForCampaign} instead */ getCampaignTags: typeof CampaignsApi.prototype.getTagsForCampaign; } CampaignsApi.prototype.getCampaignTags = CampaignsApi.prototype.getTagsForCampaign export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getTemplateForCampaignMessage} * * @deprecated Use {@link CampaignsApi.getTemplateForCampaignMessage} instead */ getCampaignMessageTemplate: typeof CampaignsApi.prototype.getTemplateForCampaignMessage; } CampaignsApi.prototype.getCampaignMessageTemplate = CampaignsApi.prototype.getTemplateForCampaignMessage export interface CampaignsApi { /** * Alias of {@link CampaignsApi.getTemplateIdForCampaignMessage} * * @deprecated Use {@link CampaignsApi.getTemplateIdForCampaignMessage} instead */ getCampaignMessageRelationshipsTemplate: typeof CampaignsApi.prototype.getTemplateIdForCampaignMessage; } CampaignsApi.prototype.getCampaignMessageRelationshipsTemplate = CampaignsApi.prototype.getTemplateIdForCampaignMessage export interface CampaignsApi { /** * Alias of {@link CampaignsApi.refreshCampaignRecipientEstimation} * * @deprecated Use {@link CampaignsApi.refreshCampaignRecipientEstimation} instead */ createCampaignRecipientEstimationJob: typeof CampaignsApi.prototype.refreshCampaignRecipientEstimation; } CampaignsApi.prototype.createCampaignRecipientEstimationJob = CampaignsApi.prototype.refreshCampaignRecipientEstimation export interface CampaignsApi { /** * Alias of {@link CampaignsApi.sendCampaign} * * @deprecated Use {@link CampaignsApi.sendCampaign} instead */ createCampaignSendJob: typeof CampaignsApi.prototype.sendCampaign; } CampaignsApi.prototype.createCampaignSendJob = CampaignsApi.prototype.sendCampaign export interface CampaignsApi { /** * Alias of {@link CampaignsApi.updateImageForCampaignMessage} * * @deprecated Use {@link CampaignsApi.updateImageForCampaignMessage} instead */ updateCampaignMessageRelationshipsImage: typeof CampaignsApi.prototype.updateImageForCampaignMessage; } CampaignsApi.prototype.updateCampaignMessageRelationshipsImage = CampaignsApi.prototype.updateImageForCampaignMessage