Ben
10/13/2025, 1:28 PMVapi Support Bot
10/13/2025, 1:29 PMjs
// Example: Express handler for tool calls
const toolCallCounts = {}; // { callId: count }
app.post('/tool-calls', (req, res) => {
const callId = req.headers['x-call-id'];
toolCallCounts[callId] = (toolCallCounts[callId] || 0) + 1;
if (toolCallCounts[callId] > MAX_CALLS) {
return res.json({ error: "Tool call limit reached for this call." });
}
// ...handle tool call...
});
This approach gives you full control over tool call limits per session.
For more details, see the [Vapi server events documentation](https://docs.vapi.ai/server-url/events).
Source:
- [Server events](https://docs.vapi.ai/server-url/events)