Events
Capture an event
Record an event to track user actions or system behavior.
POST
/
capture
TypeScript SDK
import Seerstack from 'seerstack';
const client = new Seerstack({
apiKey: process.env['SEERSTACK_API_KEY'],
});
const response = await client.events.capture({
name: 'invoice.paid',
user_id: 'user_123',
data: {
invoice_id: 'inv_993',
amount: 2000,
currency: 'usd'
}
});
console.log(response.success);require "seerstack"
seerstack = Seerstack::Client.new(
api_key: ENV["SEERSTACK_API_KEY"]
)
response = seerstack.events.capture(
name: "invoice.paid",
user_id: "user_123",
data: {
invoice_id: "inv_993",
amount: 2000,
currency: "usd"
}
)
puts(response.success)curl -X POST https://api.seerstack.com/capture \
-H "Authorization: Bearer $SEERSTACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "invoice.paid",
"user_id": "user_123",
"data": {
"invoice_id": "inv_993",
"amount": 2000,
"currency": "usd"
}
}'import requests
url = "https://api.seerstack.com/capture"
payload = { "name": "page.view" }
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({name: 'page.view'})
};
fetch('https://api.seerstack.com/capture', 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.seerstack.com/capture",
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([
'name' => 'page.view'
]),
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.seerstack.com/capture"
payload := strings.NewReader("{\n \"name\": \"page.view\"\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.seerstack.com/capture")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"page.view\"\n}")
.asString();{
"success": true
}{
"error": "Missing or invalid API key"
}Authorizations
Use your SeerStack API key as a Bearer token. You can find your API key in the SeerStack Dashboard under Settings > Developer.
Body
application/json
The name of the event. We recommend using noun.verb syntax (e.g., invoice.paid, user.signup).
Example:
"invoice.paid"
The external user ID associated with this event. Use your database's primary key.
Example:
"user_123"
ISO 8601 timestamp for when the event occurred. Defaults to the current time if not provided.
Example:
"2025-01-04T12:00:00Z"
Additional data to include with the event. Can contain any JSON-serializable values.
Example:
{
"invoice_id": "inv_993",
"amount": 2000,
"currency": "usd"
}
Response
Event captured successfully
Indicates whether the operation was successful.
Example:
true
⌘I
TypeScript SDK
import Seerstack from 'seerstack';
const client = new Seerstack({
apiKey: process.env['SEERSTACK_API_KEY'],
});
const response = await client.events.capture({
name: 'invoice.paid',
user_id: 'user_123',
data: {
invoice_id: 'inv_993',
amount: 2000,
currency: 'usd'
}
});
console.log(response.success);require "seerstack"
seerstack = Seerstack::Client.new(
api_key: ENV["SEERSTACK_API_KEY"]
)
response = seerstack.events.capture(
name: "invoice.paid",
user_id: "user_123",
data: {
invoice_id: "inv_993",
amount: 2000,
currency: "usd"
}
)
puts(response.success)curl -X POST https://api.seerstack.com/capture \
-H "Authorization: Bearer $SEERSTACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "invoice.paid",
"user_id": "user_123",
"data": {
"invoice_id": "inv_993",
"amount": 2000,
"currency": "usd"
}
}'import requests
url = "https://api.seerstack.com/capture"
payload = { "name": "page.view" }
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({name: 'page.view'})
};
fetch('https://api.seerstack.com/capture', 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.seerstack.com/capture",
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([
'name' => 'page.view'
]),
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.seerstack.com/capture"
payload := strings.NewReader("{\n \"name\": \"page.view\"\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.seerstack.com/capture")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"page.view\"\n}")
.asString();{
"success": true
}{
"error": "Missing or invalid API key"
}