Skip to content

Latest commit

 

History

History
187 lines (142 loc) · 4.57 KB

quickstart.mdx

File metadata and controls

187 lines (142 loc) · 4.57 KB
title Quickstart
sidebarTitle Quickstart
description This guide walks you through hiding and unhiding replies to Posts in conversations you. Reference for the X API v2 standard tier covering hide replies.
keywords
hide replies quickstart
hide replies tutorial
moderate replies guide

import { Button } from '/snippets/button.mdx';

This guide walks you through hiding and unhiding replies to Posts in conversations you started.

**Prerequisites**

Before you begin, you'll need:

  • A developer account with an approved App
  • User Access Token (OAuth 1.0a or OAuth 2.0 PKCE)

Hide a reply

Get the ID of the reply you want to hide. You can only hide replies to conversations started by the authenticated user.
```
https://x.com/user/status/1232720193182412800
                          └── This is the Post ID
```
curl -X PUT "https://api.x.com/2/tweets/1232720193182412800/hidden" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"hidden": true}'
from xdk import Client
from xdk.oauth1_auth import OAuth1

oauth1 = OAuth1(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET",
    access_token="YOUR_ACCESS_TOKEN",
    access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
)

client = Client(auth=oauth1)

# Hide a reply
response = client.posts.hide_reply("1232720193182412800", hidden=True)
print(f"Hidden: {response.data.hidden}")
import { Client, OAuth1 } from "@xdevplatform/xdk";

const oauth1 = new OAuth1({
  apiKey: "YOUR_API_KEY",
  apiSecret: "YOUR_API_SECRET",
  accessToken: "YOUR_ACCESS_TOKEN",
  accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
});

const client = new Client({ oauth1 });

// Hide a reply
const response = await client.posts.hideReply("1232720193182412800", {
  hidden: true,
});
console.log(`Hidden: ${response.data?.hidden}`);
```json { "data": { "hidden": true } } ```
The reply is now hidden from the main conversation view. Users can still see it by clicking "View hidden replies."

Unhide a reply

To make a hidden reply visible again:

curl -X PUT "https://api.x.com/2/tweets/1232720193182412800/hidden" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"hidden": false}'
from xdk import Client
from xdk.oauth1_auth import OAuth1

oauth1 = OAuth1(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET",
    access_token="YOUR_ACCESS_TOKEN",
    access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
)

client = Client(auth=oauth1)

# Unhide a reply
response = client.posts.hide_reply("1232720193182412800", hidden=False)
print(f"Hidden: {response.data.hidden}")
import { Client, OAuth1 } from "@xdevplatform/xdk";

const oauth1 = new OAuth1({
  apiKey: "YOUR_API_KEY",
  apiSecret: "YOUR_API_SECRET",
  accessToken: "YOUR_ACCESS_TOKEN",
  accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
});

const client = new Client({ oauth1 });

// Unhide a reply
const response = await client.posts.hideReply("1232720193182412800", {
  hidden: false,
});
console.log(`Hidden: ${response.data?.hidden}`);

Response:

{
  "data": {
    "hidden": false
  }
}

Important notes

- You can only hide replies to conversations **you started** - Hidden replies are still visible via "View hidden replies" - The reply author is not notified when their reply is hidden

Next steps

Moderate replies based on content Classify replies with Grok as they arrive and hide violations automatically Full endpoint documentation