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
# Find these under your account settings.
publishable_key = "XXXX-XXXX-XXXX-XXXX"
secret_key = "XXXX-XXXX-XXXX-XXXX"
# Find this under you site settings.
site_uuid = "XXXX-XXXX-XXXX-XXXX"
# You can send an array of events.
# MAX 100 per request.
import_data = [
{ email: "[email protected]", type: "$custom_event", fields: {"first_name": "Jesse"}, details: {"custom_stat": 1000}},
{ email: "[email protected]", type: "$custom_event_with_no_details", fields: {"first_name": "Jesse", "last_name": "Hanley"}},
{ email: "[email protected]", type: "$custom_event_with_workflow_bypass", details: {"bypass_workflows": 'true'}},
{ email: "[email protected]", type: "$custom_event_with_nothing_else"},
{ email: "[email protected]", type: "$purchase", fields: {"first_name": "Jesse"}, details: {"unique": {"key": "test123" }, "value": {"currency": "USD", "amount": 8000}}},
{ 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" }}},
{ email: "[email protected]", type: "$backdated_event", date: 3.years.ago }
]
uri = URI.parse("https://app.bentonow.com/api/v1/batch/events")
request = Net::HTTP::Post.new(uri)
request.basic_auth(publishable_key, secret_key)
request.body = JSON.dump({site_uuid: site_uuid, events: import_data })
request.content_type = "application/json"
req_options = { use_ssl: uri.scheme == "https", }
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
puts JSON.parse(response.body)