> ## 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 Retweets

> 이 가이드에서는 X API로 게시물을 리트윗하고 리트윗을 취소하는 방법을 안내합니다. 퀵스타트를 다루는 X API v2 standard 티어 레퍼런스입니다.

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)
  * User Access Token (OAuth 1.0a 또는 OAuth 2.0 PKCE)
</Note>

***

## 게시물 리트윗

<Steps>
  <Step title="사용자 ID 확인">
    인증된 사용자의 ID가 필요합니다. [user lookup 엔드포인트](/x-api/users/lookup/introduction)를 사용하거나 Access Token(숫자 부분이 사용자 ID)에서 확인할 수 있습니다.
  </Step>

  <Step title="게시물 ID 확인">
    게시물을 볼 때 URL에서 Post ID를 찾을 수 있습니다:

    ```
    https://x.com/XDevelopers/status/1228393702244134912
                                    └── This is the Post ID
    ```
  </Step>

  <Step title="Retweet 요청 보내기">
    <CodeGroup dropdown>
      ```bash cURL theme={null}
      curl -X POST "https://api.x.com/2/users/123456789/retweets" \
        -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{"tweet_id": "1228393702244134912"}'
      ```

      ```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)

      # Retweet a Post
      response = client.posts.retweet(
          user_id="123456789",
          tweet_id="1228393702244134912"
      )

      print(f"Retweeted: {response.data.retweeted}")
      ```

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

      // Retweet a Post
      const response = await client.posts.retweet("123456789", {
        tweetId: "1228393702244134912",
      });

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

  <Step title="응답 확인">
    ```json theme={null}
    {
      "data": {
        "retweeted": true
      }
    }
    ```
  </Step>
</Steps>

***

## 리트윗 취소

Retweet 제거:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.x.com/2/users/123456789/retweets/1228393702244134912" \
    -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)

  # Undo a Retweet
  response = client.posts.unretweet(
      user_id="123456789",
      tweet_id="1228393702244134912"
  )

  print(f"Retweeted: {response.data.retweeted}")
  ```

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

  // Undo a Retweet
  const response = await client.posts.unretweet("123456789", "1228393702244134912");

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

**응답:**

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

***

## 다음 단계

<CardGroup cols={2}>
  <Card title="Retweets 조회" icon="retweet" href="/x-api/posts/retweets/quickstart/retweets-lookup">
    게시물을 리트윗한 사용자 가져오기
  </Card>

  <Card title="Quote Posts" icon="quote-left" href="/x-api/posts/quote-tweets/quickstart">
    Quote Posts 가져오기
  </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/repost-post" width="24" height="24" data-path="icons/xds/icon-code.svg">
    전체 엔드포인트 문서
  </Card>
</CardGroup>
