# KlaviyoAPI::EventsApi
All URIs are relative to *https://a.klaviyo.com*
| Method | HTTP request | Description |
| ------ | ------------ | ----------- |
| [**create_event**](EventsApi.md#create_event) | **POST** /api/events/ | Create Event |
| [**get_event**](EventsApi.md#get_event) | **GET** /api/events/{id}/ | Get Event |
| [**get_event_metric**](EventsApi.md#get_event_metric) | **GET** /api/events/{id}/metric/ | Get Event Metric |
| [**get_event_profile**](EventsApi.md#get_event_profile) | **GET** /api/events/{id}/profile/ | Get Event Profile |
| [**get_event_relationships_metric**](EventsApi.md#get_event_relationships_metric) | **GET** /api/events/{id}/relationships/metric/ | Get Event Relationships Metric |
| [**get_event_relationships_profile**](EventsApi.md#get_event_relationships_profile) | **GET** /api/events/{id}/relationships/profile/ | Get Event Relationships Profile |
| [**get_events**](EventsApi.md#get_events) | **GET** /api/events/ | Get Events |
## create_event
> create_event(event_create_query_v2)
Create Event
Create a new event to track a profile's activity. Successful response indicates that the event was validated and submitted for processing, but does not guarantee that processing is complete.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `events:write`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::EventsApi.new
event_create_query_v2 = KlaviyoAPI::EventCreateQueryV2.new({data: KlaviyoAPI::EventCreateQueryV2ResourceObject.new({type: KlaviyoAPI::EventEnum::EVENT, attributes: KlaviyoAPI::EventCreateQueryV2ResourceObjectAttributes.new({properties: {"Brand":"Kids Book","Categories":["Fiction","Children"],"ProductID":1111,"ProductName":"Winnie the Pooh","$extra":{"URL":"http://www.example.com/path/to/product","ImageURL":"http://www.example.com/path/to/product/image.png"}}, metric: KlaviyoAPI::EventCreateQueryV2ResourceObjectAttributesMetric.new({data: KlaviyoAPI::MetricCreateQueryResourceObject.new({type: KlaviyoAPI::MetricEnum::METRIC, attributes: KlaviyoAPI::MetricCreateQueryResourceObjectAttributes.new({name: 'Viewed Product'})})}), profile: KlaviyoAPI::EventCreateQueryV2ResourceObjectAttributesProfile.new({data: KlaviyoAPI::OnsiteProfileCreateQueryResourceObject.new({type: KlaviyoAPI::ProfileEnum::PROFILE, attributes: KlaviyoAPI::OnsiteProfileCreateQueryResourceObjectAttributes.new})})})})}) # EventCreateQueryV2 |
begin
# Create Event
api_instance.create_event(event_create_query_v2)
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->create_event: #{e}"
end
```
#### Using the create_event_with_http_info variant
This returns an Array which contains the response data (`nil` in this case), status code and headers.
> create_event_with_http_info(event_create_query_v2)
```ruby
begin
# Create Event
data, status_code, headers = api_instance.create_event_with_http_info(event_create_query_v2)
p status_code # => 2xx
p headers # => { ... }
p data # => nil
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->create_event_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **event_create_query_v2** | [**EventCreateQueryV2**](EventCreateQueryV2.md) | | |
### Return type
nil (empty response body)
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
## get_event
> Hash<String, Object> get_event(id, opts)
Get Event
Get an event with the given event ID. Include parameters can be provided to get the following related resource data: `metric`, `profile`
*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `events:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::EventsApi.new
id = 'id_example' # String | ID of the event
opts = {
fields_event: ['timestamp'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
fields_metric: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
fields_profile: ['email'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
include: ['metric'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#relationships
}
begin
# Get Event
result = api_instance.get_event(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event: #{e}"
end
```
#### Using the get_event_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_event_with_http_info(id, opts)
```ruby
begin
# Get Event
data, status_code, headers = api_instance.get_event_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | ID of the event | |
| **fields_event** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_metric** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_profile** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#relationships | [optional] |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## get_event_metric
> Hash<String, Object> get_event_metric(id, opts)
Get Event Metric
Get the metric for an event with the given event ID.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `events:read` `metrics:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::EventsApi.new
id = 'id_example' # String |
opts = {
fields_metric: ['name'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Event Metric
result = api_instance.get_event_metric(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_metric: #{e}"
end
```
#### Using the get_event_metric_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_event_metric_with_http_info(id, opts)
```ruby
begin
# Get Event Metric
data, status_code, headers = api_instance.get_event_metric_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_metric_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **fields_metric** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## get_event_profile
> Hash<String, Object> get_event_profile(id, opts)
Get Event Profile
Get the profile associated with an event with the given event ID.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `events:read` `profiles:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::EventsApi.new
id = 'id_example' # String |
opts = {
additional_fields_profile: ['predictive_analytics'], # Array | Request additional fields not included by default in the response. Supported values: 'predictive_analytics'
fields_profile: ['email'] # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
}
begin
# Get Event Profile
result = api_instance.get_event_profile(id, opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_profile: #{e}"
end
```
#### Using the get_event_profile_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_event_profile_with_http_info(id, opts)
```ruby
begin
# Get Event Profile
data, status_code, headers = api_instance.get_event_profile_with_http_info(id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_profile_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
| **additional_fields_profile** | [**Array<String>**](String.md) | Request additional fields not included by default in the response. Supported values: 'predictive_analytics' | [optional] |
| **fields_profile** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## get_event_relationships_metric
> Hash<String, Object> get_event_relationships_metric(id)
Get Event Relationships Metric
Get a list of related Metrics for an Event
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `events:read` `metrics:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::EventsApi.new
id = 'id_example' # String |
begin
# Get Event Relationships Metric
result = api_instance.get_event_relationships_metric(id)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_relationships_metric: #{e}"
end
```
#### Using the get_event_relationships_metric_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_event_relationships_metric_with_http_info(id)
```ruby
begin
# Get Event Relationships Metric
data, status_code, headers = api_instance.get_event_relationships_metric_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_relationships_metric_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## get_event_relationships_profile
> Hash<String, Object> get_event_relationships_profile(id)
Get Event Relationships Profile
Get profile [relationships](https://developers.klaviyo.com/en/reference/api_overview#relationships) for an event with the given event ID.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `events:read` `profiles:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::EventsApi.new
id = 'id_example' # String |
begin
# Get Event Relationships Profile
result = api_instance.get_event_relationships_profile(id)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_relationships_profile: #{e}"
end
```
#### Using the get_event_relationships_profile_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_event_relationships_profile_with_http_info(id)
```ruby
begin
# Get Event Relationships Profile
data, status_code, headers = api_instance.get_event_relationships_profile_with_http_info(id)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_event_relationships_profile_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | | |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## get_events
> Hash<String, Object> get_events(opts)
Get Events
Get all events in an account Requests can be sorted by the following fields: `datetime`, `timestamp` Include parameters can be provided to get the following related resource data: `metric`, `profile` Returns a maximum of 200 events per page.
*Rate limits*:
Burst: `350/s`
Steady: `3500/m` **Scopes:** `events:read`
### Examples
```ruby
require 'time'
require 'klaviyo-api-sdk'
# setup authorization
KlaviyoAPI.configure do |config|
# Configure API key authorization: Klaviyo-API-Key
config.api_key['Klaviyo-API-Key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['Klaviyo-API-Key'] = 'Bearer'
end
api_instance = KlaviyoAPI::EventsApi.new
opts = {
fields_event: ['timestamp'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
fields_metric: ['name'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
fields_profile: ['email'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets
filter: 'filter_example', # String | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#filtering
Allowed field(s)/operator(s):
`metric_id`: `equals`
`profile_id`: `equals`
`datetime`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
`timestamp`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`
include: ['metric'], # Array | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#relationships
page_cursor: 'page_cursor_example', # String | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#pagination
sort: 'datetime' # String | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sorting
}
begin
# Get Events
result = api_instance.get_events(opts)
p result
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_events: #{e}"
end
```
#### Using the get_events_with_http_info variant
This returns an Array which contains the response data, status code and headers.
> get_events_with_http_info(opts)
```ruby
begin
# Get Events
data, status_code, headers = api_instance.get_events_with_http_info(opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Hash<String, Object>
rescue KlaviyoAPI::ApiError => e
puts "Error when calling EventsApi->get_events_with_http_info: #{e}"
end
```
### Parameters
| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **fields_event** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_metric** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
| **fields_profile** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sparse-fieldsets | [optional] |
| **filter** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`metric_id`: `equals`<br>`profile_id`: `equals`<br>`datetime`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`timestamp`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than` | [optional] |
| **include** | [**Array<String>**](String.md) | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#relationships | [optional] |
| **page_cursor** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#pagination | [optional] |
| **sort** | **String** | For more information please visit https://developers.klaviyo.com/en/v2023-09-15/reference/api-overview#sorting | [optional] |
### Return type
**Hash<String, Object>**
### Authorization
[Klaviyo-API-Key](../README.md#Klaviyo-API-Key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json