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.


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

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.


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

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: ‘10/s`
Steady: `150/m` Scopes: `templates:write`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)

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

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;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


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
93
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 40

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'] || "2025-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_query, opts = {}) ⇒ Hash<String, Object>

Create Template Create a new custom HTML 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: ‘10/s`
Steady: `150/m` Scopes: `templates:write`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)

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

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

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

Create Template Create a new custom HTML 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;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

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

    the optional parameters

Returns:

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

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


113
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 113

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

  # 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'] || "2025-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_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. Only text blocks, which can include text or HTML, are supported at this time.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/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>)

173
174
175
176
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 173

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. Only text blocks, which can include text or HTML, are supported at this time.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


186
187
188
189
190
191
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 186

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'] || "2025-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: ‘10/s`
Steady: `150/m` Scopes: `templates:write`

Parameters:

  • id (String)

    The ID of template

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

    the optional parameters

Returns:

  • (nil)

249
250
251
252
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 249

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;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


259
260
261
262
263
264
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 259

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'] || "2025-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: ‘10/s`
Steady: `150/m` Scopes: `templates:write`

Parameters:

  • id (String)

    The ID of the template universal content

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

    the optional parameters

Returns:

  • (nil)

314
315
316
317
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 314

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;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


327
328
329
330
331
332
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 327

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'] || "2025-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: ‘10/s`
Steady: `150/m` Scopes: `templates:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)

389
390
391
392
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 389

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;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


406
407
408
409
410
411
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 406

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 = ["name", "definition", "definition.content_type", "definition.type", "definition.data", "definition.data.content", "definition.data.display_options", "definition.data.display_options.show_on", "definition.data.display_options.visible_check", "definition.data.display_options.content_repeat", "definition.data.display_options.content_repeat.repeat_for", "definition.data.display_options.content_repeat.item_alias", "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", "created", "updated", "screenshot_status", "screenshot_url"]
  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'] || "2025-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: ‘10/s`
Steady: `150/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>)

482
483
484
485
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 482

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;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


493
494
495
496
497
498
499
500
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 493

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 = ["name", "editor_type", "html", "text", "amp", "created", "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[:'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'] || "2025-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. Filter to request a subset of all templates. Templates can be sorted by the following fields, in ascending and descending order: ‘id`, `name`, `created`, `updated` Returns a maximum of 10 results per page.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `templates:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)

556
557
558
559
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 556

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. Filter to request a subset of all templates. Templates can be sorted by the following fields, in ascending and descending order: &#x60;id&#x60;, &#x60;name&#x60;, &#x60;created&#x60;, &#x60;updated&#x60; Returns a maximum of 10 results per page.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 569

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 = ["name", "editor_type", "html", "text", "amp", "created", "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[:'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'] || "2025-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: ‘10/s`
Steady: `150/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>)

633
634
635
636
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 633

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;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 644

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 = ["name", "definition", "definition.content_type", "definition.type", "definition.data", "definition.data.content", "definition.data.display_options", "definition.data.display_options.show_on", "definition.data.display_options.visible_check", "definition.data.display_options.content_repeat", "definition.data.display_options.content_repeat.repeat_for", "definition.data.display_options.content_repeat.item_alias", "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", "created", "updated", "screenshot_status", "screenshot_url"]
  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'] || "2025-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>)

704
705
706
707
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 704

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


717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 717

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'] || "2025-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_query, opts = {}) ⇒ Hash<String, Object>

Update Template Update a template with the given template ID. Does not currently update drag & drop templates.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `templates:write`

Parameters:

  • id (String)

    The ID of template

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

    the optional parameters

Returns:

  • (Hash<String, Object>)

781
782
783
784
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 781

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

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

Update Template Update a template with the given template ID. Does not currently update drag &amp; drop templates.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;templates:write&#x60;

Parameters:

  • id (String)

    The ID of template

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

    the optional parameters

Returns:

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

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


792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 792

def update_template_with_http_info(id, template_update_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_query' is set
  if @api_client.config.client_side_validation && template_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_update_query' when calling TemplatesApi.update_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'] || "2025-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_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 for text blocks at this time.
*Rate limits*:
Burst: `10/s`
Steady: `150/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>)

857
858
859
860
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 857

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 for text blocks at this time.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/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


871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
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
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 871

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'] || "2025-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