---
title: "Correct an ingested event"
method: POST
path: "/events/correction"
tags: ["Event Management"]
---

# Correct an ingested event

`POST /events/correction`

## Request

- Base URL: `https://api.togai.com`
- URL: `https://api.togai.com/events/correction`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/togaihq/apis/togai-apis/docs/events/correction/post.ts> (a function with typed inputs; its response is checked against the schema)

#### 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

## Query parameters

- `action` 'UNDO' | 'REDO' | 'REDO_EVENT', required
- `require_confirmation` boolean

## Request body

- EventCorrectionRequest: Event Correction Payload for event correction
  - `event` Event: Contents of the event
    - `schemaName` string, required: Name of the Event Schema. Know more about [event schema](https://docs.togai.com/docs/event-schemas)
    - `id` string: Togai restricts users to ingest events with same id within a period of *45 days*. This restriction is common for [/entitled API](/api-reference/entitlements/ingest-event-if-a-user-is-entitled-to-a-feature), [/ingest API](/api-reference/event-ingestion/ingest-events-to-togai) and [/ingestBatch API](/api-reference/event-ingestion/ingest-events-to-togai-in-batch). i.e, an id used on /ingest API will not be allowed on /ingestBatch or /entitled APIs
    - `timestamp` string, date-time, required: Source time stamp of the event. This timestamp must be in ISO 8601 format.
    - `accountId` string, required: The event will be associated with the provided account
    - `attributes` Attribute[], required: Attributes are numeric values. It can be usage metric which you push to Togai
      - `name` string, required: Name of the event attribute
      - `value` string, required: Value of the event attribute
      - `unit` string: Unit with which the attribute value was measured. Natively supported units - "Meters, Miles, Kilometers, Grams, Kilograms, ounces, Pounds, Minutes, Hours, Seconds, Milliseconds, Microseconds, None". Clients are free to add any other custom units.
    - `dimensions` Dimensions, required: Dimensions are tags/labels associated with the events.

## Response `200`

Success response

- EventsCorrectionResponse: Events Correction response
  - `data` EventCorrectionInfo[], required
    - `referenceId` string, required: Unique id generated by Togai to identify an event uniquely
    - `eventPayload` Event, required: Contents of the event
      - `schemaName` string, required: Name of the Event Schema. Know more about [event schema](https://docs.togai.com/docs/event-schemas)
      - `id` string: Togai restricts users to ingest events with same id within a period of *45 days*. This restriction is common for [/entitled API](/api-reference/entitlements/ingest-event-if-a-user-is-entitled-to-a-feature), [/ingest API](/api-reference/event-ingestion/ingest-events-to-togai) and [/ingestBatch API](/api-reference/event-ingestion/ingest-events-to-togai-in-batch). i.e, an id used on /ingest API will not be allowed on /ingestBatch or /entitled APIs
      - `timestamp` string, date-time, required: Source time stamp of the event. This timestamp must be in ISO 8601 format.
      - `accountId` string, required: The event will be associated with the provided account
      - `attributes` Attribute[], required: Attributes are numeric values. It can be usage metric which you push to Togai
        - `name` string, required: Name of the event attribute
        - `value` string, required: Value of the event attribute
        - `unit` string: Unit with which the attribute value was measured. Natively supported units - "Meters, Miles, Kilometers, Grams, Kilograms, ounces, Pounds, Minutes, Hours, Seconds, Milliseconds, Microseconds, None". Clients are free to add any other custom units.
      - `dimensions` Dimensions, required: Dimensions are tags/labels associated with the events.
    - `ingestionStatus` IngestionStatus, required: Status about the event ingestion.
      - `status` 'INGESTION_IN_PROGRESS' | 'INGESTION_FAILED' | 'INGESTION_FAILED_SCHEMA_NOT_DEFINED' | 'INGESTION_FAILED_ENRICHMENT_FAILED' | 'INGESTION_FAILED_UNITS_INVALID' | 'INGESTION_COMPLETED_NO_MATCHING_METERS' | 'INGESTION_COMPLETED_EVENT_METERED' | 'INGESTION_COMPLETED_EVENT_NOT_METERED' | 'INGESTION_FAILED_PAST_GRACE_PERIOD' | 'INGESTION_FAILED_ACCOUNT_NOT_FOUND' | 'INGESTION_FAILED_DUPLICATE_EVENT' | 'INGESTION_FAILED_NO_EVENT_ID' | 'INGESTION_FAILED_INVALID_NAMED_LICENSE_EVENT' | 'INGESTION_FAILED_INSUFFICIENT_CREDITS' | 'REVERTED' | 'UNKNOWN', required: Ingestion status
      - `statusDescription` string
    - `customerId` string: The associated account belongs to this customer
    - `source` EventSource: Source of ingestion of event
      - `id` string, required: Unique identifier representing the source
      - `type` string, required: Type of source
    - `createdAt` string, date-time, required: Created time stamp of the event. This timestamp must be in ISO 8601 format.
    - `status` 'REVERTED' | 'REVERTED_AND_REINGESTED' | 'FAILED', required: Status of the event requested for correction
    - `reason` string, required: Status description of the event requested for correction

## Other responses

- `400`: Bad request. Please check the response message for failure details.
- `401`: Credential is not valid. Please check the response message for failure details.
- `403`: Credential does not have access to get events.
- `429`: Request throttled. Please check the response message on the failure details.
- `default`: Error response

## Changes

- **2024-05-14** `d078d3562056`: 1 breaking, 1 warning, 1 info
  - the `data/items/allOf[#/components/schemas/EventWithStatus]/eventPayload/dimensions/additionalProperties/` response property's maxLength was increased from `50` to `200` for the response status `200`
  - added the new `INGESTION_FAILED_INSUFFICIENT_CREDITS` enum value to the `data/items/allOf[#/components/schemas/EventWithStatus]/ingestionStatus/status` response property for the response status `200`
  - the `event/dimensions/additionalProperties/` request property's maxLength was increased from `50` to `200`
- **2024-03-11** `cc0b10fb537e`: 1 warning, 1 info
  - added the new `INGESTION_FAILED_INVALID_NAMED_LICENSE_EVENT` enum value to the `data/items/allOf[#/components/schemas/EventWithStatus]/ingestionStatus/status` response property for the response status `200`
  - added the new optional `query` request parameter `require_confirmation`
- **2024-03-01** `6fb940b0dad9`: 1 info
  - endpoint added
- **2023-09-02** `6b13f6f47735`: 1 breaking
  - api path removed without deprecation

[Operation history](https://skmtc.dev/togaihq/apis/togai-apis/changes/events/correction/post.md)

---

[API](https://skmtc.dev/togaihq/apis/togai-apis.md) - [All operations](https://skmtc.dev/togaihq/apis/togai-apis/llms.txt) - [OpenAPI document](https://skmtc.dev/togaihq/apis/togai-apis/revisions/442f5d8f4aa0?raw)
