Using the API

Understanding the Data Model

Events

Events store any change made to a database. When an INSERT, UPDATE, or DELETE SQL command is issued an event is created for every record in a table that changes as a result of the command. The columns that were changed are stored in the event's associated columns. All events are part of a transaction

Columns

Columns contain the raw data for every column changed on an event. It stores the name, type, previous value and current value of the column. The data is stored in the same binary format as received from the database protocol.

Transactions

Transactions are groups of related events. All events that are generated during a SQL transaction are part of the same transaction. Any data that is written to the <<changebaseMetadataTable>> is attached to the transactions metadata. All events share the same metadata.

Metadata

Metadata is used to track additional context about transactions and events. For example, you could track the id of the user making the change. For more details about metadata, see our Metadata page.

Creating Events

curl --request POST \
     --url https://changebase.io/events \
     --header 'API-Key: CHANGEBASE-API-KEY' \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --data '
{
     "event": {
          "lsn": "1",
          "type": "insert",
          "schema": "repellat_sequi_voluptata",
          "table": "at_pariatur_ins",
          "timestamp": "2022-04-26T14:58:13.855-04:00"
     }
}
'