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

# Getting Threads

> Retrieve and query thread data

### Retrieving Threads

<CodeGroup>
  ```javascript JavaScript theme={null}
  // By ID
  const thread = await threadify.getThread('thread-uuid');

  // By external reference
  const threads = await threadify.getThreadsByRef({
    refKey: 'stripe_payment_id',
    refValue: 'pi_1234567890'
  });
  ```

  ```go Go theme={null}
  // By ID
  thread, err := conn.GetThread(ctx, "thread-uuid")
  if err != nil {
      log.Fatal(err)
  }

  // By external reference
  threads, err := conn.GetThreadsByRef(ctx, &threadify.RefQuery{
      RefKey:   "stripe_payment_id",
      RefValue: "pi_1234567890",
  })
  if err != nil {
      log.Fatal(err)
  }
  ```

  ```python Python theme={null}
  from threadify.models import RefQuery

  # By ID
  thread = await conn.get_thread("thread-uuid")

  # By external reference
  threads = await conn.get_threads_by_ref(
      RefQuery(ref_key="stripe_payment_id", ref_value="pi_1234567890")
  )
  ```
</CodeGroup>

### Query Options

| Option          | Type   | Description                        |
| --------------- | ------ | ---------------------------------- |
| `refKey`        | string | Reference key                      |
| `refValue`      | string | Reference value                    |
| `status`        | string | `active`, `completed`, `cancelled` |
| `startedAfter`  | string | ISO timestamp filter               |
| `startedBefore` | string | ISO timestamp filter               |
| `limit`         | number | Max results                        |

### Thread Properties

| Property       | Type   | Description                        |
| -------------- | ------ | ---------------------------------- |
| `id`           | string | Thread ID                          |
| `status`       | string | `active`, `completed`, `cancelled` |
| `contractName` | string | Contract name                      |
| `startedAt`    | string | ISO timestamp                      |
| `completedAt`  | string | ISO timestamp                      |
| `ownerId`      | string | Creator user/service               |

### Next Steps

<CardGroup cols={2}>
  <Card title="Querying Steps" icon="list" href="/core-concepts/data-retrieval/querying-steps">
    Get step data and execution history
  </Card>

  <Card title="Validation Results" icon="shield-check" href="/core-concepts/data-retrieval/validation-results">
    Query contract violations
  </Card>
</CardGroup>
