=begin #Klaviyo API #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details. The version of the OpenAPI document: 2025-01-15 Contact: developers@klaviyo.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module KlaviyoAPI class TagsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Tag # Create a tag. An account cannot have more than **500** unique tags. A tag belongs to a single tag group. If the `tag_group_id` is not specified, the tag is added to the account's default tag group.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param tag_create_query [TagCreateQuery] # @param [Hash] opts the optional parameters # @return [Hash] def create_tag(tag_create_query, opts = {}) data, _status_code, _headers = create_tag_with_http_info(tag_create_query, opts) data end # Create Tag # Create a tag. An account cannot have more than **500** unique tags. A tag belongs to a single tag group. If the `tag_group_id` is not specified, the tag is added to the account's default tag group.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param tag_create_query [TagCreateQuery] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_tag_with_http_info(tag_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.create_tag ...' end # verify the required parameter 'tag_create_query' is set if @api_client.config.client_side_validation && tag_create_query.nil? fail ArgumentError, "Missing the required parameter 'tag_create_query' when calling TagsApi.create_tag" end # resource path local_var_path = '/api/tags' # 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-01-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(tag_create_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.create_tag", :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: TagsApi#create_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Tag Group # Create a tag group. An account cannot have more than **50** unique tag groups. If `exclusive` is not specified `true` or `false`, the tag group defaults to non-exclusive. If a tag group is non-exclusive, any given related resource (campaign, flow, etc.) can be linked to multiple tags from that tag group. If a tag group is exclusive, any given related resource can only be linked to one tag from that tag group.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param tag_group_create_query [TagGroupCreateQuery] # @param [Hash] opts the optional parameters # @return [Hash] def create_tag_group(tag_group_create_query, opts = {}) data, _status_code, _headers = create_tag_group_with_http_info(tag_group_create_query, opts) data end # Create Tag Group # Create a tag group. An account cannot have more than **50** unique tag groups. If `exclusive` is not specified `true` or `false`, the tag group defaults to non-exclusive. If a tag group is non-exclusive, any given related resource (campaign, flow, etc.) can be linked to multiple tags from that tag group. If a tag group is exclusive, any given related resource can only be linked to one tag from that tag group.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param tag_group_create_query [TagGroupCreateQuery] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_tag_group_with_http_info(tag_group_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.create_tag_group ...' end # verify the required parameter 'tag_group_create_query' is set if @api_client.config.client_side_validation && tag_group_create_query.nil? fail ArgumentError, "Missing the required parameter 'tag_group_create_query' when calling TagsApi.create_tag_group" end # resource path local_var_path = '/api/tag-groups' # 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-01-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(tag_group_create_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.create_tag_group", :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: TagsApi#create_tag_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Tag # Delete the tag with the given tag ID. Any associations between the tag and other resources will also be removed.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [nil] def delete_tag(id, opts = {}) delete_tag_with_http_info(id, opts) nil end # Delete Tag # Delete the tag with the given tag ID. Any associations between the tag and other resources will also be removed.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.delete_tag ...' 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 TagsApi.delete_tag" end # resource path local_var_path = '/api/tags/{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-01-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 => :"TagsApi.delete_tag", :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: TagsApi#delete_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Tag Group # Delete the tag group with the given tag group ID. Any tags inside that tag group, and any associations between those tags and other resources, will also be removed. The default tag group cannot be deleted.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @return [Hash] def delete_tag_group(id, opts = {}) data, _status_code, _headers = delete_tag_group_with_http_info(id, opts) data end # Delete Tag Group # Delete the tag group with the given tag group ID. Any tags inside that tag group, and any associations between those tags and other resources, will also be removed. The default tag group cannot be deleted.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def delete_tag_group_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.delete_tag_group ...' 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 TagsApi.delete_tag_group" end # resource path local_var_path = '/api/tag-groups/{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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.delete_tag_group", :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: TagsApi#delete_tag_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign IDs for Tag # Returns the IDs of all campaigns associated with the given tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Hash] def get_campaign_ids_for_tag(id, opts = {}) data, _status_code, _headers = get_campaign_ids_for_tag_with_http_info(id, opts) data end # alias of `get_campaign_ids_for_tag` alias get_tag_relationships_campaigns get_campaign_ids_for_tag # Get Campaign IDs for Tag # Returns the IDs of all campaigns associated with the given tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `campaigns:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_campaign_ids_for_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_campaign_ids_for_tag ...' 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 TagsApi.get_campaign_ids_for_tag" end # resource path local_var_path = '/api/tags/{id}/relationships/campaigns'.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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_campaign_ids_for_tag", :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: TagsApi#get_campaign_ids_for_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_campaign_ids_for_tag_with_http_info` alias get_tag_relationships_campaigns_with_http_info get_campaign_ids_for_tag_with_http_info # Get Flow IDs for Tag # Returns the IDs of all flows associated with the given tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `flows:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Hash] def get_flow_ids_for_tag(id, opts = {}) data, _status_code, _headers = get_flow_ids_for_tag_with_http_info(id, opts) data end # alias of `get_flow_ids_for_tag` alias get_tag_relationships_flows get_flow_ids_for_tag # Get Flow IDs for Tag # Returns the IDs of all flows associated with the given tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `flows:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_flow_ids_for_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_flow_ids_for_tag ...' 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 TagsApi.get_flow_ids_for_tag" end # resource path local_var_path = '/api/tags/{id}/relationships/flows'.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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_flow_ids_for_tag", :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: TagsApi#get_flow_ids_for_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_flow_ids_for_tag_with_http_info` alias get_tag_relationships_flows_with_http_info get_flow_ids_for_tag_with_http_info # Get List IDs for Tag # Returns the IDs of all lists associated with the given tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `lists:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Hash] def get_list_ids_for_tag(id, opts = {}) data, _status_code, _headers = get_list_ids_for_tag_with_http_info(id, opts) data end # alias of `get_list_ids_for_tag` alias get_tag_relationships_lists get_list_ids_for_tag # Get List IDs for Tag # Returns the IDs of all lists associated with the given tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `lists:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_list_ids_for_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_list_ids_for_tag ...' 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 TagsApi.get_list_ids_for_tag" end # resource path local_var_path = '/api/tags/{id}/relationships/lists'.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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_list_ids_for_tag", :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: TagsApi#get_list_ids_for_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_list_ids_for_tag_with_http_info` alias get_tag_relationships_lists_with_http_info get_list_ids_for_tag_with_http_info # Get Segment IDs for Tag # Returns the IDs of all segments associated with the given tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `segments:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Hash] def get_segment_ids_for_tag(id, opts = {}) data, _status_code, _headers = get_segment_ids_for_tag_with_http_info(id, opts) data end # alias of `get_segment_ids_for_tag` alias get_tag_relationships_segments get_segment_ids_for_tag # Get Segment IDs for Tag # Returns the IDs of all segments associated with the given tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `segments:read` `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_segment_ids_for_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_segment_ids_for_tag ...' 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 TagsApi.get_segment_ids_for_tag" end # resource path local_var_path = '/api/tags/{id}/relationships/segments'.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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_segment_ids_for_tag", :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: TagsApi#get_segment_ids_for_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_segment_ids_for_tag_with_http_info` alias get_tag_relationships_segments_with_http_info get_segment_ids_for_tag_with_http_info # Get Tag # Retrieve the tag with the given tag ID.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#relationships # @return [Hash] def get_tag(id, opts = {}) data, _status_code, _headers = get_tag_with_http_info(id, opts) data end # Get Tag # Retrieve the tag with the given tag ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#relationships # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tag ...' 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 TagsApi.get_tag" end allowable_values = ["name", "exclusive", "default"] if @api_client.config.client_side_validation && opts[:'fields_tag_group'] && !opts[:'fields_tag_group'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag_group\", must include one of #{allowable_values}" end allowable_values = ["name"] if @api_client.config.client_side_validation && opts[:'fields_tag'] && !opts[:'fields_tag'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag\", must include one of #{allowable_values}" end allowable_values = ["tag-group"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/tags/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[tag-group]'] = @api_client.build_collection_param(opts[:'fields_tag_group'], :csv) if !opts[:'fields_tag_group'].nil? query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tag", :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: TagsApi#get_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Tag Group # Retrieve the tag group with the given tag group ID.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_tag_group(id, opts = {}) data, _status_code, _headers = get_tag_group_with_http_info(id, opts) data end # Get Tag Group # Retrieve the tag group with the given tag group ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tag_group_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tag_group ...' 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 TagsApi.get_tag_group" end allowable_values = ["name", "exclusive", "default"] if @api_client.config.client_side_validation && opts[:'fields_tag_group'] && !opts[:'fields_tag_group'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag_group\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/tag-groups/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[tag-group]'] = @api_client.build_collection_param(opts[:'fields_tag_group'], :csv) if !opts[:'fields_tag_group'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tag_group", :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: TagsApi#get_tag_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Tag Group for Tag # Returns the tag group resource for a given tag ID.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_tag_group_for_tag(id, opts = {}) data, _status_code, _headers = get_tag_group_for_tag_with_http_info(id, opts) data end # alias of `get_tag_group_for_tag` alias get_tag_tag_group get_tag_group_for_tag # alias of `get_tag_group_for_tag` alias get_group_for_tag get_tag_group_for_tag # Get Tag Group for Tag # Returns the tag group resource for a given tag ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tag_group_for_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tag_group_for_tag ...' 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 TagsApi.get_tag_group_for_tag" end allowable_values = ["name", "exclusive", "default"] if @api_client.config.client_side_validation && opts[:'fields_tag_group'] && !opts[:'fields_tag_group'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag_group\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/tags/{id}/tag-group'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[tag-group]'] = @api_client.build_collection_param(opts[:'fields_tag_group'], :csv) if !opts[:'fields_tag_group'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tag_group_for_tag", :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: TagsApi#get_tag_group_for_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_tag_group_for_tag_with_http_info` alias get_tag_tag_group_with_http_info get_tag_group_for_tag_with_http_info # alias of `get_tag_group_for_tag_with_http_info` alias get_group_for_tag_with_http_info get_tag_group_for_tag_with_http_info # Get Tag Group ID for Tag # Returns the id of the tag group related to the given tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Hash] def get_tag_group_id_for_tag(id, opts = {}) data, _status_code, _headers = get_tag_group_id_for_tag_with_http_info(id, opts) data end # alias of `get_tag_group_id_for_tag` alias get_tag_relationships_tag_group get_tag_group_id_for_tag # alias of `get_tag_group_id_for_tag` alias get_group_id_for_tag get_tag_group_id_for_tag # alias of `get_tag_group_id_for_tag` alias get_tag_relationships_group get_tag_group_id_for_tag # Get Tag Group ID for Tag # Returns the id of the tag group related to the given tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag ID # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tag_group_id_for_tag_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tag_group_id_for_tag ...' 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 TagsApi.get_tag_group_id_for_tag" end # resource path local_var_path = '/api/tags/{id}/relationships/tag-group'.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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tag_group_id_for_tag", :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: TagsApi#get_tag_group_id_for_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_tag_group_id_for_tag_with_http_info` alias get_tag_relationships_tag_group_with_http_info get_tag_group_id_for_tag_with_http_info # alias of `get_tag_group_id_for_tag_with_http_info` alias get_group_id_for_tag_with_http_info get_tag_group_id_for_tag_with_http_info # alias of `get_tag_group_id_for_tag_with_http_info` alias get_tag_relationships_group_with_http_info get_tag_group_id_for_tag_with_http_info # Get Tag Groups # List all tag groups in an account. Every account has one default tag group. Tag groups can be filtered by `name`, `exclusive`, and `default`, and sorted by `name` or `id` in ascending or descending order. Returns a maximum of 25 tag groups per request, which can be paginated with [cursor-based pagination](https://developers.klaviyo.com/en/v2022-10-17/reference/api_overview#pagination).

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`exclusive`: `equals`<br>`default`: `equals` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sorting # @return [Hash] def get_tag_groups(opts = {}) data, _status_code, _headers = get_tag_groups_with_http_info(opts) data end # Get Tag Groups # List all tag groups in an account. Every account has one default tag group. Tag groups can be filtered by `name`, `exclusive`, and `default`, and sorted by `name` or `id` in ascending or descending order. Returns a maximum of 25 tag groups per request, which can be paginated with [cursor-based pagination](https://developers.klaviyo.com/en/v2022-10-17/reference/api_overview#pagination).<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `contains`, `ends-with`, `equals`, `starts-with`<br>`exclusive`: `equals`<br>`default`: `equals` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sorting # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tag_groups_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tag_groups ...' end allowable_values = ["name", "exclusive", "default"] if @api_client.config.client_side_validation && opts[:'fields_tag_group'] && !opts[:'fields_tag_group'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag_group\", must include one of #{allowable_values}" end allowable_values = ["id", "-id", "name", "-name"] 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/tag-groups' # query parameters query_params = opts[:query_params] || {} query_params[:'fields[tag-group]'] = @api_client.build_collection_param(opts[:'fields_tag_group'], :csv) if !opts[:'fields_tag_group'].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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tag_groups", :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: TagsApi#get_tag_groups\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Tag IDs for Tag Group # Returns the tag IDs of all tags inside the given tag group.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @return [Hash] def get_tag_ids_for_tag_group(id, opts = {}) data, _status_code, _headers = get_tag_ids_for_tag_group_with_http_info(id, opts) data end # alias of `get_tag_ids_for_tag_group` alias get_tag_group_relationships_tags get_tag_ids_for_tag_group # Get Tag IDs for Tag Group # Returns the tag IDs of all tags inside the given tag group.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tag_ids_for_tag_group_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tag_ids_for_tag_group ...' 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 TagsApi.get_tag_ids_for_tag_group" end # resource path local_var_path = '/api/tag-groups/{id}/relationships/tags'.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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tag_ids_for_tag_group", :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: TagsApi#get_tag_ids_for_tag_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_tag_ids_for_tag_group_with_http_info` alias get_tag_group_relationships_tags_with_http_info get_tag_ids_for_tag_group_with_http_info # Get Tags # List all tags in an account. Tags can be filtered by `name`, and sorted by `name` or `id` in ascending or descending order. Returns a maximum of 50 tags per request, which can be paginated with [cursor-based pagination](https://developers.klaviyo.com/en/v2022-10-17/reference/api_overview#pagination).

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `contains`, `ends-with`, `equals`, `starts-with` # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#relationships # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sorting # @return [Hash] def get_tags(opts = {}) data, _status_code, _headers = get_tags_with_http_info(opts) data end # Get Tags # List all tags in an account. Tags can be filtered by `name`, and sorted by `name` or `id` in ascending or descending order. Returns a maximum of 50 tags per request, which can be paginated with [cursor-based pagination](https://developers.klaviyo.com/en/v2022-10-17/reference/api_overview#pagination).<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag_group For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `contains`, `ends-with`, `equals`, `starts-with` # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#relationships # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sorting # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tags_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tags ...' end allowable_values = ["name", "exclusive", "default"] if @api_client.config.client_side_validation && opts[:'fields_tag_group'] && !opts[:'fields_tag_group'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag_group\", must include one of #{allowable_values}" end allowable_values = ["name"] if @api_client.config.client_side_validation && opts[:'fields_tag'] && !opts[:'fields_tag'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag\", must include one of #{allowable_values}" end allowable_values = ["tag-group"] if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}" end allowable_values = ["id", "-id", "name", "-name"] 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/tags' # query parameters query_params = opts[:query_params] || {} query_params[:'fields[tag-group]'] = @api_client.build_collection_param(opts[:'fields_tag_group'], :csv) if !opts[:'fields_tag_group'].nil? query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil? query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil? query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].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-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tags", :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: TagsApi#get_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Tags for Tag Group # Return the tags for a given tag group ID.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_tags_for_tag_group(id, opts = {}) data, _status_code, _headers = get_tags_for_tag_group_with_http_info(id, opts) data end # alias of `get_tags_for_tag_group` alias get_tag_group_tags get_tags_for_tag_group # Get Tags for Tag Group # Return the tags for a given tag group ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` # @param id [String] The Tag Group ID # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2025-01-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tags_for_tag_group_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.get_tags_for_tag_group ...' 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 TagsApi.get_tags_for_tag_group" end allowable_values = ["name"] if @api_client.config.client_side_validation && opts[:'fields_tag'] && !opts[:'fields_tag'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_tag\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/tag-groups/{id}/tags'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-01-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' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.get_tags_for_tag_group", :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: TagsApi#get_tags_for_tag_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_tags_for_tag_group_with_http_info` alias get_tag_group_tags_with_http_info get_tags_for_tag_group_with_http_info # Remove Tag from Campaigns # Remove a tag's association with one or more campaigns. Use the request body to pass in the ID(s) of the campaign(s) whose association with the tag will be removed.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:write` `tags:write` # @param id [String] The Tag ID # @param tag_campaign_op [TagCampaignOp] # @param [Hash] opts the optional parameters # @return [nil] def remove_tag_from_campaigns(id, tag_campaign_op, opts = {}) remove_tag_from_campaigns_with_http_info(id, tag_campaign_op, opts) nil end # alias of `remove_tag_from_campaigns` alias delete_tag_relationships_campaigns remove_tag_from_campaigns # alias of `remove_tag_from_campaigns` alias remove_campaigns_from_tag remove_tag_from_campaigns # Remove Tag from Campaigns # Remove a tag's association with one or more campaigns. Use the request body to pass in the ID(s) of the campaign(s) whose association with the tag will be removed.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `campaigns:write` `tags:write` # @param id [String] The Tag ID # @param tag_campaign_op [TagCampaignOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def remove_tag_from_campaigns_with_http_info(id, tag_campaign_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.remove_tag_from_campaigns ...' 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 TagsApi.remove_tag_from_campaigns" end # verify the required parameter 'tag_campaign_op' is set if @api_client.config.client_side_validation && tag_campaign_op.nil? fail ArgumentError, "Missing the required parameter 'tag_campaign_op' when calling TagsApi.remove_tag_from_campaigns" end # resource path local_var_path = '/api/tags/{id}/relationships/campaigns'.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-01-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(tag_campaign_op) # 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 => :"TagsApi.remove_tag_from_campaigns", :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: TagsApi#remove_tag_from_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `remove_tag_from_campaigns_with_http_info` alias delete_tag_relationships_campaigns_with_http_info remove_tag_from_campaigns_with_http_info # alias of `remove_tag_from_campaigns_with_http_info` alias remove_campaigns_from_tag_with_http_info remove_tag_from_campaigns_with_http_info # Remove Tag from Flows # Remove a tag's association with one or more flows. Use the request body to pass in the ID(s) of the flows(s) whose association with the tag will be removed.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `flows:write` `tags:write` # @param id [String] The Tag ID # @param tag_flow_op [TagFlowOp] # @param [Hash] opts the optional parameters # @return [nil] def remove_tag_from_flows(id, tag_flow_op, opts = {}) remove_tag_from_flows_with_http_info(id, tag_flow_op, opts) nil end # alias of `remove_tag_from_flows` alias delete_tag_relationships_flows remove_tag_from_flows # alias of `remove_tag_from_flows` alias remove_flows_from_tag remove_tag_from_flows # Remove Tag from Flows # Remove a tag's association with one or more flows. Use the request body to pass in the ID(s) of the flows(s) whose association with the tag will be removed.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `flows:write` `tags:write` # @param id [String] The Tag ID # @param tag_flow_op [TagFlowOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def remove_tag_from_flows_with_http_info(id, tag_flow_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.remove_tag_from_flows ...' 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 TagsApi.remove_tag_from_flows" end # verify the required parameter 'tag_flow_op' is set if @api_client.config.client_side_validation && tag_flow_op.nil? fail ArgumentError, "Missing the required parameter 'tag_flow_op' when calling TagsApi.remove_tag_from_flows" end # resource path local_var_path = '/api/tags/{id}/relationships/flows'.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-01-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(tag_flow_op) # 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 => :"TagsApi.remove_tag_from_flows", :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: TagsApi#remove_tag_from_flows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `remove_tag_from_flows_with_http_info` alias delete_tag_relationships_flows_with_http_info remove_tag_from_flows_with_http_info # alias of `remove_tag_from_flows_with_http_info` alias remove_flows_from_tag_with_http_info remove_tag_from_flows_with_http_info # Remove Tag from Lists # Remove a tag's association with one or more lists. Use the request body to pass in the ID(s) of the list(s) whose association with the tag will be removed.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `lists:write` `tags:write` # @param id [String] The Tag ID # @param tag_list_op [TagListOp] # @param [Hash] opts the optional parameters # @return [nil] def remove_tag_from_lists(id, tag_list_op, opts = {}) remove_tag_from_lists_with_http_info(id, tag_list_op, opts) nil end # alias of `remove_tag_from_lists` alias delete_tag_relationships_lists remove_tag_from_lists # alias of `remove_tag_from_lists` alias remove_lists_from_tag remove_tag_from_lists # Remove Tag from Lists # Remove a tag's association with one or more lists. Use the request body to pass in the ID(s) of the list(s) whose association with the tag will be removed.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `lists:write` `tags:write` # @param id [String] The Tag ID # @param tag_list_op [TagListOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def remove_tag_from_lists_with_http_info(id, tag_list_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.remove_tag_from_lists ...' 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 TagsApi.remove_tag_from_lists" end # verify the required parameter 'tag_list_op' is set if @api_client.config.client_side_validation && tag_list_op.nil? fail ArgumentError, "Missing the required parameter 'tag_list_op' when calling TagsApi.remove_tag_from_lists" end # resource path local_var_path = '/api/tags/{id}/relationships/lists'.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-01-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(tag_list_op) # 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 => :"TagsApi.remove_tag_from_lists", :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: TagsApi#remove_tag_from_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `remove_tag_from_lists_with_http_info` alias delete_tag_relationships_lists_with_http_info remove_tag_from_lists_with_http_info # alias of `remove_tag_from_lists_with_http_info` alias remove_lists_from_tag_with_http_info remove_tag_from_lists_with_http_info # Remove Tag from Segments # Remove a tag's association with one or more segments. Use the request body to pass in the ID(s) of the segments(s) whose association with the tag will be removed.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `segments:write` `tags:write` # @param id [String] The Tag ID # @param tag_segment_op [TagSegmentOp] # @param [Hash] opts the optional parameters # @return [nil] def remove_tag_from_segments(id, tag_segment_op, opts = {}) remove_tag_from_segments_with_http_info(id, tag_segment_op, opts) nil end # alias of `remove_tag_from_segments` alias delete_tag_relationships_segments remove_tag_from_segments # alias of `remove_tag_from_segments` alias remove_segments_from_tag remove_tag_from_segments # Remove Tag from Segments # Remove a tag's association with one or more segments. Use the request body to pass in the ID(s) of the segments(s) whose association with the tag will be removed.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `segments:write` `tags:write` # @param id [String] The Tag ID # @param tag_segment_op [TagSegmentOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def remove_tag_from_segments_with_http_info(id, tag_segment_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.remove_tag_from_segments ...' 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 TagsApi.remove_tag_from_segments" end # verify the required parameter 'tag_segment_op' is set if @api_client.config.client_side_validation && tag_segment_op.nil? fail ArgumentError, "Missing the required parameter 'tag_segment_op' when calling TagsApi.remove_tag_from_segments" end # resource path local_var_path = '/api/tags/{id}/relationships/segments'.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-01-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(tag_segment_op) # 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 => :"TagsApi.remove_tag_from_segments", :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: TagsApi#remove_tag_from_segments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `remove_tag_from_segments_with_http_info` alias delete_tag_relationships_segments_with_http_info remove_tag_from_segments_with_http_info # alias of `remove_tag_from_segments_with_http_info` alias remove_segments_from_tag_with_http_info remove_tag_from_segments_with_http_info # Tag Campaigns # Associate a tag with one or more campaigns. Any campaign cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the campaign(s) that will be associated with the tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `campaigns:write` `tags:write` # @param id [String] The Tag ID # @param tag_campaign_op [TagCampaignOp] # @param [Hash] opts the optional parameters # @return [nil] def tag_campaigns(id, tag_campaign_op, opts = {}) tag_campaigns_with_http_info(id, tag_campaign_op, opts) nil end # alias of `tag_campaigns` alias create_tag_relationships_campaign tag_campaigns # alias of `tag_campaigns` alias add_campaigns_to_tag tag_campaigns # alias of `tag_campaigns` alias create_tag_relationships_campaigns tag_campaigns # Tag Campaigns # Associate a tag with one or more campaigns. Any campaign cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the campaign(s) that will be associated with the tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `campaigns:write` `tags:write` # @param id [String] The Tag ID # @param tag_campaign_op [TagCampaignOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def tag_campaigns_with_http_info(id, tag_campaign_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.tag_campaigns ...' 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 TagsApi.tag_campaigns" end # verify the required parameter 'tag_campaign_op' is set if @api_client.config.client_side_validation && tag_campaign_op.nil? fail ArgumentError, "Missing the required parameter 'tag_campaign_op' when calling TagsApi.tag_campaigns" end # resource path local_var_path = '/api/tags/{id}/relationships/campaigns'.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-01-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(tag_campaign_op) # 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 => :"TagsApi.tag_campaigns", :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: TagsApi#tag_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `tag_campaigns_with_http_info` alias create_tag_relationships_campaign_with_http_info tag_campaigns_with_http_info # alias of `tag_campaigns_with_http_info` alias add_campaigns_to_tag_with_http_info tag_campaigns_with_http_info # alias of `tag_campaigns_with_http_info` alias create_tag_relationships_campaigns_with_http_info tag_campaigns_with_http_info # Tag Flows # Associate a tag with one or more flows. Any flow cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the flow(s) that will be associated with the tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `flows:write` `tags:write` # @param id [String] The Tag ID # @param tag_flow_op [TagFlowOp] # @param [Hash] opts the optional parameters # @return [nil] def tag_flows(id, tag_flow_op, opts = {}) tag_flows_with_http_info(id, tag_flow_op, opts) nil end # alias of `tag_flows` alias create_tag_relationships_flow tag_flows # alias of `tag_flows` alias add_flows_to_tag tag_flows # alias of `tag_flows` alias create_tag_relationships_flows tag_flows # Tag Flows # Associate a tag with one or more flows. Any flow cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the flow(s) that will be associated with the tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `flows:write` `tags:write` # @param id [String] The Tag ID # @param tag_flow_op [TagFlowOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def tag_flows_with_http_info(id, tag_flow_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.tag_flows ...' 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 TagsApi.tag_flows" end # verify the required parameter 'tag_flow_op' is set if @api_client.config.client_side_validation && tag_flow_op.nil? fail ArgumentError, "Missing the required parameter 'tag_flow_op' when calling TagsApi.tag_flows" end # resource path local_var_path = '/api/tags/{id}/relationships/flows'.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-01-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(tag_flow_op) # 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 => :"TagsApi.tag_flows", :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: TagsApi#tag_flows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `tag_flows_with_http_info` alias create_tag_relationships_flow_with_http_info tag_flows_with_http_info # alias of `tag_flows_with_http_info` alias add_flows_to_tag_with_http_info tag_flows_with_http_info # alias of `tag_flows_with_http_info` alias create_tag_relationships_flows_with_http_info tag_flows_with_http_info # Tag Lists # Associate a tag with one or more lists. Any list cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the lists(s) that will be associated with the tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `lists:write` `tags:write` # @param id [String] The Tag ID # @param tag_list_op [TagListOp] # @param [Hash] opts the optional parameters # @return [nil] def tag_lists(id, tag_list_op, opts = {}) tag_lists_with_http_info(id, tag_list_op, opts) nil end # alias of `tag_lists` alias create_tag_relationships_list tag_lists # alias of `tag_lists` alias add_lists_to_tag tag_lists # alias of `tag_lists` alias create_tag_relationships_lists tag_lists # Tag Lists # Associate a tag with one or more lists. Any list cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the lists(s) that will be associated with the tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `lists:write` `tags:write` # @param id [String] The Tag ID # @param tag_list_op [TagListOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def tag_lists_with_http_info(id, tag_list_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.tag_lists ...' 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 TagsApi.tag_lists" end # verify the required parameter 'tag_list_op' is set if @api_client.config.client_side_validation && tag_list_op.nil? fail ArgumentError, "Missing the required parameter 'tag_list_op' when calling TagsApi.tag_lists" end # resource path local_var_path = '/api/tags/{id}/relationships/lists'.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-01-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(tag_list_op) # 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 => :"TagsApi.tag_lists", :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: TagsApi#tag_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `tag_lists_with_http_info` alias create_tag_relationships_list_with_http_info tag_lists_with_http_info # alias of `tag_lists_with_http_info` alias add_lists_to_tag_with_http_info tag_lists_with_http_info # alias of `tag_lists_with_http_info` alias create_tag_relationships_lists_with_http_info tag_lists_with_http_info # Tag Segments # Associate a tag with one or more segments. Any segment cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the segments(s) that will be associated with the tag.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `segments:write` `tags:write` # @param id [String] The Tag ID # @param tag_segment_op [TagSegmentOp] # @param [Hash] opts the optional parameters # @return [nil] def tag_segments(id, tag_segment_op, opts = {}) tag_segments_with_http_info(id, tag_segment_op, opts) nil end # alias of `tag_segments` alias create_tag_relationships_segment tag_segments # alias of `tag_segments` alias add_segments_to_tag tag_segments # alias of `tag_segments` alias create_tag_relationships_segments tag_segments # Tag Segments # Associate a tag with one or more segments. Any segment cannot be associated with more than **100** tags. Use the request body to pass in the ID(s) of the segments(s) that will be associated with the tag.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `segments:write` `tags:write` # @param id [String] The Tag ID # @param tag_segment_op [TagSegmentOp] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def tag_segments_with_http_info(id, tag_segment_op, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.tag_segments ...' 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 TagsApi.tag_segments" end # verify the required parameter 'tag_segment_op' is set if @api_client.config.client_side_validation && tag_segment_op.nil? fail ArgumentError, "Missing the required parameter 'tag_segment_op' when calling TagsApi.tag_segments" end # resource path local_var_path = '/api/tags/{id}/relationships/segments'.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-01-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(tag_segment_op) # 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 => :"TagsApi.tag_segments", :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: TagsApi#tag_segments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `tag_segments_with_http_info` alias create_tag_relationships_segment_with_http_info tag_segments_with_http_info # alias of `tag_segments_with_http_info` alias add_segments_to_tag_with_http_info tag_segments_with_http_info # alias of `tag_segments_with_http_info` alias create_tag_relationships_segments_with_http_info tag_segments_with_http_info # Update Tag # Update the tag with the given tag ID. Only a tag's `name` can be changed. A tag cannot be moved from one tag group to another.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag ID # @param tag_update_query [TagUpdateQuery] # @param [Hash] opts the optional parameters # @return [nil] def update_tag(id, tag_update_query, opts = {}) update_tag_with_http_info(id, tag_update_query, opts) nil end # Update Tag # Update the tag with the given tag ID. Only a tag's `name` can be changed. A tag cannot be moved from one tag group to another.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag ID # @param tag_update_query [TagUpdateQuery] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def update_tag_with_http_info(id, tag_update_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.update_tag ...' 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 TagsApi.update_tag" end # verify the required parameter 'tag_update_query' is set if @api_client.config.client_side_validation && tag_update_query.nil? fail ArgumentError, "Missing the required parameter 'tag_update_query' when calling TagsApi.update_tag" end # resource path local_var_path = '/api/tags/{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-01-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(tag_update_query) # 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 => :"TagsApi.update_tag", :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: TagsApi#update_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Tag Group # Update the tag group with the given tag group ID. Only a tag group's `name` can be changed. A tag group's `exclusive` or `default` value cannot be changed.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag Group ID # @param tag_group_update_query [TagGroupUpdateQuery] # @param [Hash] opts the optional parameters # @return [Hash] def update_tag_group(id, tag_group_update_query, opts = {}) data, _status_code, _headers = update_tag_group_with_http_info(id, tag_group_update_query, opts) data end # Update Tag Group # Update the tag group with the given tag group ID. Only a tag group's `name` can be changed. A tag group's `exclusive` or `default` value cannot be changed.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `tags:read` `tags:write` # @param id [String] The Tag Group ID # @param tag_group_update_query [TagGroupUpdateQuery] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def update_tag_group_with_http_info(id, tag_group_update_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TagsApi.update_tag_group ...' 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 TagsApi.update_tag_group" end # verify the required parameter 'tag_group_update_query' is set if @api_client.config.client_side_validation && tag_group_update_query.nil? fail ArgumentError, "Missing the required parameter 'tag_group_update_query' when calling TagsApi.update_tag_group" end # resource path local_var_path = '/api/tag-groups/{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-01-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(tag_group_update_query) # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth'] new_options = opts.merge( :operation => :"TagsApi.update_tag_group", :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: TagsApi#update_tag_group\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end