Class: KlaviyoAPI::TemplatesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo-api-sdk/api/templates_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TemplatesApi

Returns a new instance of TemplatesApi.



18
19
20
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 18

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



16
17
18
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 16

def api_client
  @api_client
end

Instance Method Details

#clone_template(template_clone_query, opts = {}) ⇒ Hash<String, Object> Also known as: create_template_clone

Clone Template Create a clone of a template with the given template ID. If there are 1,000 or more templates in an account, cloning will fail as there is a limit of 1,000 templates that can be created via the API.
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:write`

Parameters:

  • template_clone_query (TemplateCloneQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


26
27
28
29
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 26

def clone_template(template_clone_query, opts = {})
  data, _status_code, _headers = clone_template_with_http_info(template_clone_query, opts)
  data
end

#clone_template_with_http_info(template_clone_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: create_template_clone_with_http_info

Clone Template Create a clone of a template with the given template ID. If there are 1,000 or more templates in an account, cloning will fail as there is a limit of 1,000 templates that can be created via the API.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

  • template_clone_query (TemplateCloneQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 39

def clone_template_with_http_info(template_clone_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.clone_template ...'
  end
  # verify the required parameter 'template_clone_query' is set
  if @api_client.config.client_side_validation && template_clone_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_clone_query' when calling TemplatesApi.clone_template"
  end
  # resource path
  local_var_path = '/api/template-clone'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_clone_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.clone_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#clone_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_template(template_create_html_or_dnd_query, opts = {}) ⇒ Hash<String, Object>

Create Template Create a new HTML or drag-and-drop template. If there are 1,000 or more templates in an account, creation will fail as there is a limit of 1,000 templates that can be created via the API. Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets).
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:write`

Parameters:

Options Hash (opts):

  • :additional_fields_template (Array<String>)

    Request additional fields not included by default in the response. Supported values: &#39;definition&#39;

Returns:

  • (Hash<String, Object>)


103
104
105
106
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 103

def create_template(template_create_html_or_dnd_query, opts = {})
  data, _status_code, _headers = create_template_with_http_info(template_create_html_or_dnd_query, opts)
  data
end

#create_template_with_http_info(template_create_html_or_dnd_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Create Template Create a new HTML or drag-and-drop template. If there are 1,000 or more templates in an account, creation will fail as there is a limit of 1,000 templates that can be created via the API. Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets).&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

Options Hash (opts):

  • :additional_fields_template (Array<String>)

    Request additional fields not included by default in the response. Supported values: &#39;definition&#39;

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 114

def create_template_with_http_info(template_create_html_or_dnd_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.create_template ...'
  end
  # verify the required parameter 'template_create_html_or_dnd_query' is set
  if @api_client.config.client_side_validation && template_create_html_or_dnd_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_create_html_or_dnd_query' when calling TemplatesApi.create_template"
  end
  allowable_values = ["definition"]
  if @api_client.config.client_side_validation && opts[:'additional_fields_template'] && !opts[:'additional_fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"additional_fields_template\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/templates'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'additional-fields[template]'] = @api_client.build_collection_param(opts[:'additional_fields_template'], :csv) if !opts[:'additional_fields_template'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_create_html_or_dnd_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.create_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#create_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_universal_content(universal_content_create_query, opts = {}) ⇒ Hash<String, Object> Also known as: create_template_universal_content

Create Universal Content Create universal content. Currently supported block types are: ‘button`, `drop_shadow`, `horizontal_rule`, `html`, `image`, `spacer`, and `text`.
*Rate limits*:
Burst: `75/s`
Steady: `750/m` Scopes: `templates:write`

Parameters:

  • universal_content_create_query (UniversalContentCreateQuery)

    Create a template universal content

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


179
180
181
182
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 179

def create_universal_content(universal_content_create_query, opts = {})
  data, _status_code, _headers = create_universal_content_with_http_info(universal_content_create_query, opts)
  data
end

#create_universal_content_with_http_info(universal_content_create_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: create_template_universal_content_with_http_info

Create Universal Content Create universal content. Currently supported block types are: &#x60;button&#x60;, &#x60;drop_shadow&#x60;, &#x60;horizontal_rule&#x60;, &#x60;html&#x60;, &#x60;image&#x60;, &#x60;spacer&#x60;, and &#x60;text&#x60;.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

  • universal_content_create_query (UniversalContentCreateQuery)

    Create a template universal content

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 192

def create_universal_content_with_http_info(universal_content_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.create_universal_content ...'
  end
  # verify the required parameter 'universal_content_create_query' is set
  if @api_client.config.client_side_validation && universal_content_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'universal_content_create_query' when calling TemplatesApi.create_universal_content"
  end
  # resource path
  local_var_path = '/api/template-universal-content'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(universal_content_create_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.create_universal_content",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#create_universal_content\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_template(id, opts = {}) ⇒ nil

Delete Template Delete a template with the given template ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:write`

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


255
256
257
258
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 255

def delete_template(id, opts = {})
  delete_template_with_http_info(id, opts)
  nil
end

#delete_template_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Template Delete a template with the given template ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 265

def delete_template_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.delete_template ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.delete_template"
  end
  # resource path
  local_var_path = '/api/templates/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.delete_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#delete_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_universal_content(id, opts = {}) ⇒ nil Also known as: delete_template_universal_content

Delete Universal Content Delete the universal content with the given ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:write`

Parameters:

  • id (String)

    The ID of the template universal content

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


320
321
322
323
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 320

def delete_universal_content(id, opts = {})
  delete_universal_content_with_http_info(id, opts)
  nil
end

#delete_universal_content_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)> Also known as: delete_template_universal_content_with_http_info

Delete Universal Content Delete the universal content with the given ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

  • id (String)

    The ID of the template universal content

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 333

def delete_universal_content_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.delete_universal_content ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.delete_universal_content"
  end
  # resource path
  local_var_path = '/api/template-universal-content/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.delete_universal_content",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#delete_universal_content\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_all_universal_content(opts = {}) ⇒ Hash<String, Object> Also known as: get_template_universal_content

Get All Universal Content Get all universal content in an account.
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:read`

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


395
396
397
398
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 395

def get_all_universal_content(opts = {})
  data, _status_code, _headers = get_all_universal_content_with_http_info(opts)
  data
end

#get_all_universal_content_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_template_universal_content_with_http_info

Get All Universal Content Get all universal content in an account.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 412

def get_all_universal_content_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.get_all_universal_content ...'
  end
  allowable_values = ["created", "definition", "definition.content_type", "definition.data", "definition.data.content", "definition.data.display_options", "definition.data.display_options.content_repeat", "definition.data.display_options.content_repeat.item_alias", "definition.data.display_options.content_repeat.repeat_for", "definition.data.display_options.show_on", "definition.data.display_options.visible_check", "definition.data.styles", "definition.data.styles.background_color", "definition.data.styles.block_background_color", "definition.data.styles.block_border_color", "definition.data.styles.block_border_style", "definition.data.styles.block_border_width", "definition.data.styles.block_padding_bottom", "definition.data.styles.block_padding_left", "definition.data.styles.block_padding_right", "definition.data.styles.block_padding_top", "definition.data.styles.color", "definition.data.styles.extra_css_class", "definition.data.styles.font_family", "definition.data.styles.font_size", "definition.data.styles.font_style", "definition.data.styles.font_weight", "definition.data.styles.inner_padding_bottom", "definition.data.styles.inner_padding_left", "definition.data.styles.inner_padding_right", "definition.data.styles.inner_padding_top", "definition.data.styles.letter_spacing", "definition.data.styles.line_height", "definition.data.styles.mobile_stretch_content", "definition.data.styles.text_align", "definition.data.styles.text_decoration", "definition.data.styles.text_table_layout", "definition.type", "name", "screenshot_status", "screenshot_url", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template_universal_content'] && !opts[:'fields_template_universal_content'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template_universal_content\", must include one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling TemplatesApi.get_all_universal_content, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling TemplatesApi.get_all_universal_content, must be greater than or equal to 1.'
  end

  allowable_values = ["created", "-created", "id", "-id", "name", "-name", "updated", "-updated"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/template-universal-content'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[template-universal-content]'] = @api_client.build_collection_param(opts[:'fields_template_universal_content'], :csv) if !opts[:'fields_template_universal_content'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.get_all_universal_content",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#get_all_universal_content\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_template(id, opts = {}) ⇒ Hash<String, Object>

Get Template Get a template with the given template ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:read`

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


489
490
491
492
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 489

def get_template(id, opts = {})
  data, _status_code, _headers = get_template_with_http_info(id, opts)
  data
end

#get_template_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Template Get a template with the given template ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 501

def get_template_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.get_template ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.get_template"
  end
  allowable_values = ["definition"]
  if @api_client.config.client_side_validation && opts[:'additional_fields_template'] && !opts[:'additional_fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"additional_fields_template\", must include one of #{allowable_values}"
  end
  allowable_values = ["amp", "created", "definition", "definition.body", "definition.body.id", "definition.body.properties", "definition.body.properties.css_class", "definition.body.properties.id", "definition.body.sections", "definition.body.styles", "definition.body.styles.background_color", "definition.body.styles.width", "definition.id", "definition.styles", "definition.template_id", "editor_type", "html", "name", "text", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/templates/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'additional-fields[template]'] = @api_client.build_collection_param(opts[:'additional_fields_template'], :csv) if !opts[:'additional_fields_template'].nil?
  query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.get_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#get_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_templates(opts = {}) ⇒ Hash<String, Object>

Get Templates Get all templates in an account. Use ‘additional-fields=definition` to include the full template definition for SYSTEM_DRAGGABLE templates.
*Rate limits*:
Burst: `75/s`
Steady: `750/m` Scopes: `templates:read`

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


570
571
572
573
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 570

def get_templates(opts = {})
  data, _status_code, _headers = get_templates_with_http_info(opts)
  data
end

#get_templates_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Templates Get all templates in an account. Use &#x60;additional-fields&#x3D;definition&#x60; to include the full template definition for SYSTEM_DRAGGABLE templates.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 584

def get_templates_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.get_templates ...'
  end
  allowable_values = ["definition"]
  if @api_client.config.client_side_validation && opts[:'additional_fields_template'] && !opts[:'additional_fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"additional_fields_template\", must include one of #{allowable_values}"
  end
  allowable_values = ["amp", "created", "definition", "definition.body", "definition.body.id", "definition.body.properties", "definition.body.properties.css_class", "definition.body.properties.id", "definition.body.sections", "definition.body.styles", "definition.body.styles.background_color", "definition.body.styles.width", "definition.id", "definition.styles", "definition.template_id", "editor_type", "html", "name", "text", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}"
  end
  allowable_values = ["created", "-created", "id", "-id", "name", "-name", "updated", "-updated"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/templates'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'additional-fields[template]'] = @api_client.build_collection_param(opts[:'additional_fields_template'], :csv) if !opts[:'additional_fields_template'].nil?
  query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.get_templates",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#get_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_universal_content(id, opts = {}) ⇒ Hash<String, Object>

Get Universal Content Get the universal content with the given ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:read`

Parameters:

  • id (String)

    The ID of the universal content

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


653
654
655
656
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 653

def get_universal_content(id, opts = {})
  data, _status_code, _headers = get_universal_content_with_http_info(id, opts)
  data
end

#get_universal_content_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Universal Content Get the universal content with the given ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • id (String)

    The ID of the universal content

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 664

def get_universal_content_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.get_universal_content ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.get_universal_content"
  end
  allowable_values = ["created", "definition", "definition.content_type", "definition.data", "definition.data.content", "definition.data.display_options", "definition.data.display_options.content_repeat", "definition.data.display_options.content_repeat.item_alias", "definition.data.display_options.content_repeat.repeat_for", "definition.data.display_options.show_on", "definition.data.display_options.visible_check", "definition.data.styles", "definition.data.styles.background_color", "definition.data.styles.block_background_color", "definition.data.styles.block_border_color", "definition.data.styles.block_border_style", "definition.data.styles.block_border_width", "definition.data.styles.block_padding_bottom", "definition.data.styles.block_padding_left", "definition.data.styles.block_padding_right", "definition.data.styles.block_padding_top", "definition.data.styles.color", "definition.data.styles.extra_css_class", "definition.data.styles.font_family", "definition.data.styles.font_size", "definition.data.styles.font_style", "definition.data.styles.font_weight", "definition.data.styles.inner_padding_bottom", "definition.data.styles.inner_padding_left", "definition.data.styles.inner_padding_right", "definition.data.styles.inner_padding_top", "definition.data.styles.letter_spacing", "definition.data.styles.line_height", "definition.data.styles.mobile_stretch_content", "definition.data.styles.text_align", "definition.data.styles.text_decoration", "definition.data.styles.text_table_layout", "definition.type", "name", "screenshot_status", "screenshot_url", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template_universal_content'] && !opts[:'fields_template_universal_content'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template_universal_content\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/template-universal-content/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[template-universal-content]'] = @api_client.build_collection_param(opts[:'fields_template_universal_content'], :csv) if !opts[:'fields_template_universal_content'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.get_universal_content",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#get_universal_content\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#render_template(template_render_query, opts = {}) ⇒ Hash<String, Object> Also known as: create_template_render

Render Template Render a template with the given template ID and context attribute. Returns the AMP, HTML, and plain text versions of the email template. **Request body parameters** (nested under ‘attributes`): * `return_fields`: Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets). * `context`: This is the context your email template will be rendered with. You must pass in a `context` object as a JSON object. Email templates are rendered with contexts in a similar manner to Django templates. Nested template variables can be referenced via dot notation. Template variables without corresponding `context` values are treated as `FALSE` and output nothing. Ex. `{ "name" : "George Washington", "state" : "VA" }`
*Rate limits*:
Burst: `3/s`
Steady: `60/m` Scopes: `templates:read`

Parameters:

  • template_render_query (TemplateRenderQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


724
725
726
727
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 724

def render_template(template_render_query, opts = {})
  data, _status_code, _headers = render_template_with_http_info(template_render_query, opts)
  data
end

#render_template_with_http_info(template_render_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: create_template_render_with_http_info

Render Template Render a template with the given template ID and context attribute. Returns the AMP, HTML, and plain text versions of the email template. **Request body parameters** (nested under &#x60;attributes&#x60;): * &#x60;return_fields&#x60;: Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets). * &#x60;context&#x60;: This is the context your email template will be rendered with. You must pass in a &#x60;context&#x60; object as a JSON object. Email templates are rendered with contexts in a similar manner to Django templates. Nested template variables can be referenced via dot notation. Template variables without corresponding &#x60;context&#x60; values are treated as &#x60;FALSE&#x60; and output nothing. Ex. &#x60;{ &quot;name&quot; : &quot;George Washington&quot;, &quot;state&quot; : &quot;VA&quot; }&#x60;&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • template_render_query (TemplateRenderQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 737

def render_template_with_http_info(template_render_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.render_template ...'
  end
  # verify the required parameter 'template_render_query' is set
  if @api_client.config.client_side_validation && template_render_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_render_query' when calling TemplatesApi.render_template"
  end
  # resource path
  local_var_path = '/api/template-render'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_render_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.render_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#render_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_template(id, template_update_html_or_dnd_query, opts = {}) ⇒ Hash<String, Object>

Update Template Update a template with the given template ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `750/m` Scopes: `templates:write`

Parameters:

  • id (String)

    The ID of template

  • template_update_html_or_dnd_query (TemplateUpdateHtmlOrDndQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :additional_fields_template (Array<String>)

    Request additional fields not included by default in the response. Supported values: &#39;definition&#39;

Returns:

  • (Hash<String, Object>)


802
803
804
805
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 802

def update_template(id, template_update_html_or_dnd_query, opts = {})
  data, _status_code, _headers = update_template_with_http_info(id, template_update_html_or_dnd_query, opts)
  data
end

#update_template_with_http_info(id, template_update_html_or_dnd_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Update Template Update a template with the given template ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

  • id (String)

    The ID of template

  • template_update_html_or_dnd_query (TemplateUpdateHtmlOrDndQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :additional_fields_template (Array<String>)

    Request additional fields not included by default in the response. Supported values: &#39;definition&#39;

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 814

def update_template_with_http_info(id, template_update_html_or_dnd_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.update_template ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.update_template"
  end
  # verify the required parameter 'template_update_html_or_dnd_query' is set
  if @api_client.config.client_side_validation && template_update_html_or_dnd_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_update_html_or_dnd_query' when calling TemplatesApi.update_template"
  end
  allowable_values = ["definition"]
  if @api_client.config.client_side_validation && opts[:'additional_fields_template'] && !opts[:'additional_fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"additional_fields_template\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/templates/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'additional-fields[template]'] = @api_client.build_collection_param(opts[:'additional_fields_template'], :csv) if !opts[:'additional_fields_template'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_update_html_or_dnd_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.update_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#update_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_universal_content(id, universal_content_partial_update_query, opts = {}) ⇒ Hash<String, Object> Also known as: update_template_universal_content

Update Universal Content Update universal content. The ‘definition` field can only be updated on the following block types at this time: `button`, `drop_shadow`, `horizontal_rule`, `html`, `image`, `spacer`, and `text`.
*Rate limits*:
Burst: `75/s`
Steady: `750/m` Scopes: `templates:write`

Parameters:

  • id (String)

    The ID of the template universal content

  • universal_content_partial_update_query (UniversalContentPartialUpdateQuery)

    Update a universal content by ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


884
885
886
887
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 884

def update_universal_content(id, universal_content_partial_update_query, opts = {})
  data, _status_code, _headers = update_universal_content_with_http_info(id, universal_content_partial_update_query, opts)
  data
end

#update_universal_content_with_http_info(id, universal_content_partial_update_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: update_template_universal_content_with_http_info

Update Universal Content Update universal content. The &#x60;definition&#x60; field can only be updated on the following block types at this time: &#x60;button&#x60;, &#x60;drop_shadow&#x60;, &#x60;horizontal_rule&#x60;, &#x60;html&#x60;, &#x60;image&#x60;, &#x60;spacer&#x60;, and &#x60;text&#x60;.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;750/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

  • id (String)

    The ID of the template universal content

  • universal_content_partial_update_query (UniversalContentPartialUpdateQuery)

    Update a universal content by ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 898

def update_universal_content_with_http_info(id, universal_content_partial_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.update_universal_content ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.update_universal_content"
  end
  # verify the required parameter 'universal_content_partial_update_query' is set
  if @api_client.config.client_side_validation && universal_content_partial_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'universal_content_partial_update_query' when calling TemplatesApi.update_universal_content"
  end
  # resource path
  local_var_path = '/api/template-universal-content/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2026-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(universal_content_partial_update_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.update_universal_content",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#update_universal_content\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end