curl --request POST \
--url https://api.togai.com/event_schema \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "ride_completed",
"description": "Cab ride completed",
"attributes": [
{
"name": "distance"
},
{
"name": "time"
}
],
"dimensions": [
{
"name": "city"
},
{
"name": "vehicle_type"
}
],
"enrichments": {
"dependencies": [
{
"type": "SETTING",
"key": "setting.user.meters_per_km",
"name": "meters_per_km"
}
],
"fields": [
{
"name": "distanceInKM",
"type": "ATTRIBUTE",
"enrichmentType": "JSON_LOGIC",
"value": "{\"/\":[{\"var\":[\"attribute.distance\"]},{\"var\":[\"dependencies.meters_per_km\"]}]}",
"order": 1
},
{
"name": "rideType",
"type": "DIMENSION",
"enrichmentType": "JSON_LOGIC",
"value": "{\"if\":[{\"<=\":[100,{\"var\":[\"attribute.distanceInKM\"]}]},\"long_distance\",\"short_distance\"]}",
"order": 2
}
]
}
}
'import requests
url = "https://api.togai.com/event_schema"
payload = {
"name": "ride_completed",
"description": "Cab ride completed",
"attributes": [{ "name": "distance" }, { "name": "time" }],
"dimensions": [{ "name": "city" }, { "name": "vehicle_type" }],
"enrichments": {
"dependencies": [
{
"type": "SETTING",
"key": "setting.user.meters_per_km",
"name": "meters_per_km"
}
],
"fields": [
{
"name": "distanceInKM",
"type": "ATTRIBUTE",
"enrichmentType": "JSON_LOGIC",
"value": "{\"/\":[{\"var\":[\"attribute.distance\"]},{\"var\":[\"dependencies.meters_per_km\"]}]}",
"order": 1
},
{
"name": "rideType",
"type": "DIMENSION",
"enrichmentType": "JSON_LOGIC",
"value": "{\"if\":[{\"<=\":[100,{\"var\":[\"attribute.distanceInKM\"]}]},\"long_distance\",\"short_distance\"]}",
"order": 2
}
]
}
}
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: 'ride_completed',
description: 'Cab ride completed',
attributes: [{name: 'distance'}, {name: 'time'}],
dimensions: [{name: 'city'}, {name: 'vehicle_type'}],
enrichments: {
dependencies: [{type: 'SETTING', key: 'setting.user.meters_per_km', name: 'meters_per_km'}],
fields: [
{
name: 'distanceInKM',
type: 'ATTRIBUTE',
enrichmentType: 'JSON_LOGIC',
value: '{"/":[{"var":["attribute.distance"]},{"var":["dependencies.meters_per_km"]}]}',
order: 1
},
{
name: 'rideType',
type: 'DIMENSION',
enrichmentType: 'JSON_LOGIC',
value: '{"if":[{"<=":[100,{"var":["attribute.distanceInKM"]}]},"long_distance","short_distance"]}',
order: 2
}
]
}
})
};
fetch('https://api.togai.com/event_schema', 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.togai.com/event_schema",
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' => 'ride_completed',
'description' => 'Cab ride completed',
'attributes' => [
[
'name' => 'distance'
],
[
'name' => 'time'
]
],
'dimensions' => [
[
'name' => 'city'
],
[
'name' => 'vehicle_type'
]
],
'enrichments' => [
'dependencies' => [
[
'type' => 'SETTING',
'key' => 'setting.user.meters_per_km',
'name' => 'meters_per_km'
]
],
'fields' => [
[
'name' => 'distanceInKM',
'type' => 'ATTRIBUTE',
'enrichmentType' => 'JSON_LOGIC',
'value' => '{"/":[{"var":["attribute.distance"]},{"var":["dependencies.meters_per_km"]}]}',
'order' => 1
],
[
'name' => 'rideType',
'type' => 'DIMENSION',
'enrichmentType' => 'JSON_LOGIC',
'value' => '{"if":[{"<=":[100,{"var":["attribute.distanceInKM"]}]},"long_distance","short_distance"]}',
'order' => 2
]
]
]
]),
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.togai.com/event_schema"
payload := strings.NewReader("{\n \"name\": \"ride_completed\",\n \"description\": \"Cab ride completed\",\n \"attributes\": [\n {\n \"name\": \"distance\"\n },\n {\n \"name\": \"time\"\n }\n ],\n \"dimensions\": [\n {\n \"name\": \"city\"\n },\n {\n \"name\": \"vehicle_type\"\n }\n ],\n \"enrichments\": {\n \"dependencies\": [\n {\n \"type\": \"SETTING\",\n \"key\": \"setting.user.meters_per_km\",\n \"name\": \"meters_per_km\"\n }\n ],\n \"fields\": [\n {\n \"name\": \"distanceInKM\",\n \"type\": \"ATTRIBUTE\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"/\\\":[{\\\"var\\\":[\\\"attribute.distance\\\"]},{\\\"var\\\":[\\\"dependencies.meters_per_km\\\"]}]}\",\n \"order\": 1\n },\n {\n \"name\": \"rideType\",\n \"type\": \"DIMENSION\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"if\\\":[{\\\"<=\\\":[100,{\\\"var\\\":[\\\"attribute.distanceInKM\\\"]}]},\\\"long_distance\\\",\\\"short_distance\\\"]}\",\n \"order\": 2\n }\n ]\n }\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.togai.com/event_schema")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"ride_completed\",\n \"description\": \"Cab ride completed\",\n \"attributes\": [\n {\n \"name\": \"distance\"\n },\n {\n \"name\": \"time\"\n }\n ],\n \"dimensions\": [\n {\n \"name\": \"city\"\n },\n {\n \"name\": \"vehicle_type\"\n }\n ],\n \"enrichments\": {\n \"dependencies\": [\n {\n \"type\": \"SETTING\",\n \"key\": \"setting.user.meters_per_km\",\n \"name\": \"meters_per_km\"\n }\n ],\n \"fields\": [\n {\n \"name\": \"distanceInKM\",\n \"type\": \"ATTRIBUTE\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"/\\\":[{\\\"var\\\":[\\\"attribute.distance\\\"]},{\\\"var\\\":[\\\"dependencies.meters_per_km\\\"]}]}\",\n \"order\": 1\n },\n {\n \"name\": \"rideType\",\n \"type\": \"DIMENSION\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"if\\\":[{\\\"<=\\\":[100,{\\\"var\\\":[\\\"attribute.distanceInKM\\\"]}]},\\\"long_distance\\\",\\\"short_distance\\\"]}\",\n \"order\": 2\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/event_schema")
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 \"name\": \"ride_completed\",\n \"description\": \"Cab ride completed\",\n \"attributes\": [\n {\n \"name\": \"distance\"\n },\n {\n \"name\": \"time\"\n }\n ],\n \"dimensions\": [\n {\n \"name\": \"city\"\n },\n {\n \"name\": \"vehicle_type\"\n }\n ],\n \"enrichments\": {\n \"dependencies\": [\n {\n \"type\": \"SETTING\",\n \"key\": \"setting.user.meters_per_km\",\n \"name\": \"meters_per_km\"\n }\n ],\n \"fields\": [\n {\n \"name\": \"distanceInKM\",\n \"type\": \"ATTRIBUTE\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"/\\\":[{\\\"var\\\":[\\\"attribute.distance\\\"]},{\\\"var\\\":[\\\"dependencies.meters_per_km\\\"]}]}\",\n \"order\": 1\n },\n {\n \"name\": \"rideType\",\n \"type\": \"DIMENSION\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"if\\\":[{\\\"<=\\\":[100,{\\\"var\\\":[\\\"attribute.distanceInKM\\\"]}]},\\\"long_distance\\\",\\\"short_distance\\\"]}\",\n \"order\": 2\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"name": "ride_completed",
"description": "Cab ride completed",
"version": 1,
"attributes": [
{
"name": "distance"
},
{
"name": "time"
}
],
"dimensions": [
{
"name": "city"
},
{
"name": "ride_type"
}
],
"featureDetails": {
"featureId": "feature.1122.ahoiud",
"attributeName": "distance"
},
"eventLevelRevenue": false
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}Create an event schema
Create an event schema with attributes and dimensions to process events.
curl --request POST \
--url https://api.togai.com/event_schema \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "ride_completed",
"description": "Cab ride completed",
"attributes": [
{
"name": "distance"
},
{
"name": "time"
}
],
"dimensions": [
{
"name": "city"
},
{
"name": "vehicle_type"
}
],
"enrichments": {
"dependencies": [
{
"type": "SETTING",
"key": "setting.user.meters_per_km",
"name": "meters_per_km"
}
],
"fields": [
{
"name": "distanceInKM",
"type": "ATTRIBUTE",
"enrichmentType": "JSON_LOGIC",
"value": "{\"/\":[{\"var\":[\"attribute.distance\"]},{\"var\":[\"dependencies.meters_per_km\"]}]}",
"order": 1
},
{
"name": "rideType",
"type": "DIMENSION",
"enrichmentType": "JSON_LOGIC",
"value": "{\"if\":[{\"<=\":[100,{\"var\":[\"attribute.distanceInKM\"]}]},\"long_distance\",\"short_distance\"]}",
"order": 2
}
]
}
}
'import requests
url = "https://api.togai.com/event_schema"
payload = {
"name": "ride_completed",
"description": "Cab ride completed",
"attributes": [{ "name": "distance" }, { "name": "time" }],
"dimensions": [{ "name": "city" }, { "name": "vehicle_type" }],
"enrichments": {
"dependencies": [
{
"type": "SETTING",
"key": "setting.user.meters_per_km",
"name": "meters_per_km"
}
],
"fields": [
{
"name": "distanceInKM",
"type": "ATTRIBUTE",
"enrichmentType": "JSON_LOGIC",
"value": "{\"/\":[{\"var\":[\"attribute.distance\"]},{\"var\":[\"dependencies.meters_per_km\"]}]}",
"order": 1
},
{
"name": "rideType",
"type": "DIMENSION",
"enrichmentType": "JSON_LOGIC",
"value": "{\"if\":[{\"<=\":[100,{\"var\":[\"attribute.distanceInKM\"]}]},\"long_distance\",\"short_distance\"]}",
"order": 2
}
]
}
}
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: 'ride_completed',
description: 'Cab ride completed',
attributes: [{name: 'distance'}, {name: 'time'}],
dimensions: [{name: 'city'}, {name: 'vehicle_type'}],
enrichments: {
dependencies: [{type: 'SETTING', key: 'setting.user.meters_per_km', name: 'meters_per_km'}],
fields: [
{
name: 'distanceInKM',
type: 'ATTRIBUTE',
enrichmentType: 'JSON_LOGIC',
value: '{"/":[{"var":["attribute.distance"]},{"var":["dependencies.meters_per_km"]}]}',
order: 1
},
{
name: 'rideType',
type: 'DIMENSION',
enrichmentType: 'JSON_LOGIC',
value: '{"if":[{"<=":[100,{"var":["attribute.distanceInKM"]}]},"long_distance","short_distance"]}',
order: 2
}
]
}
})
};
fetch('https://api.togai.com/event_schema', 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.togai.com/event_schema",
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' => 'ride_completed',
'description' => 'Cab ride completed',
'attributes' => [
[
'name' => 'distance'
],
[
'name' => 'time'
]
],
'dimensions' => [
[
'name' => 'city'
],
[
'name' => 'vehicle_type'
]
],
'enrichments' => [
'dependencies' => [
[
'type' => 'SETTING',
'key' => 'setting.user.meters_per_km',
'name' => 'meters_per_km'
]
],
'fields' => [
[
'name' => 'distanceInKM',
'type' => 'ATTRIBUTE',
'enrichmentType' => 'JSON_LOGIC',
'value' => '{"/":[{"var":["attribute.distance"]},{"var":["dependencies.meters_per_km"]}]}',
'order' => 1
],
[
'name' => 'rideType',
'type' => 'DIMENSION',
'enrichmentType' => 'JSON_LOGIC',
'value' => '{"if":[{"<=":[100,{"var":["attribute.distanceInKM"]}]},"long_distance","short_distance"]}',
'order' => 2
]
]
]
]),
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.togai.com/event_schema"
payload := strings.NewReader("{\n \"name\": \"ride_completed\",\n \"description\": \"Cab ride completed\",\n \"attributes\": [\n {\n \"name\": \"distance\"\n },\n {\n \"name\": \"time\"\n }\n ],\n \"dimensions\": [\n {\n \"name\": \"city\"\n },\n {\n \"name\": \"vehicle_type\"\n }\n ],\n \"enrichments\": {\n \"dependencies\": [\n {\n \"type\": \"SETTING\",\n \"key\": \"setting.user.meters_per_km\",\n \"name\": \"meters_per_km\"\n }\n ],\n \"fields\": [\n {\n \"name\": \"distanceInKM\",\n \"type\": \"ATTRIBUTE\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"/\\\":[{\\\"var\\\":[\\\"attribute.distance\\\"]},{\\\"var\\\":[\\\"dependencies.meters_per_km\\\"]}]}\",\n \"order\": 1\n },\n {\n \"name\": \"rideType\",\n \"type\": \"DIMENSION\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"if\\\":[{\\\"<=\\\":[100,{\\\"var\\\":[\\\"attribute.distanceInKM\\\"]}]},\\\"long_distance\\\",\\\"short_distance\\\"]}\",\n \"order\": 2\n }\n ]\n }\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.togai.com/event_schema")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"ride_completed\",\n \"description\": \"Cab ride completed\",\n \"attributes\": [\n {\n \"name\": \"distance\"\n },\n {\n \"name\": \"time\"\n }\n ],\n \"dimensions\": [\n {\n \"name\": \"city\"\n },\n {\n \"name\": \"vehicle_type\"\n }\n ],\n \"enrichments\": {\n \"dependencies\": [\n {\n \"type\": \"SETTING\",\n \"key\": \"setting.user.meters_per_km\",\n \"name\": \"meters_per_km\"\n }\n ],\n \"fields\": [\n {\n \"name\": \"distanceInKM\",\n \"type\": \"ATTRIBUTE\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"/\\\":[{\\\"var\\\":[\\\"attribute.distance\\\"]},{\\\"var\\\":[\\\"dependencies.meters_per_km\\\"]}]}\",\n \"order\": 1\n },\n {\n \"name\": \"rideType\",\n \"type\": \"DIMENSION\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"if\\\":[{\\\"<=\\\":[100,{\\\"var\\\":[\\\"attribute.distanceInKM\\\"]}]},\\\"long_distance\\\",\\\"short_distance\\\"]}\",\n \"order\": 2\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/event_schema")
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 \"name\": \"ride_completed\",\n \"description\": \"Cab ride completed\",\n \"attributes\": [\n {\n \"name\": \"distance\"\n },\n {\n \"name\": \"time\"\n }\n ],\n \"dimensions\": [\n {\n \"name\": \"city\"\n },\n {\n \"name\": \"vehicle_type\"\n }\n ],\n \"enrichments\": {\n \"dependencies\": [\n {\n \"type\": \"SETTING\",\n \"key\": \"setting.user.meters_per_km\",\n \"name\": \"meters_per_km\"\n }\n ],\n \"fields\": [\n {\n \"name\": \"distanceInKM\",\n \"type\": \"ATTRIBUTE\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"/\\\":[{\\\"var\\\":[\\\"attribute.distance\\\"]},{\\\"var\\\":[\\\"dependencies.meters_per_km\\\"]}]}\",\n \"order\": 1\n },\n {\n \"name\": \"rideType\",\n \"type\": \"DIMENSION\",\n \"enrichmentType\": \"JSON_LOGIC\",\n \"value\": \"{\\\"if\\\":[{\\\"<=\\\":[100,{\\\"var\\\":[\\\"attribute.distanceInKM\\\"]}]},\\\"long_distance\\\",\\\"short_distance\\\"]}\",\n \"order\": 2\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"name": "ride_completed",
"description": "Cab ride completed",
"version": 1,
"attributes": [
{
"name": "distance"
},
{
"name": "time"
}
],
"dimensions": [
{
"name": "city"
},
{
"name": "ride_type"
}
],
"featureDetails": {
"featureId": "feature.1122.ahoiud",
"attributeName": "distance"
},
"eventLevelRevenue": false
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Payload to create event schema
Request to create event schema
Name of the event. Must be unique for an organization.
50^[\sa-zA-Z0-9_-]*$50Show child attributes
Show child attributes
50Show child attributes
Show child attributes
Description of the event
255Show child attributes
Show child attributes
List of fields that can be used for filtering in usage meter
Template used to generate event id based on event payload
Response
Response for Create and Get event schema requests
Structure of an event schema
Name of the event. Must be unique for an organization.
50^[\sa-zA-Z0-9_-]*$Version of event schema
x >= 11
Description of the event
255Status of event schema
- DRAFT - Schema is in draft state
- ACTIVE - Schema is currently active
- INACTIVE - Schema is currently inactive
- ARCHIVED - Older version of event schema
DRAFT, ACTIVE, INACTIVE, ARCHIVED "DRAFT"
50Show child attributes
Show child attributes
50Show child attributes
Show child attributes
details of feature associated with event schema with attribute name
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Template used to generate event id based on event payload
