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

# Working with Contracts

> Define contracts that ensure workflows follow the right process

When a thread is created with a contract, Threadify uses that contract to validate record steps and identifies violations, failed business logic, race conditions, etc.

<Note>
  New to contracts? Learn how to [create a contract](/core-concepts/creating-contracts) first.
</Note>

### Starting with a Contract

Start a thread with a contract to enable automatic validation:

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Use latest version with a label (recommended)
  const thread = await threadify.start('Order-123', 'order_fulfillment');

  // Use specific version with a label
  const thread = await threadify.start('Order-123', 'order_fulfillment:2');
  ```

  ```go Go theme={null}
  // Use latest version with a label (recommended)
  thread, err := conn.Start(ctx, "Order-123", "order_fulfillment")
  if err != nil {
      log.Fatal(err)
  }

  // Use specific version with a label
  thread, err := conn.Start(ctx, "Order-123", "order_fulfillment:2")
  if err != nil {
      log.Fatal(err)
  }
  ```

  ```python Python theme={null}
  # Use latest version with a label (recommended)
  thread = await connection.start("Order-123", contract_name="order_fulfillment")

  # Use specific version with a label
  thread = await connection.start("Order-123", contract_name="order_fulfillment:2")
  ```
</CodeGroup>

### What Contracts Validate

**Entry points** - The first step must be a valid entry point defined in the contract.

**Transitions** - Steps must follow the allowed transitions defined in the contract.

**Required fields** - Context provided with each step must include all required fields.

**Terminal states** - Threads automatically complete when reaching a terminal node.

<Info>
  Violations are reported via notifications but don't block execution. Learn how to [subscribe to violations](/core-concepts/notifications/subscribing).
</Info>

### Next Steps

<CardGroup cols={2}>
  <Card title="Inviting Parties" icon="users" href="/core-concepts/thread-collaboration/inviting-parties">
    Invite others to collaborate on threads
  </Card>

  <Card title="Notifications" icon="bell" href="/core-concepts/notifications/subscribing">
    Subscribe to validation alerts
  </Card>
</CardGroup>
