curl --request POST \
--url https://api.onchainsuite.com/api/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "first_deposit",
"contact": {
"email": "jsmith@example.com",
"walletAddress": "<string>",
"externalId": "<string>"
},
"attributes": {},
"payload": {},
"idempotencyKey": "deposit:0xabc:9184",
"occurredAt": "2023-11-07T05:31:56Z",
"test": true
}
'import requests
url = "https://api.onchainsuite.com/api/v1/events"
payload = {
"event": "first_deposit",
"contact": {
"email": "jsmith@example.com",
"walletAddress": "<string>",
"externalId": "<string>"
},
"attributes": {},
"payload": {},
"idempotencyKey": "deposit:0xabc:9184",
"occurredAt": "2023-11-07T05:31:56Z",
"test": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: 'first_deposit',
contact: {email: 'jsmith@example.com', walletAddress: '<string>', externalId: '<string>'},
attributes: {},
payload: {},
idempotencyKey: 'deposit:0xabc:9184',
occurredAt: '2023-11-07T05:31:56Z',
test: true
})
};
fetch('https://api.onchainsuite.com/api/v1/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onchainsuite.com/api/v1/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'event' => 'first_deposit',
'contact' => [
'email' => 'jsmith@example.com',
'walletAddress' => '<string>',
'externalId' => '<string>'
],
'attributes' => [
],
'payload' => [
],
'idempotencyKey' => 'deposit:0xabc:9184',
'occurredAt' => '2023-11-07T05:31:56Z',
'test' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onchainsuite.com/api/v1/events"
payload := strings.NewReader("{\n \"event\": \"first_deposit\",\n \"contact\": {\n \"email\": \"jsmith@example.com\",\n \"walletAddress\": \"<string>\",\n \"externalId\": \"<string>\"\n },\n \"attributes\": {},\n \"payload\": {},\n \"idempotencyKey\": \"deposit:0xabc:9184\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"test\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.onchainsuite.com/api/v1/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"first_deposit\",\n \"contact\": {\n \"email\": \"jsmith@example.com\",\n \"walletAddress\": \"<string>\",\n \"externalId\": \"<string>\"\n },\n \"attributes\": {},\n \"payload\": {},\n \"idempotencyKey\": \"deposit:0xabc:9184\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"test\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onchainsuite.com/api/v1/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"event\": \"first_deposit\",\n \"contact\": {\n \"email\": \"jsmith@example.com\",\n \"walletAddress\": \"<string>\",\n \"externalId\": \"<string>\"\n },\n \"attributes\": {},\n \"payload\": {},\n \"idempotencyKey\": \"deposit:0xabc:9184\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"test\": true\n}"
response = http.request(request)
puts response.read_body{
"accepted": true,
"deduplicated": true,
"idempotencyKey": "<string>"
}Send a custom event
Send one product event (a signup, a deposit, a purchase). It resolves to a contact by wallet, then email, then external id, creating the contact if none matches. Returns 202: accepted for processing, not yet acted on.
curl --request POST \
--url https://api.onchainsuite.com/api/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "first_deposit",
"contact": {
"email": "jsmith@example.com",
"walletAddress": "<string>",
"externalId": "<string>"
},
"attributes": {},
"payload": {},
"idempotencyKey": "deposit:0xabc:9184",
"occurredAt": "2023-11-07T05:31:56Z",
"test": true
}
'import requests
url = "https://api.onchainsuite.com/api/v1/events"
payload = {
"event": "first_deposit",
"contact": {
"email": "jsmith@example.com",
"walletAddress": "<string>",
"externalId": "<string>"
},
"attributes": {},
"payload": {},
"idempotencyKey": "deposit:0xabc:9184",
"occurredAt": "2023-11-07T05:31:56Z",
"test": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: 'first_deposit',
contact: {email: 'jsmith@example.com', walletAddress: '<string>', externalId: '<string>'},
attributes: {},
payload: {},
idempotencyKey: 'deposit:0xabc:9184',
occurredAt: '2023-11-07T05:31:56Z',
test: true
})
};
fetch('https://api.onchainsuite.com/api/v1/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onchainsuite.com/api/v1/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'event' => 'first_deposit',
'contact' => [
'email' => 'jsmith@example.com',
'walletAddress' => '<string>',
'externalId' => '<string>'
],
'attributes' => [
],
'payload' => [
],
'idempotencyKey' => 'deposit:0xabc:9184',
'occurredAt' => '2023-11-07T05:31:56Z',
'test' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onchainsuite.com/api/v1/events"
payload := strings.NewReader("{\n \"event\": \"first_deposit\",\n \"contact\": {\n \"email\": \"jsmith@example.com\",\n \"walletAddress\": \"<string>\",\n \"externalId\": \"<string>\"\n },\n \"attributes\": {},\n \"payload\": {},\n \"idempotencyKey\": \"deposit:0xabc:9184\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"test\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.onchainsuite.com/api/v1/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"first_deposit\",\n \"contact\": {\n \"email\": \"jsmith@example.com\",\n \"walletAddress\": \"<string>\",\n \"externalId\": \"<string>\"\n },\n \"attributes\": {},\n \"payload\": {},\n \"idempotencyKey\": \"deposit:0xabc:9184\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"test\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onchainsuite.com/api/v1/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"event\": \"first_deposit\",\n \"contact\": {\n \"email\": \"jsmith@example.com\",\n \"walletAddress\": \"<string>\",\n \"externalId\": \"<string>\"\n },\n \"attributes\": {},\n \"payload\": {},\n \"idempotencyKey\": \"deposit:0xabc:9184\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"test\": true\n}"
response = http.request(request)
puts response.read_body{
"accepted": true,
"deduplicated": true,
"idempotencyKey": "<string>"
}Authorizations
Your secret key, for example sk_live_.... Send it as Authorization: Bearer sk_live_.... A sk_test_... key runs in test mode.
Body
Event name, matching ^[a-zA-Z0-9_.:-]{1,64}$, lower-cased on arrival.
"first_deposit"
Who the event or action is for. Provide at least one identifier.
Show child attributes
Show child attributes
Contact traits merged onto the contact record. Max 50 keys.
Event-specific data, kept with the event. Max 16 KB.
Your dedup key. Strongly recommended.
"deposit:0xabc:9184"
When it happened. Rejected if older than 7 days or more than 5 minutes in the future.
Dry run: reports what it would match but sends nothing.

