Remove message actions

Showing JavaScript examples.

This guide shows you how to remove a previously added message action from a message.

  • Remove an action using its own action timetoken and the target message's timetoken.
  • Confirm the removal from the empty response PubNub returns.
  • Recognize the status code that means the action was deleted but its event wasn't published.

Every call on this page needs an SDK instance initialized with your publish key, the target message's timetoken, and the action's own timetoken. That last value is what adding the action returned, or one you looked up with Retrieve historical message actions. Examples use the JavaScript, Swift, Java, Kotlin, C#, Python, and Objective-C SDKs. For any other language, refer to Available SDKs.

Before removing a message action, confirm the prerequisites are in place.

Remove an action​

Call the remove-action method with the channel, the message's timetoken, and the action's own timetoken.

1await pubnub.removeMessageAction({
2 channel: 'chats.room1',
3 messageTimetoken: '15610547826969050',
4 actionTimetoken: '15610547826970050',
5});

Confirm the removal​

A successful call returns an empty response. There's nothing to roll back on the message itself, only the action record to delete, so PubNub has nothing else to report back.

A 207 status means PubNub deleted the action but couldn't publish the deletion event to subscribers. Treat the action as removed. A client that fetches historical message actions for this channel afterward won't see it either, even though no live event announced the removal.

Was this page useful?

Last updated on