Ingesting Test Data

This article talks about how users can ingest test data using Togai APIs

Updated over a week ago

Once you've configured your pricing plans within Togai, you'd want to test it out before you go live with it.

To get started, let's use this API to create a customer first. Here's what a sample request payload looks like :

curl --request POST \
--url https://api.togai.com/customers \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"id": "01BX5ZZKBKACTAV9WEVGEMMVRZ",
"name": "ACME Enterprise",
"primaryEmail": "[email protected]",
"billingAddress": "201 Boulevard, WA 53123",
"settings": [
{
"id": "customerSettingId",
"value": "INR",
"namespace": "USER",
"name": "Settings Name",
"dataType": "STRING"
}
],
"account": {
"id": "ACC00001",
"name": "Primary Account",
"invoiceCurrency": "USD",
"aliases": [
"acme_primary",
"[email protected]"
],
"settings": [
{
"id": "accountSettingId",
"value": "INR",
"namespace": "USER",
"name": "Settings Name",
"dataType": "STRING"
}
]
}
}
'

Once a customer is created, use this API to attach a price plan to that customer. Here's what a sample request payload looks like :

curl --request POST \
--url https://api.togai.com/accounts/account_id/price_plans \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"pricePlanDetailsOverride": {
"pricingCycleConfig": {
"interval": "MONTHLY"
},
"rateDetails": {
"ratePlan": {
"pricingModel": "TIERED",
"slabs": [
{
"priceType": "FLAT"
}
]
}
}
},
"mode": "ASSOCIATE",
"pricePlanId": "pp.1zYnCiM9Bpg.lv25y",
"effectiveFrom": "2022-07-04",
"effectiveUntil": "2022-10-04"
}
'

Here are the APIs to ingest single events and batched events. Here's what a sample request payload for a single event looks like :

curl --request POST \
--url https://api.togai.com/ingest \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"event": {
"timestamp": "2022-06-15T07:30:35.123",
"schemaName": "travelCompletedEvent",
"id": "c0b1306d-f506-43a6-856b-69221efaee6b",
"accountId": "1",
"attributes": [
{
"name": "distanceTravelled",
"value": "50",
"unit": "Miles"
},
{
"name": "timeSpent",
"value": "60",
"unit": "Minutes"
}
],
"dimensions": {
"location": "Seattle",
"costCenterCode": "1234",
"travelType": "Business"
}
}
}
'

Once this event is processed, this data flows into the usage meter or feature through the schema and the price plan picks it up and uses it to generate an ongoing invoice. Let's look at the money now, shall we?

Did this answer your question?