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

# API Assignment

> Let your own system decide which agent receives each conversation. Treble calls the endpoint you configure with the chat's context and assigns the conversation to the agent you return.

If your team already has its own routing logic, with the **API** destination you don't have to replicate it in Treble. Treble calls **your endpoint** with the chat's context and respects the agent you return.

<img src="https://mintcdn.com/trebleai/4IeYTi_jb7MUcJQl/images/transfer-methods-api-1.png?fit=max&auto=format&n=4IeYTi_jb7MUcJQl&q=85&s=371208d78864b14c1a8fcb78ec7dbb23" alt="API destination" width="1440" height="1024" data-path="images/transfer-methods-api-1.png" />

```mermaid theme={null}
sequenceDiagram
    participant C as Customer
    participant T as Treble
    participant S as Your server

    C->>T: The conversation reaches the block
    T->>S: POST with the chat's context
    S->>S: Decides which agent should attend
    S->>T: Responds with the agent
    T->>C: Assigns the conversation to that agent
```

## Configuration

<Steps>
  <Step title="Select the API destination">
    In the block configuration, choose **API** and click **Next**.
  </Step>

  <Step title="Enter the endpoint URL">
    Write the URL Treble will make the `POST` request to when the conversation reaches the block.

    <img src="https://mintcdn.com/trebleai/4IeYTi_jb7MUcJQl/images/transfer-methods-api-config.png?fit=max&auto=format&n=4IeYTi_jb7MUcJQl&q=85&s=e8e571211be44347316c0ec00fdbac92" alt="Configuring the endpoint URL" width="1440" height="1024" data-path="images/transfer-methods-api-config.png" />
  </Step>

  <Step title="Choose the authentication type">
    * **No authentication** — Treble calls your endpoint without credentials.
    * **Token / API Key** — enter a token that Treble will send in the `Authorization` header with the format `Bearer YOUR_TOKEN`, so your endpoint can verify the call comes from Treble.

    <img src="https://mintcdn.com/trebleai/4IeYTi_jb7MUcJQl/images/transfer-methods-api-token.png?fit=max&auto=format&n=4IeYTi_jb7MUcJQl&q=85&s=46cf4d769b95a8f9ab60a5cadce1ad36" alt="Configuring the authentication token" width="1440" height="1024" data-path="images/transfer-methods-api-token.png" />
  </Step>

  <Step title="Complete the team and save">
    Select the team in **Tags**, add **Labels** if you need them, and click **Save changes**.

    <Check>
      Done! When a conversation reaches the block, Treble will call your endpoint to resolve the agent.
    </Check>
  </Step>
</Steps>

<div class="hr" />

## The contract

Your endpoint receives the contact's and the conversation's context, and must respond with the agent who will attend to it:

```json theme={null}
{
  "agent_email": "andrea.soto@yourcompany.com"
}
```

<Warning>
  Your endpoint must respond in **less than 10 seconds**. If it exceeds that, returns a status code other than `200`, or returns an agent that can't receive the conversation, Treble applies the [fallback method](/en/docs/build-with-treble/blocks/transfer-methods/overview#priority-and-fallback-method) configured in the main platform.
</Warning>

The full reference —the exact body Treble sends, the two ways to identify the agent, and an implementation example— is in the API reference.

<CardGroup cols={2}>
  <Card title="Webhook reference" icon="code" href="/en/api-reference/webhooks/api-assignation/intro">
    The body Treble sends and the response you must return.
  </Card>

  <Card title="Get the agents" icon="users" href="/en/api-reference/endpoints/get-agents">
    Look up the agents in your account to know which email or id to return.
  </Card>
</CardGroup>
