This endpoint assigns a tool to one or more assistants, making it available during their conversations. Tools can be assigned to multiple assistants simultaneously.

Path Parameters

  • tool_id (integer, required): The unique identifier of the tool to assign

Request Body

Request
{
  "assistant_ids": [123, 456, 789],
  "enabled": true
}

Request Fields

  • assistant_ids (array of integers, required): List of assistant IDs to assign the tool to
  • enabled (boolean, optional): Whether the tool is enabled for these assistants (default: true)

Response

A successful request returns assignment details:
Response
{
  "success": true,
  "tool_id": 123,
  "assignments": [
    {
      "assistant_id": 123,
      "assistant_name": "Customer Service Bot",
      "enabled": true,
      "assigned_at": "2024-01-15T16:30:00Z"
    },
    {
      "assistant_id": 456,
      "assistant_name": "Sales Assistant",
      "enabled": true,
      "assigned_at": "2024-01-15T16:30:00Z"
    },
    {
      "assistant_id": 789,
      "assistant_name": "Technical Support",
      "enabled": true,
      "assigned_at": "2024-01-15T16:30:00Z"
    }
  ],
  "message": "Tool successfully assigned to 3 assistants"
}

Single Assistant Assignment

You can also assign a tool to a single assistant:
Single Assignment Request
{
  "assistant_ids": [123],
  "enabled": true
}
Single Assignment Response
{
  "success": true,
  "tool_id": 123,
  "assignments": [
    {
      "assistant_id": 123,
      "assistant_name": "Customer Service Bot",
      "enabled": true,
      "assigned_at": "2024-01-15T16:30:00Z"
    }
  ],
  "message": "Tool successfully assigned to 1 assistant"
}

Error Responses

404 Not Found - Tool
{
  "detail": "Tool with ID 123 not found"
}
404 Not Found - Assistant
{
  "detail": "Assistant with ID 456 not found in your organization"
}
400 Bad Request - Already Assigned
{
  "detail": "Tool is already assigned to assistant 123"
}
400 Bad Request - Empty Assignment
{
  "detail": "assistant_ids cannot be empty"
}

Unassign Tool

To unassign a tool from assistants, use the unassign endpoint:
Unassign Tool
POST /api/v1/tools/{tool_id}/unassign
Unassign Request
{
  "assistant_ids": [123, 456]
}

List Tool Assignments

Get all current assignments for a tool:
List Assignments
GET /api/v1/tools/{tool_id}/assignments
Assignments Response
{
  "tool_id": 123,
  "tool_name": "get_customer_info",
  "assignments": [
    {
      "assistant_id": 123,
      "assistant_name": "Customer Service Bot",
      "enabled": true,
      "assigned_at": "2024-01-15T16:30:00Z",
      "usage_count": 45,
      "last_used_at": "2024-01-15T18:15:00Z"
    },
    {
      "assistant_id": 456,
      "assistant_name": "Sales Assistant", 
      "enabled": false,
      "assigned_at": "2024-01-15T16:30:00Z",
      "usage_count": 12,
      "last_used_at": "2024-01-15T17:20:00Z"
    }
  ],
  "total_assignments": 2
}

Integration Examples

Best Practices

  1. Selective Assignment: Only assign tools to assistants that actually need them
  2. Testing: Test tool functionality with specific assistants before broad deployment
  3. Monitoring: Track tool usage per assistant to optimize assignments
  4. Documentation: Document which tools are assigned to which assistants
  5. Performance: Consider the number of tools per assistant for optimal performance

Use Cases