Events
We recommend using this API endpoint when you need to create or update a collection of events at once. Note: Since our batch APIs process requests in the background, there may be a delay of ~2 mins.
post
https://app.bentonow.com
/api/v1/batch/events
Batch Import
Below is a short example in Ruby on how you may want to utilize this import to add events into the system. Whether you want to add 1 or many this endpoint should do the trick.
batch_importer.rb
1
publishable_key = "XXXX-XXXX-XXXX-XXXX"
2
secret_key = "XXXX-XXXX-XXXX-XXXX"
3
site_uuid = "XXXX-XXXX-XXXX-XXXX"
4
5
import_data = [
6
{ email: "[email protected]", type: "$custom_event", fields: {"first_name": "Jesse"}, details: {"custom_stat": 1000}},
7
{ email: "[email protected]", type: "$custom_event_with_no_details", fields: {"first_name": "Jesse", "last_name": "Hanley"}},
8
{ email: "[email protected]", type: "$custom_event_with_workflow_bypass", details: {"bypass_workflows": 'true'}},
9
{ email: "[email protected]", type: "$custom_event_with_nothing_else"},
10
{ email: "[email protected]", type: "$purchase", fields: {"first_name": "Jesse"}, details: {"unique": {"key": "test123" }, "value": {"currency": "USD", "amount": 8000}}},
11
{ email: "[email protected]", type: "$purchase", fields: {"first_name": "Jesse"}, details: {"unique": {"key": "test123" }, "value": {"currency": "USD", "amount": 8000}, 'cart' => { 'items' => [{'product_sku': 'SKU123', 'product_name': 'Test', 'quantity': 100 }], 'abandoned_checkout_url': "https://test.com" }}},
12
{ email: "[email protected]", type: "$backdated_event", date: 3.years.ago }
13
]
14
​
15
uri = URI.parse("https://app.bentonow.com/api/v1/batch/events")
16
​
17
request = Net::HTTP::Post.new(uri)
18
request.basic_auth(publishable_key, secret_key)
19
request.body = JSON.dump({site_uuid: site_uuid, events: import_data })
20
request.content_type = "application/json"
21
req_options = { use_ssl: uri.scheme == "https", }
22
​
23
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
24
http.request(request)
25
end
26
​
27
puts JSON.parse(response.body)
Copied!
Copy link