---
source_url: https://www.pubnub.com/docs/pub-sub/message-actions/remove-message-actions
title: Remove message actions
updated_at: 2026-09-30T07:20:08.000Z
---

# Remove message actions

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

This guide shows you how to remove a previously added [message action](https://www.pubnub.com/docs/pub-sub/message-actions/overview.md) 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](https://www.pubnub.com/docs/pub-sub/message-actions/add-message-actions.md) returned, or one you looked up with [Retrieve historical message actions](https://www.pubnub.com/docs/pub-sub/message-actions/retrieve-historical-message-actions.md). Examples use the JavaScript, Swift, Java, Kotlin, C#, Python, and Objective-C SDKs. For any other language, refer to [Available SDKs](https://www.pubnub.com/docs/getting-started/available-sdks.md).

Before removing a message action, confirm the [prerequisites](https://www.pubnub.com/docs/pub-sub/message-actions/overview.md#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.

### JavaScript

```javascript
await pubnub.removeMessageAction({
  channel: 'chats.room1',
  messageTimetoken: '15610547826969050',
  actionTimetoken: '15610547826970050',
});
```

### Swift

```swift
pubnub.removeMessageActions(
  channel: "chats.room1",
  message: 15610547826969050,
  action: 15610547826970050
) { result in
  switch result {
  case .success:
    print("Action removed")
  case let .failure(error):
    print("failed: \(error.localizedDescription)")
  }
}
```

### Java

```java
pubnub.removeMessageAction()
    .channel("chats.room1")
    .messageTimetoken(15610547826969050L)
    .actionTimetoken(15610547826970050L)
    .async(result -> { /* check result */ });
```

### Kotlin

```kotlin
pubnub.removeMessageAction(
    channel = "chats.room1",
    messageTimetoken = 15610547826969050L,
    actionTimetoken = 15610547826970050L
).async { result -> /* check result */ }
```

### C#

```csharp
pubnub.RemoveMessageAction()
  .Channel("chats.room1")
  .MessageTimetoken(15610547826969050)
  .ActionTimetoken(15610547826970050)
  .Uuid("user-456")
  .Execute(new PNRemoveMessageActionResultExt((result, status) => {
    if (status != null && status.Error) {
      Console.WriteLine(status.ErrorData.Information);
    }
  }));
```

C#'s `RemoveMessageAction()` also needs `Uuid()`, the publisher of the action being removed, returned as `uuid` when the action was [added](https://www.pubnub.com/docs/pub-sub/message-actions/add-message-actions.md).

### Python

```python
def remove_action_callback(result, status):
    if status.is_error():
        print(status.error_data.information)
    else:
        print("Action removed")

pubnub.remove_message_action() \
    .channel("chats.room1") \
    .message_timetoken(15610547826969050) \
    .action_timetoken(15610547826970050) \
    .pn_async(remove_action_callback)
```

### Objective-C

```objectivec
PNRemoveMessageActionRequest *request =
    [PNRemoveMessageActionRequest requestWithChannel:@"chats.room1"
                                     messageTimetoken:@15610547826969050];
request.actionTimetoken = @15610547826970050;

[self.client removeMessageActionWithRequest:request completion:^(PNAcknowledgmentStatus *status) {
  if (!status.isError) {
    NSLog(@"Action removed");
  }
}];
```

## 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](https://www.pubnub.com/docs/pub-sub/message-actions/retrieve-historical-message-actions.md) for this channel afterward won't see it either, even though no live event announced the removal.

## Related tasks

* [Message Actions in PubNub](https://www.pubnub.com/docs/pub-sub/message-actions/overview.md). The type/value model, the event model, and the Message Persistence requirement.
* [Add message actions](https://www.pubnub.com/docs/pub-sub/message-actions/add-message-actions.md). Attach the action, and get the `actionTimetoken` this call needs.
* [Receive message actions](https://www.pubnub.com/docs/pub-sub/message-actions/receive-message-actions.md). Handle the event this call generates on a live subscription.
* [Retrieve historical message actions](https://www.pubnub.com/docs/pub-sub/message-actions/retrieve-historical-message-actions.md). Look up an `actionTimetoken` you didn't keep from the add call.
* [Delete messages](https://www.pubnub.com/docs/data-storage/message-history/delete-messages-from-history.md). Remove the message itself instead of just an action attached to it.

Last updated at: 2026-09-30T07:20:08.000Z
