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

# リストのメンバーを管理

> リストのメンバーを追加および削除する

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <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>;
};

このガイドでは、リストのメンバーを追加・削除する方法を説明します。

<Note>
  **前提条件**

  作業を始める前に、次のものが必要です。

  * 承認済みの App を持つ [開発者アカウント](https://developer.x.com/en/portal/petition/essential/basic-info)
  * User Access Token (OAuth 1.0a または OAuth 2.0 PKCE)
  * あなたが所有しているリスト
</Note>

***

<div id="add-a-member-to-a-list">
  ## リストにメンバーを追加する
</div>

<Steps>
  <Step title="リストIDとユーザーIDを取得する">
    追加したいユーザーのユーザーIDと、対象のリストのIDが必要です。ユーザーIDは[user lookup endpoint](/ja/x-api/users/lookup/introduction)を使用して取得できます。
  </Step>

  <Step title="メンバーを追加する">
    <CodeGroup dropdown>
      ```bash cURL theme={null}
      curl -X POST "https://api.x.com/2/lists/1441162269824405510/members" \
        -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{"user_id": "2244994945"}'
      ```

      ```python Python SDK 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.lists.add_member(
          list_id="1441162269824405510",
          user_id="2244994945"
      )

      print(f"Is member: {response.data.is_member}")
      ```

      ```javascript JavaScript SDK 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.lists.addMember("1441162269824405510", {
        userId: "2244994945",
      });

      console.log(`Is member: ${response.data?.is_member}`);
      ```
    </CodeGroup>
  </Step>

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

***

<div id="remove-a-member-from-a-list">
  ## リストからメンバーを削除する
</div>

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.x.com/2/lists/1441162269824405510/members/2244994945" \
    -H "Authorization: Bearer $USER_ACCESS_TOKEN"
  ```

  ```python Python SDK 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.lists.remove_member(
      list_id="1441162269824405510",
      user_id="2244994945"
  )

  print(f"Is member: {response.data.is_member}")
  ```

  ```javascript JavaScript SDK 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.lists.removeMember(
    "1441162269824405510",
    "2244994945"
  );

  console.log(`Is member: ${response.data?.is_member}`);
  ```
</CodeGroup>

**レスポンス:**

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

***

<div id="important-notes">
  ## 重要な注意事項
</div>

<Note>
  * メンバーを管理できるのは、自分が所有しているリストのみです
  * ユーザーをリストに追加する際に、そのユーザーの許可は必要ありません
  * ユーザーは、自分がどの公開リストに追加されたかを確認できます
</Note>

***

<div id="next-steps">
  ## 次のステップ
</div>

<CardGroup cols={2}>
  <Card title="リストメンバーの取得" icon="users" href="/ja/x-api/lists/list-members/quickstart/list-members-lookup">
    リストメンバーを取得する
  </Card>

  <Card title="リストの管理" icon="pen" href="/ja/x-api/lists/manage-lists/quickstart">
    リストを作成および更新する
  </Card>

  <Card title="APIリファレンス" icon="code" href="/ja/x-api/lists/add-list-member">
    エンドポイントの完全なドキュメント
  </Card>
</CardGroup>
