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

# 대화 ID

> 대화 스레드를 추적하고 재구성합니다

X의 모든 답글은 하나의 대화 스레드에 속합니다. `conversation_id` 필드를 사용하면 전체 대화 트리를 식별하고 추적하며 재구성할 수 있습니다.

***

<div id="how-it-works">
  ## 동작 방식
</div>

누군가 게시물을 올리고 다른 사람들이 답글을 달면, 모든 답글에는 동일한 `conversation_id`가 설정됩니다. 이는 대화를 시작한 원본 게시물의 id입니다.

```
Original post (ID: 1234567890)  ← conversation_id for all replies
├── Reply 1 (ID: 1234567891)    → conversation_id: 1234567890
│   └── Reply to Reply 1        → conversation_id: 1234567890
└── Reply 2 (ID: 1234567892)    → conversation_id: 1234567890
    └── Reply to Reply 2        → conversation_id: 1234567890
```

스레드가 아무리 깊어져도 모든 포스트는 동일한 `conversation_id`를 가집니다.

***

<div id="requesting-conversation_id">
  ## conversation\_id 요청하기
</div>

`tweet.fields`에 `conversation_id`를 추가하세요:

```bash theme={null}
curl "https://api.x.com/2/tweets/1234567891?tweet.fields=conversation_id,in_reply_to_user_id,referenced_tweets" \
  -H "Authorization: Bearer $TOKEN"
```

응답:

```json theme={null}
{
  "data": {
    "id": "1234567891",
    "text": "@user Great point!",
    "conversation_id": "1234567890",
    "in_reply_to_user_id": "2244994945",
    "referenced_tweets": [{
      "type": "replied_to",
      "id": "1234567890"
    }]
  }
}
```

***

<div id="getting-a-full-conversation">
  ## 전체 대화 불러오기
</div>

`conversation_id`를 검색 연산자로 사용하여 스레드의 모든 포스트를 가져올 수 있습니다.

```bash theme={null}
curl "https://api.x.com/2/tweets/search/recent?\
query=conversation_id:1234567890&\
tweet.fields=author_id,created_at,in_reply_to_user_id&\
expansions=author_id" \
  -H "Authorization: Bearer $TOKEN"
```

원본 게시물에 대한 모든 답글을 최신순으로 반환합니다.

***

<div id="use-cases">
  ## 사용 사례
</div>

<Tabs>
  <Tab title="스레드 재구성">
    전체 대화 트리를 구성합니다:

    ```python theme={null}
    import requests

    conversation_id = "1234567890"
    url = f"https://api.x.com/2/tweets/search/recent"
    params = {
        "query": f"conversation_id:{conversation_id}",
        "tweet.fields": "author_id,in_reply_to_user_id,referenced_tweets,created_at",
        "max_results": 100
    }

    response = requests.get(url, headers=headers, params=params)
    replies = response.json()["data"]

    # created_at 기준으로 정렬하여 시간순으로 정렬합니다.
    replies.sort(key=lambda x: x["created_at"])
    ```
  </Tab>

  <Tab title="대화 모니터링">
    특정 대화에 대한 답글을 실시간으로 스트리밍합니다:

    ```bash theme={null}
    # 특정 대화에 대한 필터링된 스트림 규칙 추가
    curl -X POST "https://api.x.com/2/tweets/search/stream/rules" \
      -H "Authorization: Bearer $TOKEN" \
      -d '{"add": [{"value": "conversation_id:1234567890"}]}'
    ```
  </Tab>

  <Tab title="대화 분석">
    대화에서 답글 수를 집계합니다:

    ```bash theme={null}
    curl "https://api.x.com/2/tweets/counts/recent?\
    query=conversation_id:1234567890" \
      -H "Authorization: Bearer $TOKEN"
    ```
  </Tab>
</Tabs>

***

<div id="related-fields">
  ## 관련 필드
</div>

| Field                 | Description                               |
| :-------------------- | :---------------------------------------- |
| `conversation_id`     | 스레드를 시작한 원본 게시물의 ID                       |
| `in_reply_to_user_id` | 답글 대상 게시물 작성자의 사용자 ID                     |
| `referenced_tweets`   | `type: "replied_to"` 및 부모 게시물 ID를 포함하는 배열 |

***

<div id="example-full-thread-retrieval">
  ## 예시: 전체 스레드 조회
</div>

```json theme={null}
{
  "data": [
    {
      "id": "1234567893",
      "text": "@user2 @user1 I agree with you both!",
      "conversation_id": "1234567890",
      "author_id": "3333333333",
      "created_at": "2024-01-15T12:05:00.000Z",
      "in_reply_to_user_id": "2222222222",
      "referenced_tweets": [{"type": "replied_to", "id": "1234567892"}]
    },
    {
      "id": "1234567892",
      "text": "@user1 That's interesting!",
      "conversation_id": "1234567890",
      "author_id": "2222222222",
      "created_at": "2024-01-15T12:03:00.000Z",
      "in_reply_to_user_id": "1111111111",
      "referenced_tweets": [{"type": "replied_to", "id": "1234567890"}]
    },
    {
      "id": "1234567891",
      "text": "@user1 Great point!",
      "conversation_id": "1234567890",
      "author_id": "4444444444",
      "created_at": "2024-01-15T12:02:00.000Z",
      "in_reply_to_user_id": "1111111111",
      "referenced_tweets": [{"type": "replied_to", "id": "1234567890"}]
    }
  ],
  "meta": {
    "result_count": 3
  }
}
```

***

<div id="notes">
  ## 참고 사항
</div>

* 원본 게시물의 `conversation_id` 값은 해당 게시물의 `id`와 동일합니다
* `conversation_id`는 게시물을 반환하는 모든 v2 엔드포인트에서 제공됩니다
* 실시간으로 대화를 모니터링하려면 [필터링된 스트림](/ko/x-api/posts/filtered-stream/introduction)과 함께 사용하세요
* 대규모 스레드를 처리하려면 [페이지네이션](/ko/x-api/fundamentals/pagination)과 함께 사용하세요

***

<div id="next-steps">
  ## 다음 단계
</div>

<CardGroup cols={2}>
  <Card title="포스트 검색" icon="magnifying-glass" href="/ko/x-api/posts/search/introduction">
    conversation\_id를 기준으로 검색합니다.
  </Card>

  <Card title="필터링된 스트림" icon="signal-stream" href="/ko/x-api/posts/filtered-stream/introduction">
    대화를 실시간으로 모니터링합니다.
  </Card>
</CardGroup>
