Overwriting events

You can overwrite an existing event, for example to change a parameter value or correct an error.

This is done by sending an event (as described in Sending events) with the same action, occurrence time, and event salt as an existing event.

When you overwrite the event, it is replaced entirely by the new one. The time of saving in the database changes to the new event, but the time of occurrence doesn’t.

Requirements and limitations

  • The original event (the one which you want to overwrite) had to be sent with an eventSalt parameter.
    • An eventSalt must be unique. For example, you can concatenate the action, profile ID, and timestamp.
    • The eventSalt can’t be retrieved with an event! You need to implement your own mechanism for keeping the values for later use or create the value in such a way that it can be re-created.
    • eventSalt can’t be added to an existing event.
  • Both events must have the same action.
  • Both events must belong to the same profile’s history.
  • Both events must have the same time
    • In transaction events, this parameter is called recordedAt
    • It isn’t possible to change the time of occurrence by overwriting an event.
    • This must be the time saved in the database. If your original event had a timestamp that was in the future in relation to the time of sending the event, that timestamp was rejected and you must first retrieve the event and check the time it was saved with (in such a case, it will be the same as the time of receiving the event in Synerise).

Example

Send first event

This is the original event:

curl --location --request POST 'https://api.synerise.com/v4/events/custom' \
--header 'Authorization: Bearer ey...RtH_g' \
--header 'Api-Version: 4.4' \
--header 'Content-Type: application/json' \
--data-raw '{
    "action": "dog.bark",
    "eventSalt": "dogbark50921599992022-12-13T15:25:08.861Z",
    "client": {
        "id": 5092159999
    },
    "time": "2022-12-13T15:25:08.861Z",
    "params": {
        "loudness": 3,
        "mood": "happy",
        "mailmanScared": true
    },
    "label": "bark"
}'

Get original event

This is the event when you retrieve it (for example, by getting all events from a profile):

{
    "time": "2022-12-13T15:24:49Z",
    "action": "dog.bark",
    "label": "",
    "client": {
        "id": 5092159999,
        "email": "e0097757-d1e2-44ac-ba3c-d97979a354c1@anonymous.invalid",
        "uuid": "e0097757-d1e2-44ac-ba3c-d97979a354c1"
    },
    "params": {
        "eventCreateTime": "2022-12-13T15:25:08.861Z",
        "mood": "happy",
        "ip": "13.93.68.194",
        "loudness": 3,
        "mailmanScared": true
    }
}

Note that the eventSalt is not retrieved, and some parameters were added automatically when the event was processed.

Overwrite event

Let’s overwrite the event by:

  • changing the loudness parameter
  • removing the mailmanScared parameter
  • adding the mailDelivered parameter
curl --location --request POST 'https://api.synerise.com/v4/events/custom' \
--header 'Authorization: Bearer ey...RtH_g' \
--header 'Api-Version: 4.4' \
--header 'Content-Type: application/json' \
--data-raw '{
    "action": "dog.bark",
    "eventSalt": "dogbark50921599992022-12-13T15:25:08.861Z",
    "client": {
        "id": 5092159999
    },
    "time": "2022-12-13T15:25:08.861Z",
    "params": {
        "loudness": 1,
        "mood": "happy",
        "mailDelivered": true
    },
    "label": "bark"
}'

Get overwritten event

When you retrieve the same event:

  • the parameters are changed according to the new data you sent.
  • the eventCreateTime parameter is the time of saving the new instance in the database, and event retention takes the new time into account.
  • the occurrence time (time) is the same.
  • the updated event also replaces the original event on the profile’s card view.
{
    "time": "2022-12-13T15:25:08.861Z",
    "action": "dog.bark",
    "label": "",
    "client": {
        "id": 5092159999,
        "email": "e0097757-d1e2-44ac-ba3c-d97979a354c1@anonymous.invalid",
        "uuid": "e0097757-d1e2-44ac-ba3c-d97979a354c1"
    },
    "params": {
        "eventCreateTime": "2022-12-13T15:48:02.746Z",
        "mood": "happy",
        "ip": "13.93.68.194",
        "loudness": 1,
        "mailDelivered": true
    }
}
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker