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
Batch Import

https://app.bentonow.com/api/v1/batch/events
This endpoint mimics our frontend event API and will process your events as a background job. Whether you submit one event or many expect to see them live in 1-3 minutes.
Request
Response
Request
Path Parameters
id
optional
string
ID of the cake to get, for free of course.
Headers
Basic Auth
required
string
publishable_key:secret_key
Query Parameters
site_uuid
optional
string
This is your site's unique identifier.
Body Parameters
events
optional
array
An array between 1 to 1,000 events.
Response
200: OK
Returns how many events have been sent for processing.
{ "results": 1,000 }

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
publishable_key = "XXXX-XXXX-XXXX-XXXX"
secret_key = "XXXX-XXXX-XXXX-XXXX"
site_uuid = "XXXX-XXXX-XXXX-XXXX"
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_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, 'product_price': 8000, 'product_id': '123'}], '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)