Custom Adapters
Custom adapters let you connect Bedrock agents to your own APIs, databases, or third-party services. When an agent calls one of your tools, Bedrock sends a webhook to your server with the arguments, and your server returns the result.How It Works
- Agent decides to call your tool
- Bedrock POSTs to your webhook URL with headers (
X-Agent-Secret,X-Agent-Identity) and a body containing function info, arguments, and agent/template context - Your server processes the request
- Your server returns JSON
- Agent receives the result and continues
Step 1: Create an Adapter
An adapter is a named container for related tools. Create one via the API or the portal UI.private visibility and owned by your organization.
Optional: Config Schema
If your adapter needs per-template configuration (API keys, instance URLs, etc.), define aconfig_schema using JSON Schema:
AdapterConfig is saved.
Step 2: Add Tools to the Adapter
Tools are the individual functions agents can call. Each tool needs:- name — Function name the LLM sees (e.g.,
search_leads) - description — What the tool does (included in the LLM prompt, so be thorough)
- url — Your webhook endpoint
- parameters — JSON Schema defining the arguments
Step 3: Attach the Adapter to Your Template
Attach the adapter to a template by creating anAdapterConfig. This single action enables the adapter and stores its per-template configuration (even if the config is empty):
config: {}. To remove the adapter from the template later, DELETE the AdapterConfig.
Existing agents created from the template keep their snapshot; only new agents will pick up the attach/detach. Existing agents can be edited directly via
PATCH /api/cloud/agents/{id}/.Step 4: Build Your Webhook Handler
When an agent calls your tool, Bedrock sends a POST request to the tool’surl.
Request Format
Headers:
Body:
template block is only included when the agent was created from a template. Ad-hoc agents (dev / eval without a template) will have it absent.
Response Format
Return JSON. The entire response body is serialized to a string and shown to the agent as the tool result.Error Handling
If something goes wrong, return a clear error message. The agent will see it and can adapt:Example: FastAPI Handler
Example: Express.js Handler
Setting Up the Tool Call Secret
Thetool_call_secret is set on your template. It’s sent with every webhook call by agents created from that template, so your server can verify the request came from Bedrock.
Set it in the portal (Template Detail > Tool Call Secret) or via the API:
The secret is snapshotted onto each agent when the agent is created, so rotating the template’s secret does not affect agents that already exist.
When Are Tools Called?
Tools are called during an agent’s runtime loop. Here’s the lifecycle:- Agent wakes up (via API call, schedule, or incoming message)
- Runtime loads tools from every adapter attached to the agent (seeded from its template at creation time)
- LLM prompt is built with the tool descriptions and parameters
- LLM decides whether to call a tool based on the conversation and available tools
- Bedrock executes the tool call (webhook POST for external tools)
- Result is returned to the LLM as a tool response
- LLM continues — it may call more tools, respond, or sleep
max_turns.
Dynamic Tool Descriptions with Detail URLs
If your tool’s description needs to change at runtime (e.g., showing current inventory levels or available time slots), use thedetail_url field.
When an agent run starts, Bedrock GETs the detail_url and appends the response to the tool description:
detail_url endpoint should return:
X-Agent-Secret and X-Agent-Identity headers, so you can personalize the response per agent.
Multiple Tools Per Adapter
A single adapter can have many tools. Group related functionality together:function.name field in the request body:
Best Practices
Tool Descriptions
The description is the most important field — it’s what the LLM reads to decide when and how to use your tool.- Be specific: “Search CRM leads by name, email, or company name. Returns matching leads with their status, contact info, and last interaction date.”
- Not vague: “Search the CRM”
Return Values
- Return structured JSON that gives the agent actionable information
- Include IDs so the agent can reference items in follow-up tool calls
- For lists, include a count so the agent knows if there are more results
- For errors, return a human-readable message the agent can relay to the user
Security
- Always verify
X-Agent-Secret— this is your only authentication layer - Don’t expose internal system details in error messages
- Rate-limit your webhook endpoints
- Use HTTPS for all webhook URLs
Performance
- Keep webhook response times under 30 seconds
- For long-running operations, return immediately with a status and use notifications to update the agent later
- Cache expensive operations where possible