You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2026/04/22 09:05:06 UTC
(pulsar-site) branch main updated: docs(admin-api-topics): document topic truncate operation (#1121)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
The following commit(s) were added to refs/heads/main by this push:
new 4213953fcbd docs(admin-api-topics): document topic truncate operation (#1121)
4213953fcbd is described below
commit 4213953fcbd3af7cdfdc44608a45bd8a3b93d986
Author: Vishal Kumar Singh <vi...@gmail.com>
AuthorDate: Wed Apr 22 14:35:00 2026 +0530
docs(admin-api-topics): document topic truncate operation (#1121)
Add a "Truncate topic" section in admin-api-topics.md with the
standard pulsar-admin / REST API / Java tab layout, matching the
style of the surrounding Unload/Delete sections.
The feature itself has been available for years via
`pulsar-admin topics truncate` (CmdTopics.TruncateCmd), the
Topics#truncate(String) Java admin API, and
`DELETE /{tenant}/{namespace}/{topic}/truncate` on the broker
(PersistentTopics#truncateTopic). It just wasn't documented on
pulsar.apache.org/docs/*/admin-api-topics/.
Fixes apache/pulsar#24086
---
docs/admin-api-topics.md | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/docs/admin-api-topics.md b/docs/admin-api-topics.md
index 07b57acd1ca..7bbedf87052 100644
--- a/docs/admin-api-topics.md
+++ b/docs/admin-api-topics.md
@@ -257,6 +257,38 @@ admin.topics().unload(topic);
</Tabs>
````
+### Truncate topic
+
+You can truncate a topic in the following ways. The truncate operation moves all cursors to the end of the topic and deletes all inactive ledgers, freeing the storage used by messages that have already been consumed.
+
+````mdx-code-block
+<Tabs groupId="api-choice"
+ defaultValue="pulsar-admin"
+ values={[{"label":"pulsar-admin","value":"pulsar-admin"},{"label":"REST API","value":"REST API"},{"label":"Java","value":"Java"}]}>
+<TabItem value="pulsar-admin">
+
+```shell
+pulsar-admin topics truncate persistent://test-tenant/ns1/tp1
+```
+
+</TabItem>
+<TabItem value="REST API">
+
+[](swagger:/admin/v2/PersistentTopics_truncateTopic)
+
+</TabItem>
+<TabItem value="Java">
+
+```java
+String topic = "persistent://my-tenant/my-namespace/my-topic";
+admin.topics().truncate(topic);
+```
+
+</TabItem>
+
+</Tabs>
+````
+
### Get stats
For the detailed statistics of a topic, see [Pulsar statistics](administration-stats.md#topic-stats).