Ingest a batch of customer events
curl --request POST \
--url https://api.swapnice.com/v1/events/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"events": [
{
"customer_id": "<string>",
"client_event_id": "<string>",
"event_type": "purchase.completed",
"ontology": "ygo",
"occurred_at": "2023-11-07T05:31:56Z",
"payload": {},
"object": "sku_blue_eyes_tin",
"consent_receipt_id": "<string>",
"context": {},
"confidence": 1
}
]
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
events: [
{
customer_id: '<string>',
client_event_id: '<string>',
event_type: 'purchase.completed',
ontology: 'ygo',
occurred_at: '2023-11-07T05:31:56Z',
payload: {},
object: 'sku_blue_eyes_tin',
consent_receipt_id: '<string>',
context: {},
confidence: 1
}
]
})
};
fetch('https://api.swapnice.com/v1/events/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.swapnice.com/v1/events/batch"
payload = { "events": [
{
"customer_id": "<string>",
"client_event_id": "<string>",
"event_type": "purchase.completed",
"ontology": "ygo",
"occurred_at": "2023-11-07T05:31:56Z",
"payload": {},
"object": "sku_blue_eyes_tin",
"consent_receipt_id": "<string>",
"context": {},
"confidence": 1
}
] }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"batch_id": "<string>",
"status": "accepted",
"accepted_count": 123,
"rejected_count": 123,
"items": [
{
"client_event_id": "<string>",
"status": "accepted",
"event_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
}
]
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}Events
Ingest a batch of events
Send 1–100 events. Ordering is guaranteed per customer, not across customers.
POST
/
v1
/
events
/
batch
Ingest a batch of customer events
curl --request POST \
--url https://api.swapnice.com/v1/events/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"events": [
{
"customer_id": "<string>",
"client_event_id": "<string>",
"event_type": "purchase.completed",
"ontology": "ygo",
"occurred_at": "2023-11-07T05:31:56Z",
"payload": {},
"object": "sku_blue_eyes_tin",
"consent_receipt_id": "<string>",
"context": {},
"confidence": 1
}
]
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
events: [
{
customer_id: '<string>',
client_event_id: '<string>',
event_type: 'purchase.completed',
ontology: 'ygo',
occurred_at: '2023-11-07T05:31:56Z',
payload: {},
object: 'sku_blue_eyes_tin',
consent_receipt_id: '<string>',
context: {},
confidence: 1
}
]
})
};
fetch('https://api.swapnice.com/v1/events/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.swapnice.com/v1/events/batch"
payload = { "events": [
{
"customer_id": "<string>",
"client_event_id": "<string>",
"event_type": "purchase.completed",
"ontology": "ygo",
"occurred_at": "2023-11-07T05:31:56Z",
"payload": {},
"object": "sku_blue_eyes_tin",
"consent_receipt_id": "<string>",
"context": {},
"confidence": 1
}
] }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"batch_id": "<string>",
"status": "accepted",
"accepted_count": 123,
"rejected_count": 123,
"items": [
{
"client_event_id": "<string>",
"status": "accepted",
"event_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
}
]
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}Send 1–100 events. Ordering is guaranteed per customer, not across customers.
Each item uses the same shape as a single ingest. Partial acceptance is possible.
Authorizations
OAuth 2.1 authorization code with PKCE. Implicit and password flows are unsupported.
Headers
Required for mutating requests. Replays with the same key and payload hash return
the original logical result; replays with a different payload hash return 409.
Required string length:
16 - 255Body
application/json
Required array length:
1 - 100 elementsShow child attributes
Show child attributes
⌘I