Skip to main content
POST
/
features
Create a Feature and optionally associate with one or more event_schemas
curl --request POST \
  --url https://api.togai.com/features \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "DiscountCredits",
  "schemaAssociations": [
    "event_schema1",
    "event_schema2"
  ]
}
'
import requests

url = "https://api.togai.com/features"

payload = {
"name": "DiscountCredits",
"schemaAssociations": ["event_schema1", "event_schema2"]
}
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: 'DiscountCredits',
schemaAssociations: ['event_schema1', 'event_schema2']
})
};

fetch('https://api.togai.com/features', 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/features",
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' => 'DiscountCredits',
'schemaAssociations' => [
'event_schema1',
'event_schema2'
]
]),
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/features"

payload := strings.NewReader("{\n \"name\": \"DiscountCredits\",\n \"schemaAssociations\": [\n \"event_schema1\",\n \"event_schema2\"\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/features")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"DiscountCredits\",\n \"schemaAssociations\": [\n \"event_schema1\",\n \"event_schema2\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.togai.com/features")

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\": \"DiscountCredits\",\n \"schemaAssociations\": [\n \"event_schema1\",\n \"event_schema2\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "feature.1zYnCiM9Bpg.lv25y",
  "name": "DiscountCredits",
  "displayName": "DiscountCredits",
  "schemaAssociations": [
    {
      "schemaName": "event_schema1",
      "attributeName": "distance"
    },
    {
      "schemaName": "event_schema2",
      "attributeName": "time"
    }
  ],
  "createdAt": "2020-01-01T00:00:00Z",
  "updatedAt": "2020-01-01T00:00:00Z"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}

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 a Feature along the association with event_schemas

Create a Feature stand-alone or associate it with schemas

name
string
required

Name of the feature

Maximum string length: 255
schemaAssociations
object[]
required

Association of a feature with event_schemas

Maximum array length: 50
billableName
string

Billable name of feature. Billable name takes precedence over name to display in invoice.

Maximum string length: 255

Response

Response for Create and Get Feature requests

Represents a Feature

id
string
required
name
string
required
displayName
string
required

Display name of feature. This is an auto-generated field which contains billableName of feature. If billableName is not provided, name will be used as display name.

Maximum string length: 255
schemaAssociations
object[]
required

Association of a feature with event_schemas

Maximum array length: 50
createdAt
string<date-time>
required
billableName
string
Maximum string length: 255
updatedAt
string<date-time>