> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-143107c1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Blocks

> Blocks エンドポイントを使うと、認証済みユーザーがブロックしているユーザーの一覧の取得などが行えます。X API v2 スタンダード階層の blocks に関するリファレンスドキュメントです。

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>;
};

Blocks エンドポイントを使うと、認証済みユーザーがブロックしているユーザーの一覧を取得したり、ユーザーをブロック・ブロック解除したりできます。

<Callout icon="/icons/xds/icon-key.svg" color="#22C55E" iconType="regular">
  ユーザーのブロックおよびブロック解除エンドポイントは、Enterprise プランでのみ利用可能です。Enterprise の関心表明フォームは[こちら](/forms/enterprise-api-interest)からご記入いただけます。
</Callout>

## 概要

<CardGroup cols={2}>
  <Card title="ブロック済みユーザー" icon="https://mintcdn.com/x-preview-mintlify-143107c1/-vUZNvNnsedeyKnT/icons/xds/icon-bulleted-list.svg?fit=max&auto=format&n=-vUZNvNnsedeyKnT&q=85&s=4ff4e2300afadbf6c9c64712c8d3f0fa" width="24" height="24" data-path="icons/xds/icon-bulleted-list.svg">
    ブロック中のユーザー一覧を取得
  </Card>

  <Card title="ブロック" icon="https://mintcdn.com/x-preview-mintlify-143107c1/r6g1kiGndqT3mXyl/icons/xds/icon-block.svg?fit=max&auto=format&n=r6g1kiGndqT3mXyl&q=85&s=17d5c8d08abb80bfc4b276eb51ed7c0f" width="24" height="24" data-path="icons/xds/icon-block.svg">
    ユーザーをブロック
  </Card>

  <Card title="ブロック解除" icon="https://mintcdn.com/x-preview-mintlify-143107c1/-vUZNvNnsedeyKnT/icons/xds/icon-checkmark-circle.svg?fit=max&auto=format&n=-vUZNvNnsedeyKnT&q=85&s=9c44a20ac344761e56002921218e19fe" width="24" height="24" data-path="icons/xds/icon-checkmark-circle.svg">
    ユーザーのブロックを解除
  </Card>
</CardGroup>

***

## エンドポイント

| Method | Endpoint                                             | Description   | Availability                                                                                                                                                                    |
| :----- | :--------------------------------------------------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| GET    | [`/2/users/:id/blocking`](/x-api/users/get-blocking) | ブロック中のユーザーを取得 | <div className="flex items-center gap-1 flex-nowrap whitespace-nowrap"><Badge color="blue" size="xs">Pay-per-use</Badge><Badge color="green" size="xs">Enterprise</Badge></div> |
| POST   | `/2/users/:id/blocking`                              | ユーザーをブロック     | <Badge color="green" size="xs">Enterprise</Badge>                                                                                                                               |
| DELETE | `/2/users/:source_user_id/blocking/:target_user_id`  | ユーザーのブロックを解除  | <Badge color="green" size="xs">Enterprise</Badge>                                                                                                                               |

***

## 例: ブロック中のユーザーを取得

```bash theme={null}
curl "https://api.x.com/2/users/123456789/blocking?\
user.fields=username,description" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN"
```

## 例: ユーザーをブロック (Enterprise のみ)

```bash theme={null}
curl -X POST "https://api.x.com/2/users/123456789/blocking" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"target_user_id": "9876543210"}'
```

***

## はじめに

<Note>
  **前提条件**

  * 承認済みの [developer account](https://developer.x.com/en/portal/petition/essential/basic-info)
  * Developer Console 内の [Project と App](/resources/fundamentals/developer-apps)
  * [OAuth 2.0 PKCE](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2) 経由のユーザー Access Token
</Note>

<CardGroup cols={2}>
  <Card title="クイックスタート" icon="https://mintcdn.com/x-preview-mintlify-143107c1/LjDupcgIJeQhUrTV/icons/xds/icon-rocket.svg?fit=max&auto=format&n=LjDupcgIJeQhUrTV&q=85&s=ab9d87f67ff2827df976c782467c9fe1" href="/x-api/users/blocks/quickstart" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    blocks を使い始める
  </Card>

  <Card title="連携ガイド" icon="https://mintcdn.com/x-preview-mintlify-143107c1/r6g1kiGndqT3mXyl/icons/xds/icon-book.svg?fit=max&auto=format&n=r6g1kiGndqT3mXyl&q=85&s=221001d25934bdf1f9d20077f943b9c8" href="/x-api/users/blocks/integrate" width="24" height="24" data-path="icons/xds/icon-book.svg">
    主要な概念とベストプラクティス
  </Card>

  <Card title="API リファレンス" icon="https://mintcdn.com/x-preview-mintlify-143107c1/-vUZNvNnsedeyKnT/icons/xds/icon-code.svg?fit=max&auto=format&n=-vUZNvNnsedeyKnT&q=85&s=1df744166b46c62535ed328bca70d1c0" href="/x-api/users/get-blocking" width="24" height="24" data-path="icons/xds/icon-code.svg">
    エンドポイントの詳細ドキュメント
  </Card>
</CardGroup>
