Correct an ingested event
curl --request POST \
--url https://api.togai.com/events/correction \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.togai.com/events/correction"
payload = {}
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({})
};
fetch('https://api.togai.com/events/correction', 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/events/correction",
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([
]),
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/events/correction"
payload := strings.NewReader("{}")
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/events/correction")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/events/correction")
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 = "{}"
response = http.request(request)
puts response.read_body{
"data": [
{
"referenceId": "event.21OpEx4DHQu.CZlyh",
"eventPayload": {
"timestamp": "2023-02-23T14:25:10Z",
"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"
}
},
"ingestionStatus": {
"status": "INGESTION_COMPLETED_EVENT_NOT_METERED",
"statusDescription": "Event ingestion completed successfully but the event is not associated with any bill plan."
},
"customerId": "CUS0001",
"source": {
"id": "ENTITLED",
"type": "ENTITLED"
},
"createdAt": "2023-02-23T14:25:10Z",
"status": "REVERTED",
"reason": "Event Reverted"
},
{
"referenceId": "event.23OrTx4FGQu.XVpzf",
"eventPayload": {
"timestamp": "2023-02-23T14:25:10Z",
"schemaName": "smsSentEvent",
"id": "sdvb325j-f506-43a6-856b-69221efaee6b",
"accountId": "1",
"attributes": [
{
"name": "smsCount",
"value": "50",
"unit": "count"
}
],
"dimensions": {}
},
"ingestionStatus": {
"status": "INGESTION_COMPLETED_EVENT_NOT_METERED",
"statusDescription": "Event ingestion completed successfully but the event is not associated with any bill plan."
},
"customerId": "CUS0001",
"source": {
"id": "",
"type": ""
},
"createdAt": "2023-01-01T14:25:10Z",
"status": "FAILED",
"reason": "Event was ingested in past pricing cycle"
}
]
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<Reason message>"
}Event Management
Correct an ingested event
This API lets you to correct events. Available in both synchronous and asynchronous mode
- Usages: Reduction of all usages associated with this event
- Revenue: Reduction of all revenues associated with this event
- Entitlements: Entitlements(Feature Credits) consumed by this event are granted back to the account.
Possible Actions:
- UNDO: Undo all usages, revenue and entitlements associated with an event
- REDO: Performs UNDO and re-ingests the same event
- REDO_EVENT: Performs UNDO and re-ingests the correction payload of the event
POST
/
events
/
correction
Correct an ingested event
curl --request POST \
--url https://api.togai.com/events/correction \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.togai.com/events/correction"
payload = {}
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({})
};
fetch('https://api.togai.com/events/correction', 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/events/correction",
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([
]),
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/events/correction"
payload := strings.NewReader("{}")
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/events/correction")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/events/correction")
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 = "{}"
response = http.request(request)
puts response.read_body{
"data": [
{
"referenceId": "event.21OpEx4DHQu.CZlyh",
"eventPayload": {
"timestamp": "2023-02-23T14:25:10Z",
"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"
}
},
"ingestionStatus": {
"status": "INGESTION_COMPLETED_EVENT_NOT_METERED",
"statusDescription": "Event ingestion completed successfully but the event is not associated with any bill plan."
},
"customerId": "CUS0001",
"source": {
"id": "ENTITLED",
"type": "ENTITLED"
},
"createdAt": "2023-02-23T14:25:10Z",
"status": "REVERTED",
"reason": "Event Reverted"
},
{
"referenceId": "event.23OrTx4FGQu.XVpzf",
"eventPayload": {
"timestamp": "2023-02-23T14:25:10Z",
"schemaName": "smsSentEvent",
"id": "sdvb325j-f506-43a6-856b-69221efaee6b",
"accountId": "1",
"attributes": [
{
"name": "smsCount",
"value": "50",
"unit": "count"
}
],
"dimensions": {}
},
"ingestionStatus": {
"status": "INGESTION_COMPLETED_EVENT_NOT_METERED",
"statusDescription": "Event ingestion completed successfully but the event is not associated with any bill plan."
},
"customerId": "CUS0001",
"source": {
"id": "",
"type": ""
},
"createdAt": "2023-01-01T14:25:10Z",
"status": "FAILED",
"reason": "Event was ingested in past pricing cycle"
}
]
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<Reason message>"
}Query Parameters: Allowed filter combinations
All matching events will be considered for correction
- Sync mode: Maximum of first 30 events matching the filters with the default sort order being EVENT_SOURCE_TIME DESC, EVENT_ID ASC can be corrected in a single request.
- Async mode: When query parameter async = true is given, events matching the filters will be considered for correction and takes place in background.
Status of background job can be obtained using List Jobs API
Query Parameters
Query Parameters
string
required
Unique identifier of the account corresponding to the event
string
Unique identifier of an event generated by Togai for reference
string
Identifier of an event provided by the user
string
Timestamp of an event provided by the user
string
Timestamp corresponding to the event ingestion time in Togai
boolean
Determines the mode of the correction. Defaults to false
Allowed Combinations
Allowed Combinations
account_idaccount_id, idaccount_id, event_idaccount_id, event_source_timeaccount_id, event_id, created_ataccount_id, event_id, event_source_timeAuthorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Action to perform in event correction
Available options:
UNDO, REDO, REDO_EVENT Example:
"UNDO"
Specifies whether to start a migration only after a confirmation
Example:
false
Body
application/json
Event Correction Payload for event correction
Contents of the event
Show child attributes
Show child attributes
Response
Success response
Events Correction response
Required array length:
1 - 50 elementsShow child attributes
Show child attributes
