Ingest metric events
curl --request POST \
--url https://app.gaintrace.com/api/v1/metric-events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
{
"eventName": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"companyExternalId": "<string>",
"enduserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"enduserEmail": "[email protected]",
"properties": {},
"externalId": "<string>"
}
],
"source": "api",
"strict": false
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
events: [
{
eventName: '<string>',
occurredAt: '2023-11-07T05:31:56Z',
companyId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
companyExternalId: '<string>',
enduserId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
enduserEmail: '[email protected]',
properties: {},
externalId: '<string>'
}
],
source: 'api',
strict: false
})
};
fetch('https://app.gaintrace.com/api/v1/metric-events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.gaintrace.com/api/v1/metric-events"
payload = {
"events": [
{
"eventName": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"companyExternalId": "<string>",
"enduserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"enduserEmail": "[email protected]",
"properties": {},
"externalId": "<string>"
}
],
"source": "api",
"strict": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"ok": true,
"summary": {
"received": 123,
"ingested": 123,
"duplicate": 123,
"rejected": 123
},
"outcomes": [
{
"index": 123,
"status": "ingested",
"error": "<string>",
"eventLogId": 123
}
]
}{
"error": {
"code": "bad_request",
"message": "Invalid JSON body",
"doc_url": "https://docs.gaintrace.com/errors#bad_request"
}
}{
"error": {
"code": "unauthorized",
"message": "Missing Authorization header",
"doc_url": "https://docs.gaintrace.com/errors#unauthorized"
}
}{
"error": {
"code": "forbidden",
"message": "Insufficient scope: write:companies required",
"doc_url": "https://docs.gaintrace.com/errors#forbidden"
}
}{
"error": {
"code": "unprocessable_entity",
"message": "Request validation failed. name: name is required",
"doc_url": "https://docs.gaintrace.com/errors#unprocessable_entity"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Maximum 120 requests per minute per API key.",
"doc_url": "https://docs.gaintrace.com/errors#rate_limit_exceeded"
}
}{
"error": {
"code": "internal_server_error",
"message": "Something went wrong. Try again in a moment.",
"doc_url": "https://docs.gaintrace.com/errors#internal_server_error"
}
}{
"error": {
"code": "service_unavailable",
"message": "We had trouble reaching the database. Try again in a moment.",
"doc_url": "https://docs.gaintrace.com/errors#service_unavailable"
}
}{
"error": {
"code": "gateway_timeout",
"message": "The request timed out. Try again in a moment.",
"doc_url": "https://docs.gaintrace.com/errors#gateway_timeout"
}
}Ingest
Ingest metric events
Ingests a batch of typed metric events into the metrics engine (feeds daily snapshots that calc metrics evaluate). Idempotent on (source, externalId); duplicates are skipped silently. Returns a per-event outcome.
Scope: write:events · 1–500 events per request.
POST
/
metric-events
Ingest metric events
curl --request POST \
--url https://app.gaintrace.com/api/v1/metric-events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
{
"eventName": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"companyExternalId": "<string>",
"enduserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"enduserEmail": "[email protected]",
"properties": {},
"externalId": "<string>"
}
],
"source": "api",
"strict": false
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
events: [
{
eventName: '<string>',
occurredAt: '2023-11-07T05:31:56Z',
companyId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
companyExternalId: '<string>',
enduserId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
enduserEmail: '[email protected]',
properties: {},
externalId: '<string>'
}
],
source: 'api',
strict: false
})
};
fetch('https://app.gaintrace.com/api/v1/metric-events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.gaintrace.com/api/v1/metric-events"
payload = {
"events": [
{
"eventName": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"companyExternalId": "<string>",
"enduserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"enduserEmail": "[email protected]",
"properties": {},
"externalId": "<string>"
}
],
"source": "api",
"strict": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"ok": true,
"summary": {
"received": 123,
"ingested": 123,
"duplicate": 123,
"rejected": 123
},
"outcomes": [
{
"index": 123,
"status": "ingested",
"error": "<string>",
"eventLogId": 123
}
]
}{
"error": {
"code": "bad_request",
"message": "Invalid JSON body",
"doc_url": "https://docs.gaintrace.com/errors#bad_request"
}
}{
"error": {
"code": "unauthorized",
"message": "Missing Authorization header",
"doc_url": "https://docs.gaintrace.com/errors#unauthorized"
}
}{
"error": {
"code": "forbidden",
"message": "Insufficient scope: write:companies required",
"doc_url": "https://docs.gaintrace.com/errors#forbidden"
}
}{
"error": {
"code": "unprocessable_entity",
"message": "Request validation failed. name: name is required",
"doc_url": "https://docs.gaintrace.com/errors#unprocessable_entity"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Maximum 120 requests per minute per API key.",
"doc_url": "https://docs.gaintrace.com/errors#rate_limit_exceeded"
}
}{
"error": {
"code": "internal_server_error",
"message": "Something went wrong. Try again in a moment.",
"doc_url": "https://docs.gaintrace.com/errors#internal_server_error"
}
}{
"error": {
"code": "service_unavailable",
"message": "We had trouble reaching the database. Try again in a moment.",
"doc_url": "https://docs.gaintrace.com/errors#service_unavailable"
}
}{
"error": {
"code": "gateway_timeout",
"message": "The request timed out. Try again in a moment.",
"doc_url": "https://docs.gaintrace.com/errors#gateway_timeout"
}
}Authorizations
Bearer API key. Secret server keys start with gt_live_; client-safe browser keys start with gt_pub_ (write-only, origin-pinned). Create and scope keys in Settings → API Keys.
Body
application/json
Last modified on July 7, 2026
Was this page helpful?
⌘I