Skip to main content
POST
/
event_schema
Create an event schema
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
      }
    ]
  }
}
'
{
  "name": "ride_completed",
  "description": "Cab ride completed",
  "version": 1,
  "status": "DRAFT",
  "attributes": [
    {
      "name": "distance"
    },
    {
      "name": "time"
    }
  ],
  "dimensions": [
    {
      "name": "city"
    },
    {
      "name": "ride_type"
    }
  ],
  "featureDetails": {
    "featureId": "feature.1122.ahoiud",
    "attributeName": "distance"
  },
  "eventLevelRevenue": false
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Payload to create event schema

Request to create event schema

name
string
required

Name of the event. Must be unique for an organization.

Maximum string length: 50
Pattern: ^[\sa-zA-Z0-9_-]*$
attributes
object[]
required
Maximum array length: 50
dimensions
object[]
required
Maximum array length: 50
description
string

Description of the event

Maximum string length: 255
enrichments
object

Response

Response for Create and Get event schema requests

Structure of an event schema

name
string
required

Name of the event. Must be unique for an organization.

Maximum string length: 50
Pattern: ^[\sa-zA-Z0-9_-]*$
version
integer<int32>
required

Version of event schema

Required range: x >= 1
Example:

1

description
string

Description of the event

Maximum string length: 255
status
enum<string>

Status 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
Available options:
DRAFT,
ACTIVE,
INACTIVE,
ARCHIVED
Example:

"DRAFT"

attributes
object[]
Maximum array length: 50
dimensions
object[]
Maximum array length: 50
featureDetails
object

details of feature associated with event schema with attribute name

enrichments
object
eventLevelRevenue
boolean
createdAt
string<date-time>
updatedAt
string<date-time>