> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Mutes

> このガイドでは、X API を利用してユーザーをミュート・ミュート解除する手順を説明します。X API v2 スタンダード階層の quickstart に関するリファレンスドキュメントです。

export const Button = ({href, children}) => {
  return <div className="not-prose">
    <a href={href}>
      <button className="x-btn">
        <span>{children}</span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

このガイドでは、X API を利用してユーザーをミュート・ミュート解除する手順を説明します。

<Note>
  **前提条件**

  始める前に、以下が必要です:

  * 承認済みの App がある [developer account](https://developer.x.com/en/portal/petition/essential/basic-info)
  * ユーザー Access Token (OAuth 1.0a または OAuth 2.0 PKCE)
</Note>

***

## ユーザーをミュート

<Steps>
  <Step title="user ID を取得">
    認証済みユーザーの ID が必要です。[user lookup エンドポイント](/x-api/users/lookup/introduction) を使って取得するか、Access Token から確認できます (数値部分が user ID)。
  </Step>

  <Step title="対象ユーザーの user ID を取得">
    ミュートしたいアカウントの user ID を [user lookup エンドポイント](/x-api/users/lookup/introduction) で確認します。
  </Step>

  <Step title="ミュートリクエストを送信">
    <CodeGroup dropdown>
      ```bash cURL theme={null}
      curl -X POST "https://api.x.com/2/users/123456789/muting" \
        -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{"target_user_id": "9876543210"}'
      ```

      ```python title="Python SDK" lines wrap icon="python" theme={null}
      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)

      # ユーザーをミュート
      response = client.users.mute(
          source_user_id="123456789",
          target_user_id="9876543210"
      )

      print(f"Muting: {response.data.muting}")
      ```

      ```javascript title="JavaScript SDK" lines wrap icon="square-js" theme={null}
      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 });

      // ユーザーをミュート
      const response = await client.users.mute("123456789", {
        targetUserId: "9876543210",
      });

      console.log(`Muting: ${response.data?.muting}`);
      ```
    </CodeGroup>
  </Step>

  <Step title="レスポンスを確認">
    ```json theme={null}
    {
      "data": {
        "muting": true
      }
    }
    ```
  </Step>
</Steps>

***

## ユーザーのミュートを解除

ユーザーへのミュートを解除します:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.x.com/2/users/123456789/muting/9876543210" \
    -H "Authorization: Bearer $USER_ACCESS_TOKEN"
  ```

  ```python title="Python SDK" lines wrap icon="python" theme={null}
  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)

  # ユーザーのミュートを解除
  response = client.users.unmute(
      source_user_id="123456789",
      target_user_id="9876543210"
  )

  print(f"Muting: {response.data.muting}")
  ```

  ```javascript title="JavaScript SDK" lines wrap icon="square-js" theme={null}
  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 });

  // ユーザーのミュートを解除
  const response = await client.users.unmute("123456789", "9876543210");

  console.log(`Muting: ${response.data?.muting}`);
  ```
</CodeGroup>

**レスポンス:**

```json theme={null}
{
  "data": {
    "muting": false
  }
}
```

***

## ミュートとブロックの違い

| Feature          | ミュート  | ブロック |
| :--------------- | :---- | :--- |
| 相手の Post を見る     | 見えない  | 見えない |
| 相手があなたの Post を見る | 見える   | 見えない |
| 相手があなたをフォローできる   | できる   | できない |
| 相手があなたに DM を送れる  | 送れる   | 送れない |
| 相手が気付くか          | 気付かない | 気付く  |

***

## 次のステップ

<CardGroup cols={2}>
  <Card title="Mutes lookup" icon="volume-xmark" href="/x-api/users/mutes/quickstart/mutes-lookup">
    ミュート中のユーザーを取得
  </Card>

  <Card title="Blocks" icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-block.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=702a65b4001948aebcc42635b8e2eac7" href="/x-api/users/blocks/quickstart" width="24" height="24" data-path="icons/xds/icon-block.svg">
    代わりにユーザーをブロック
  </Card>

  <Card title="API リファレンス" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-code.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=488e23401b19225b89acc0136d242219" href="/x-api/users/mute-user-by-user-id" width="24" height="24" data-path="icons/xds/icon-code.svg">
    エンドポイントの詳細ドキュメント
  </Card>
</CardGroup>
