# Agents: Set an agent's tools (https://docs.envocal.ai/api-reference/agents/set-an-agents-tools/) > Replaces all of the agent's tools. Each id is a tool (GET /v1/tenants/{tenantId}/tools) of the agent's tenant, and the tool's availability must include the phase it is placed in: - before: run in order when the conversation starts (e.g. look up the caller). - during: offered to the AI model as functions it can call during the conversation. - after: run in order after the conversation ends (e.g. post a summary to a CRM). Output of earlier tools is available to later ones through dynamic variables, so before and after can form tool chains. ## PUT `/v1/tenants/{tenantId}/agents/{id}/tools` Replaces all of the agent's tools. Each id is a tool (`GET /v1/tenants/{tenantId}/tools`) of the agent's tenant, and the tool's `availability` must include the phase it is placed in: - `before`: run in order when the conversation starts (e.g. look up the caller). - `during`: offered to the AI model as functions it can call during the conversation. - `after`: run in order after the conversation ends (e.g. post a summary to a CRM). Output of earlier tools is available to later ones through dynamic variables, so `before` and `after` can form tool chains. To take a tool away from the agent, send the lists without it. Send three empty lists to remove all. **Required permission:** `agents:write` ### Parameters | Name | In | | Type | Description | | --- | --- | --- | --- | --- | | `tenantId` | path | required | string | Tenant id, or `current` for the key's own tenant. Must be the key's tenant or one of its sub-tenants. | | `id` | path | required | string | Agent id. | ### Request body `application/json`: AgentToolsConfigDto | Field | Type | | Description | | --- | --- | --- | --- | | `before` | string (uuid)[] | | Run in this order when the conversation starts, before the AI speaks (e.g. look up the caller in a CRM). | | `during` | string (uuid)[] | | Offered to the AI model as functions it may call during the conversation. Order does not matter. | | `after` | string (uuid)[] | | Run in this order after the conversation ends (e.g. post a summary or create a ticket). | ### Request examples **One lookup before the conversation and two tools the AI can call**: The ids are tool ids (`id` of a tool). All three lists are replaced, so read the agent's tools first and send back what should stay. ```json { "before": [ "0b7c2d9e-3a41-4f68-9c25-6d1e8f3a7b52" ], "during": [ "5e2a9c14-7d36-4b80-a1f9-2c4d6e8f0a13", "9f3b1d27-6c58-4e02-b7a4-8d0e2f4a6c35" ], "after": [] } ``` ### Responses **204**: Saved. **400**: Ids that are not tools of the agent's tenant (`missing` lists them), or a tool that is placed in a phase it doesn't support or twice in `before` or `after` (`toolId` says which). **401**: Missing, invalid, revoked or expired API key. **403**: The key lacks the required permission, or the tenant/resource is outside its reach. **404**: Agent not found. **429**: Rate limit exceeded. Retry after the number of seconds in the Retry-After header. ### Example ```bash curl -X PUT "https://api.envocal.ai/v1/tenants/current/agents/{id}/tools" \ -H "Authorization: Bearer evk_eu_..." \ -H "Content-Type: application/json" \ -d '{"before":["0b7c2d9e-3a41-4f68-9c25-6d1e8f3a7b52"],"during":["5e2a9c14-7d36-4b80-a1f9-2c4d6e8f0a13","9f3b1d27-6c58-4e02-b7a4-8d0e2f4a6c35"],"after":[]}' ```