Class: KlaviyoAPI::TemplatesApi
- Inherits:
-
Object
- Object
- KlaviyoAPI::TemplatesApi
- Defined in:
- lib/klaviyo-api-sdk/api/templates_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#clone_template(template_clone_query, opts = {}) ⇒ Hash<String, Object>
(also: #create_template_clone)
Clone Template Create a clone of a template with the given template ID.
-
#clone_template_with_http_info(template_clone_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #create_template_clone_with_http_info)
Clone Template Create a clone of a template with the given template ID.
-
#create_template(template_create_query, opts = {}) ⇒ Hash<String, Object>
Create Template Create a new custom HTML template.
-
#create_template_with_http_info(template_create_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Create Template Create a new custom HTML template.
-
#create_universal_content(universal_content_create_query, opts = {}) ⇒ Hash<String, Object>
(also: #create_template_universal_content)
Create Universal Content Create universal content.
-
#create_universal_content_with_http_info(universal_content_create_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #create_template_universal_content_with_http_info)
Create Universal Content Create universal content.
-
#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`. -
#delete_template_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Delete Template Delete a template with the given template ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`.
-
#delete_universal_content(id, opts = {}) ⇒ nil
(also: #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`. -
#delete_universal_content_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>
(also: #delete_template_universal_content_with_http_info)
Delete Universal Content Delete the universal content with the given ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`.
-
#get_all_universal_content(opts = {}) ⇒ Hash<String, Object>
(also: #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`. -
#get_all_universal_content_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #get_template_universal_content_with_http_info)
Get All Universal Content Get all universal content in an account.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:read`.
-
#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`. -
#get_template_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Template Get a template with the given template ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:read`.
-
#get_templates(opts = {}) ⇒ Hash<String, Object>
Get Templates Get all templates in an account.
-
#get_templates_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Templates Get all templates in an account.
-
#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`. -
#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.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:read`.
-
#initialize(api_client = ApiClient.default) ⇒ TemplatesApi
constructor
A new instance of TemplatesApi.
-
#render_template(template_render_query, opts = {}) ⇒ Hash<String, Object>
(also: #create_template_render)
Render Template Render a template with the given template ID and context attribute.
-
#render_template_with_http_info(template_render_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #create_template_render_with_http_info)
Render Template Render a template with the given template ID and context attribute.
-
#update_template(id, template_update_query, opts = {}) ⇒ Hash<String, Object>
Update Template Update a template with the given template ID.
-
#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.
-
#update_universal_content(id, universal_content_partial_update_query, opts = {}) ⇒ Hash<String, Object>
(also: #update_template_universal_content)
Update Universal Content Update universal content.
-
#update_universal_content_with_http_info(id, universal_content_partial_update_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
(also: #update_template_universal_content_with_http_info)
Update Universal Content Update universal content.
Constructor Details
permalink #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
permalink #api_client ⇒ Object
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
permalink #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`
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 |
permalink #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.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`
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'] || "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'] = 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, ) 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 |
permalink #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`
102 103 104 105 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 102 def create_template(template_create_query, opts = {}) data, _status_code, _headers = create_template_with_http_info(template_create_query, opts) data end |
permalink #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).<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`
112 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 112 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'] = 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, ) 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 |
permalink #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`
172 173 174 175 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 172 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 |
permalink #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.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`
185 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 185 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'] = 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, ) 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 |
permalink #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`
248 249 250 251 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 248 def delete_template(id, opts = {}) delete_template_with_http_info(id, opts) nil end |
permalink #delete_template_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Delete Template Delete a template with the given template ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`
258 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 258 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'] = 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, ) 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 |
permalink #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`
313 314 315 316 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 313 def delete_universal_content(id, opts = {}) delete_universal_content_with_http_info(id, opts) nil end |
permalink #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.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`
326 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 326 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'] = 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, ) 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 |
permalink #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`
388 389 390 391 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 388 def get_all_universal_content(opts = {}) data, _status_code, _headers = get_all_universal_content_with_http_info(opts) data end |
permalink #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.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:read`
405 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 405 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'] = 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, ) 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 |
permalink #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`
481 482 483 484 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 481 def get_template(id, opts = {}) data, _status_code, _headers = get_template_with_http_info(id, opts) data end |
permalink #get_template_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>
Get Template Get a template with the given template ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:read`
492 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 492 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'] = 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, ) 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 |
permalink #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`
555 556 557 558 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 555 def get_templates(opts = {}) data, _status_code, _headers = get_templates_with_http_info(opts) data end |
permalink #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: `id`, `name`, `created`, `updated` Returns a maximum of 10 results per page.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:read`
568 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 568 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'] = 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, ) 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 |
permalink #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`
632 633 634 635 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 632 def get_universal_content(id, opts = {}) data, _status_code, _headers = get_universal_content_with_http_info(id, opts) data end |
permalink #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.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:read`
643 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 643 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'] = 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, ) 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 |
permalink #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`
703 704 705 706 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 703 def render_template(template_render_query, opts = {}) data, _status_code, _headers = render_template_with_http_info(template_render_query, opts) data end |
permalink #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 `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" }`<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` Scopes: `templates:read`
716 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 716 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'] = 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, ) 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 |
permalink #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`
780 781 782 783 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 780 def update_template(id, template_update_query, opts = {}) data, _status_code, _headers = update_template_with_http_info(id, template_update_query, opts) data end |
permalink #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 & drop templates.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`
791 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 791 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'] = 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, ) 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 |
permalink #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`
856 857 858 859 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 856 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 |
permalink #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 `definition` field can only be updated for text blocks at this time.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` Scopes: `templates:write`
870 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 |
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 870 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'] = 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, ) 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 |