=begin #Klaviyo API #The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details. The version of the OpenAPI document: 2024-10-15 Contact: developers@klaviyo.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module KlaviyoAPI class ListsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add Profiles to List # Add a profile to a list with the given list ID. It is recommended that you use the [Subscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/subscribe_profiles) if you're trying to give a profile [consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api) to receive email marketing, SMS marketing, or both. This endpoint accepts a maximum of 1000 profiles per call.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:write` `profiles:write` # @param id [String] # @param list_members_add_query [ListMembersAddQuery] # @param [Hash] opts the optional parameters # @return [nil] def add_profiles_to_list(id, list_members_add_query, opts = {}) add_profiles_to_list_with_http_info(id, list_members_add_query, opts) nil end # alias of `add_profiles_to_list` alias create_list_relationships add_profiles_to_list # alias of `add_profiles_to_list` alias create_list_relationships_profile add_profiles_to_list # alias of `add_profiles_to_list` alias create_list_relationships_profiles add_profiles_to_list # Add Profiles to List # Add a profile to a list with the given list ID. It is recommended that you use the [Subscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/subscribe_profiles) if you're trying to give a profile [consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api) to receive email marketing, SMS marketing, or both. This endpoint accepts a maximum of 1000 profiles per call.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:write` `profiles:write` # @param id [String] # @param list_members_add_query [ListMembersAddQuery] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def add_profiles_to_list_with_http_info(id, list_members_add_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.add_profiles_to_list ...' 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 ListsApi.add_profiles_to_list" end # verify the required parameter 'list_members_add_query' is set if @api_client.config.client_side_validation && list_members_add_query.nil? fail ArgumentError, "Missing the required parameter 'list_members_add_query' when calling ListsApi.add_profiles_to_list" end # resource path local_var_path = '/api/lists/{id}/relationships/profiles'.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'] || "2024-10-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(list_members_add_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 => :"ListsApi.add_profiles_to_list", :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: ListsApi#add_profiles_to_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `add_profiles_to_list_with_http_info` alias create_list_relationships_with_http_info add_profiles_to_list_with_http_info # alias of `add_profiles_to_list_with_http_info` alias create_list_relationships_profile_with_http_info add_profiles_to_list_with_http_info # alias of `add_profiles_to_list_with_http_info` alias create_list_relationships_profiles_with_http_info add_profiles_to_list_with_http_info # Create List # Create a new list.

*Rate limits*:
Burst: `10/s`
Steady: `150/m`
Daily: `150/d` **Scopes:** `lists:write` # @param list_create_query [ListCreateQuery] # @param [Hash] opts the optional parameters # @return [Hash] def create_list(list_create_query, opts = {}) data, _status_code, _headers = create_list_with_http_info(list_create_query, opts) data end # Create List # Create a new list.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`<br>Daily: `150/d` **Scopes:** `lists:write` # @param list_create_query [ListCreateQuery] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def create_list_with_http_info(list_create_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.create_list ...' end # verify the required parameter 'list_create_query' is set if @api_client.config.client_side_validation && list_create_query.nil? fail ArgumentError, "Missing the required parameter 'list_create_query' when calling ListsApi.create_list" end # resource path local_var_path = '/api/lists' # 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'] || "2024-10-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(list_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 => :"ListsApi.create_list", :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: ListsApi#create_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete List # Delete a list with the given list ID.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:write` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @return [nil] def delete_list(id, opts = {}) delete_list_with_http_info(id, opts) nil end # Delete List # Delete a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:write` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.delete_list ...' 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 ListsApi.delete_list" end # resource path local_var_path = '/api/lists/{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'] || "2024-10-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 => :"ListsApi.delete_list", :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: ListsApi#delete_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Flows Triggered by List # Get all flows where the given list ID is being used as the trigger.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `flows:read` `lists:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_flows_triggered_by_list(id, opts = {}) data, _status_code, _headers = get_flows_triggered_by_list_with_http_info(id, opts) data end # alias of `get_flows_triggered_by_list` alias get_flow_triggers_for_list get_flows_triggered_by_list # alias of `get_flows_triggered_by_list` alias get_list_flow_triggers get_flows_triggered_by_list # Get Flows Triggered by List # Get all flows where the given list ID is being used as the trigger.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `flows:read` `lists:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_flows_triggered_by_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_flows_triggered_by_list ...' 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 ListsApi.get_flows_triggered_by_list" end allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"] if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}" end # resource path local_var_path = '/api/lists/{id}/flow-triggers'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil? # header parameters header_params = opts[:header_params] || {} # klaviyo api revision header_params['revision'] = ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2024-10-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 => :"ListsApi.get_flows_triggered_by_list", :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: ListsApi#get_flows_triggered_by_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_flows_triggered_by_list_with_http_info` alias get_flow_triggers_for_list_with_http_info get_flows_triggered_by_list_with_http_info # alias of `get_flows_triggered_by_list_with_http_info` alias get_list_flow_triggers_with_http_info get_flows_triggered_by_list_with_http_info # Get IDs for Flows Triggered by List # Get the IDs of all flows where the given list is being used as the trigger.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `flows:read` `lists:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @return [Hash] def get_ids_for_flows_triggered_by_list(id, opts = {}) data, _status_code, _headers = get_ids_for_flows_triggered_by_list_with_http_info(id, opts) data end # alias of `get_ids_for_flows_triggered_by_list` alias get_flow_trigger_ids_for_list get_ids_for_flows_triggered_by_list # alias of `get_ids_for_flows_triggered_by_list` alias get_list_relationships_flow_triggers get_ids_for_flows_triggered_by_list # Get IDs for Flows Triggered by List # Get the IDs of all flows where the given list is being used as the trigger.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `flows:read` `lists:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_ids_for_flows_triggered_by_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_ids_for_flows_triggered_by_list ...' 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 ListsApi.get_ids_for_flows_triggered_by_list" end # resource path local_var_path = '/api/lists/{id}/relationships/flow-triggers'.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'] || "2024-10-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 => :"ListsApi.get_ids_for_flows_triggered_by_list", :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: ListsApi#get_ids_for_flows_triggered_by_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_ids_for_flows_triggered_by_list_with_http_info` alias get_flow_trigger_ids_for_list_with_http_info get_ids_for_flows_triggered_by_list_with_http_info # alias of `get_ids_for_flows_triggered_by_list_with_http_info` alias get_list_relationships_flow_triggers_with_http_info get_ids_for_flows_triggered_by_list_with_http_info # Get List # Get a list with the given list ID.

*Rate limits*:
Burst: `75/s`
Steady: `700/m`

Rate limits when using the `additional-fields[list]=profile_count` parameter in your API request:
Burst: `1/s`
Steady: `15/m`

To learn more about how the `additional-fields` parameter impacts rate limits, check out our [Rate limits, status codes, and errors](https://developers.klaviyo.com/en/v2024-10-15/docs/rate_limits_and_error_handling) guide. **Scopes:** `lists:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :additional_fields_list Request additional fields not included by default in the response. Supported values: 'profile_count' # @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships # @return [Hash] def get_list(id, opts = {}) data, _status_code, _headers = get_list_with_http_info(id, opts) data end # Get List # Get a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m`<br><br>Rate limits when using the `additional-fields[list]=profile_count` parameter in your API request:<br>Burst: `1/s`<br>Steady: `15/m`<br><br>To learn more about how the `additional-fields` parameter impacts rate limits, check out our [Rate limits, status codes, and errors](https://developers.klaviyo.com/en/v2024-10-15/docs/rate_limits_and_error_handling) guide. **Scopes:** `lists:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :additional_fields_list Request additional fields not included by default in the response. Supported values: 'profile_count' # @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_list ...' 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 ListsApi.get_list" end allowable_values = ["profile_count"] if @api_client.config.client_side_validation && opts[:'additional_fields_list'] && !opts[:'additional_fields_list'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"additional_fields_list\", must include one of #{allowable_values}" end allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"] if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}" end allowable_values = ["name", "created", "updated", "opt_in_process", "profile_count"] if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_list\", 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 = ["flow-triggers", "tags"] 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/lists/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'additional-fields[list]'] = @api_client.build_collection_param(opts[:'additional_fields_list'], :csv) if !opts[:'additional_fields_list'].nil? query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil? query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].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'] || "2024-10-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 => :"ListsApi.get_list", :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: ListsApi#get_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Lists # Get all lists in an account. Filter to request a subset of all lists. Lists can be filtered by `id`, `name`, `created`, and `updated` fields. Returns a maximum of 10 results per page.

*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `lists:read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `any`, `equals`<br>`id`: `any`, `equals`<br>`created`: `greater-than`<br>`updated`: `greater-than` # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting # @return [Hash] def get_lists(opts = {}) data, _status_code, _headers = get_lists_with_http_info(opts) data end # Get Lists # Get all lists in an account. Filter to request a subset of all lists. Lists can be filtered by `id`, `name`, `created`, and `updated` fields. Returns a maximum of 10 results per page.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `lists:read` # @param [Hash] opts the optional parameters # @option opts [Array] :fields_flow For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_list For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `any`, `equals`<br>`id`: `any`, `equals`<br>`created`: `greater-than`<br>`updated`: `greater-than` # @option opts [Array] :include For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#relationships # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_lists_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_lists ...' end allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"] if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}" end allowable_values = ["name", "created", "updated", "opt_in_process"] if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_list\", 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 = ["flow-triggers", "tags"] 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 = ["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/lists' # query parameters query_params = opts[:query_params] || {} query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil? query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].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'] || "2024-10-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 => :"ListsApi.get_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(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ListsApi#get_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Profile IDs for List # Get profile membership [relationships](https://developers.klaviyo.com/en/reference/api_overview#relationships) for a list with the given list ID.

*Rate limits*:
Burst: `75/s`
Steady: `700/m` **Scopes:** `lists:read` `profiles:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`push_token`: `any`, `equals`<br>`_kx`: `equals`<br>`joined_group_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination # @option opts [Integer] :page_size Default: 20. Min: 1. Max: 1000. (default to 20) # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting # @return [Hash] def get_profile_ids_for_list(id, opts = {}) data, _status_code, _headers = get_profile_ids_for_list_with_http_info(id, opts) data end # alias of `get_profile_ids_for_list` alias get_list_relationships_profiles get_profile_ids_for_list # Get Profile IDs for List # Get profile membership [relationships](https://developers.klaviyo.com/en/reference/api_overview#relationships) for a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `lists:read` `profiles:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`push_token`: `any`, `equals`<br>`_kx`: `equals`<br>`joined_group_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination # @option opts [Integer] :page_size Default: 20. Min: 1. Max: 1000. (default to 20) # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_profile_ids_for_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_profile_ids_for_list ...' 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 ListsApi.get_profile_ids_for_list" end if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ListsApi.get_profile_ids_for_list, must be smaller than or equal to 1000.' 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 ListsApi.get_profile_ids_for_list, must be greater than or equal to 1.' end allowable_values = ["joined_group_at", "-joined_group_at"] 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/lists/{id}/relationships/profiles'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} 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'] || "2024-10-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 => :"ListsApi.get_profile_ids_for_list", :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: ListsApi#get_profile_ids_for_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_profile_ids_for_list_with_http_info` alias get_list_relationships_profiles_with_http_info get_profile_ids_for_list_with_http_info # Get Profiles for List # Get all profiles within a list with the given list ID. Filter to request a subset of all profiles. Profiles can be filtered by `email`, `phone_number`, `push_token`, and `joined_group_at` fields. Profiles can be sorted by the following fields, in ascending and descending order: `joined_group_at`

*Rate limits*:
Burst: `75/s`
Steady: `700/m`

Rate limits when using the `additional-fields[profile]=predictive_analytics` parameter in your API request:
Burst: `10/s`
Steady: `150/m`

To learn more about how the `additional-fields` parameter impacts rate limits, check out our [Rate limits, status codes, and errors](https://developers.klaviyo.com/en/v2024-10-15/docs/rate_limits_and_error_handling) guide. **Scopes:** `lists:read` `profiles:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics' # @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`push_token`: `any`, `equals`<br>`_kx`: `equals`<br>`joined_group_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination # @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20) # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting # @return [Hash] def get_profiles_for_list(id, opts = {}) data, _status_code, _headers = get_profiles_for_list_with_http_info(id, opts) data end # alias of `get_profiles_for_list` alias get_list_profiles get_profiles_for_list # Get Profiles for List # Get all profiles within a list with the given list ID. Filter to request a subset of all profiles. Profiles can be filtered by `email`, `phone_number`, `push_token`, and `joined_group_at` fields. Profiles can be sorted by the following fields, in ascending and descending order: `joined_group_at`<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m`<br><br>Rate limits when using the `additional-fields[profile]=predictive_analytics` parameter in your API request:<br>Burst: `10/s`<br>Steady: `150/m`<br><br>To learn more about how the `additional-fields` parameter impacts rate limits, check out our [Rate limits, status codes, and errors](https://developers.klaviyo.com/en/v2024-10-15/docs/rate_limits_and_error_handling) guide. **Scopes:** `lists:read` `profiles:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'subscriptions', 'predictive_analytics' # @option opts [Array] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`email`: `any`, `equals`<br>`phone_number`: `any`, `equals`<br>`push_token`: `any`, `equals`<br>`_kx`: `equals`<br>`joined_group_at`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` # @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#pagination # @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20) # @option opts [String] :sort For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sorting # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_profiles_for_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_profiles_for_list ...' 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 ListsApi.get_profiles_for_list" end allowable_values = ["subscriptions", "predictive_analytics"] if @api_client.config.client_side_validation && opts[:'additional_fields_profile'] && !opts[:'additional_fields_profile'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"additional_fields_profile\", must include one of #{allowable_values}" end allowable_values = ["email", "phone_number", "external_id", "first_name", "last_name", "organization", "locale", "title", "image", "created", "updated", "last_event_date", "location", "location.address1", "location.address2", "location.city", "location.country", "location.latitude", "location.longitude", "location.region", "location.zip", "location.timezone", "location.ip", "properties", "joined_group_at", "subscriptions", "subscriptions.email", "subscriptions.email.marketing", "subscriptions.email.marketing.can_receive_email_marketing", "subscriptions.email.marketing.consent", "subscriptions.email.marketing.consent_timestamp", "subscriptions.email.marketing.last_updated", "subscriptions.email.marketing.method", "subscriptions.email.marketing.method_detail", "subscriptions.email.marketing.custom_method_detail", "subscriptions.email.marketing.double_optin", "subscriptions.email.marketing.suppression", "subscriptions.email.marketing.list_suppressions", "subscriptions.sms", "subscriptions.sms.marketing", "subscriptions.sms.marketing.can_receive_sms_marketing", "subscriptions.sms.marketing.consent", "subscriptions.sms.marketing.consent_timestamp", "subscriptions.sms.marketing.method", "subscriptions.sms.marketing.method_detail", "subscriptions.sms.marketing.last_updated", "subscriptions.sms.transactional", "subscriptions.sms.transactional.can_receive_sms_transactional", "subscriptions.sms.transactional.consent", "subscriptions.sms.transactional.consent_timestamp", "subscriptions.sms.transactional.method", "subscriptions.sms.transactional.method_detail", "subscriptions.sms.transactional.last_updated", "subscriptions.mobile_push", "subscriptions.mobile_push.marketing", "subscriptions.mobile_push.marketing.can_receive_push_marketing", "subscriptions.mobile_push.marketing.consent", "subscriptions.mobile_push.marketing.consent_timestamp", "predictive_analytics", "predictive_analytics.historic_clv", "predictive_analytics.predicted_clv", "predictive_analytics.total_clv", "predictive_analytics.historic_number_of_orders", "predictive_analytics.predicted_number_of_orders", "predictive_analytics.average_days_between_orders", "predictive_analytics.average_order_value", "predictive_analytics.churn_probability", "predictive_analytics.expected_date_of_next_order"] if @api_client.config.client_side_validation && opts[:'fields_profile'] && !opts[:'fields_profile'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"fields_profile\", 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 ListsApi.get_profiles_for_list, 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 ListsApi.get_profiles_for_list, must be greater than or equal to 1.' end allowable_values = ["joined_group_at", "-joined_group_at"] 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/lists/{id}/profiles'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'additional-fields[profile]'] = @api_client.build_collection_param(opts[:'additional_fields_profile'], :csv) if !opts[:'additional_fields_profile'].nil? query_params[:'fields[profile]'] = @api_client.build_collection_param(opts[:'fields_profile'], :csv) if !opts[:'fields_profile'].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'] || "2024-10-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 => :"ListsApi.get_profiles_for_list", :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: ListsApi#get_profiles_for_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_profiles_for_list_with_http_info` alias get_list_profiles_with_http_info get_profiles_for_list_with_http_info # Get Tag IDs for List # Returns the tag IDs of all tags associated with the given list.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `lists:read` `tags:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Hash] def get_tag_ids_for_list(id, opts = {}) data, _status_code, _headers = get_tag_ids_for_list_with_http_info(id, opts) data end # alias of `get_tag_ids_for_list` alias get_list_relationships_tags get_tag_ids_for_list # Get Tag IDs for List # Returns the tag IDs of all tags associated with the given list.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `lists:read` `tags:read` # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tag_ids_for_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_tag_ids_for_list ...' 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 ListsApi.get_tag_ids_for_list" end # resource path local_var_path = '/api/lists/{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'] || "2024-10-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 => :"ListsApi.get_tag_ids_for_list", :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: ListsApi#get_tag_ids_for_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_tag_ids_for_list_with_http_info` alias get_list_relationships_tags_with_http_info get_tag_ids_for_list_with_http_info # Get Tags for List # Return all tags associated with the given list ID.

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `lists:read` `tags:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @return [Hash] def get_tags_for_list(id, opts = {}) data, _status_code, _headers = get_tags_for_list_with_http_info(id, opts) data end # alias of `get_tags_for_list` alias get_list_tags get_tags_for_list # Get Tags for List # Return all tags associated with the given list ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `lists:read` `tags:read` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param [Hash] opts the optional parameters # @option opts [Array] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2024-10-15/reference/api-overview#sparse-fieldsets # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def get_tags_for_list_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.get_tags_for_list ...' 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 ListsApi.get_tags_for_list" 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/lists/{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'] || "2024-10-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 => :"ListsApi.get_tags_for_list", :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: ListsApi#get_tags_for_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `get_tags_for_list_with_http_info` alias get_list_tags_with_http_info get_tags_for_list_with_http_info # Remove Profiles from List # Remove a profile from a list with the given list ID. The provided profile will no longer receive marketing from this particular list once removed. Removing a profile from a list will not impact the profile's [consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api) status or subscription status in general. To update a profile's subscription status, please use the [Unsubscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/unsubscribe_profiles). This endpoint accepts a maximum of 1000 profiles per call.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:write` `profiles:write` # @param id [String] # @param list_members_delete_query [ListMembersDeleteQuery] # @param [Hash] opts the optional parameters # @return [nil] def remove_profiles_from_list(id, list_members_delete_query, opts = {}) remove_profiles_from_list_with_http_info(id, list_members_delete_query, opts) nil end # alias of `remove_profiles_from_list` alias delete_list_relationships remove_profiles_from_list # alias of `remove_profiles_from_list` alias delete_list_relationships_profiles remove_profiles_from_list # Remove Profiles from List # Remove a profile from a list with the given list ID. The provided profile will no longer receive marketing from this particular list once removed. Removing a profile from a list will not impact the profile's [consent](https://developers.klaviyo.com/en/docs/collect_email_and_sms_consent_via_api) status or subscription status in general. To update a profile's subscription status, please use the [Unsubscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/unsubscribe_profiles). This endpoint accepts a maximum of 1000 profiles per call.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:write` `profiles:write` # @param id [String] # @param list_members_delete_query [ListMembersDeleteQuery] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def remove_profiles_from_list_with_http_info(id, list_members_delete_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.remove_profiles_from_list ...' 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 ListsApi.remove_profiles_from_list" end # verify the required parameter 'list_members_delete_query' is set if @api_client.config.client_side_validation && list_members_delete_query.nil? fail ArgumentError, "Missing the required parameter 'list_members_delete_query' when calling ListsApi.remove_profiles_from_list" end # resource path local_var_path = '/api/lists/{id}/relationships/profiles'.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'] || "2024-10-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(list_members_delete_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 => :"ListsApi.remove_profiles_from_list", :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: ListsApi#remove_profiles_from_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # alias of `remove_profiles_from_list_with_http_info` alias delete_list_relationships_with_http_info remove_profiles_from_list_with_http_info # alias of `remove_profiles_from_list_with_http_info` alias delete_list_relationships_profiles_with_http_info remove_profiles_from_list_with_http_info # Update List # Update the name of a list with the given list ID.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `lists:write` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param list_partial_update_query [ListPartialUpdateQuery] # @param [Hash] opts the optional parameters # @return [Hash] def update_list(id, list_partial_update_query, opts = {}) data, _status_code, _headers = update_list_with_http_info(id, list_partial_update_query, opts) data end # Update List # Update the name of a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `lists:write` # @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo. # @param list_partial_update_query [ListPartialUpdateQuery] # @param [Hash] opts the optional parameters # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def update_list_with_http_info(id, list_partial_update_query, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ListsApi.update_list ...' 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 ListsApi.update_list" end # verify the required parameter 'list_partial_update_query' is set if @api_client.config.client_side_validation && list_partial_update_query.nil? fail ArgumentError, "Missing the required parameter 'list_partial_update_query' when calling ListsApi.update_list" end # resource path local_var_path = '/api/lists/{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'] || "2024-10-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(list_partial_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 => :"ListsApi.update_list", :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: ListsApi#update_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end