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

# Assign Thread

> Assign an SMS conversation thread to a user

# Assign Thread

Assign an SMS conversation thread to a specific user (e.g. a loan officer or sales rep). Once assigned:

* The thread is marked as **qualified** (`lead_outcome: "qualified"`)
* AI auto-responses and drip messages are **stopped** for this thread
* Non-admin users will only see threads assigned to them

## Endpoint

```
POST /v1/threads/assign
```

## Authentication

<ParamField header="X-API-Key" type="string" required>
  Your API key
</ParamField>

## Request Body

<ParamField body="campaign_id" type="string" required>
  The campaign ID containing the thread
</ParamField>

<ParamField body="phone_number" type="string" required>
  The contact's phone number (E.164 format recommended, e.g. `+15551234567`)
</ParamField>

<ParamField body="assigned_user_id" type="string" required>
  The `unique_id` of the user to assign the thread to
</ParamField>

<ParamField body="organization_id" type="string">
  The organization's `unique_id`
</ParamField>

<ParamField body="assigned_by" type="string">
  The `unique_id` of the admin performing the assignment
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the assignment was successful
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable result message
</ResponseField>

<ResponseField name="thread_id" type="string">
  The thread identifier (format: `{phone_number}_{campaign_id}`)
</ResponseField>

<ResponseField name="assigned_to" type="object">
  Details of the assigned user

  <Expandable title="assigned_to properties">
    <ResponseField name="user_id" type="string">
      The assigned user's `unique_id`
    </ResponseField>

    <ResponseField name="name" type="string">
      The assigned user's display name
    </ResponseField>
  </Expandable>
</ResponseField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://partner.teli.ai/api/proxy/v1/threads/assign" \
    -H "X-API-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "campaign_id": "camp_abc123",
      "phone_number": "+15551234567",
      "assigned_user_id": "user_xyz789",
      "organization_id": "org_456",
      "assigned_by": "admin_user_001"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://partner.teli.ai/api/proxy/v1/threads/assign',
    {
      method: 'POST',
      headers: {
        'X-API-Key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        campaign_id: 'camp_abc123',
        phone_number: '+15551234567',
        assigned_user_id: 'user_xyz789',
        organization_id: 'org_456',
        assigned_by: 'admin_user_001'
      })
    }
  );
  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://partner.teli.ai/api/proxy/v1/threads/assign',
      headers={'X-API-Key': 'YOUR_API_KEY'},
      json={
          'campaign_id': 'camp_abc123',
          'phone_number': '+15551234567',
          'assigned_user_id': 'user_xyz789',
          'organization_id': 'org_456',
          'assigned_by': 'admin_user_001'
      }
  )
  data = response.json()
  ```
</CodeGroup>

## Example Response

```json theme={null}
{
  "success": true,
  "message": "Thread assigned to Jane Smith",
  "thread_id": "+15551234567_camp_abc123",
  "assigned_to": {
    "user_id": "user_xyz789",
    "name": "Jane Smith"
  },
  "powered_by": "Teli"
}
```

## Error Responses

```json 400 theme={null}
{
  "error": "campaign_id, phone_number, and assigned_user_id are required",
  "success": false,
  "powered_by": "Teli"
}
```

```json 404 theme={null}
{
  "error": "Thread not found for +15551234567 in campaign camp_abc123",
  "success": false,
  "powered_by": "Teli"
}
```

```json 404 theme={null}
{
  "error": "User 'user_xyz789' not found",
  "success": false,
  "powered_by": "Teli"
}
```

## Side Effects

Assigning a thread triggers the following:

1. **AI responses stop** — the thread is marked as complete, so the AI agent will no longer auto-reply
2. **Drip messages cancelled** — any scheduled follow-up messages are ended
3. **Lead outcome set** — the contact's `lead_outcome` is set to `"qualified"`
4. **Visibility filtered** — non-admin users will only see threads assigned to them when fetching campaign contacts or messages

## Related Endpoints

* [Unassign Thread](/partner-api/threads/unassign) - Remove a thread assignment
* [Get Campaign Contacts](/partner-api/threads/contacts) - List contacts with assignment info
* [Get Campaign Messages](/partner-api/campaigns/messages) - Get messages (filtered by assignment for non-admins)
* [List Users](/partner-api/users/list) - Get available users to assign to
