abstract-brown•3h ago
How can I get the call ID injected into an apiRequest type tool call?
Hi - I've got an apiRequest tool (tool ID = c1c55b1e-194a-41af-b4a8-7ec131affc16), and I've attempted to inject the call ID via variables into the tool headers (see screenshot) as was shown in the docs. However, when I log the headers on my side, this is coming through as a static string, not a dynamic variable:
"x-call-id": "{{call.id}}"
Here's a call where I tried this: 019a3588-5dbd-7664-a5b0-6825a1a91fb0, and here's the actual tool call message:
{
"role": "tool_calls",
"time": 1761834733663,
"message": "",
"toolCalls": [
{
"id": "call_Jv4pNjbyt2DmdZF9SUGwQSYq",
"type": "function",
"function": {
"name": "LOCAL-axe-lo-call_axe_server",
"arguments": "{"order_id": "4072"}"
}
}
],
"secondsFromStart": 8.478
}
I would have expected my server to log the actual call ID rather than the static string {{call.id}}.
Is there a more correct way to do this?
2 Replies
The most reliable way to get the call ID in your apiRequest tool is to extract it from the request payload sent by Vapi, rather than relying on header interpolation. In your server code, you can access it like this:
This ensures you always have the correct call ID, as documented in the Vapi Custom Tools guide.
Note: Header variable interpolation for
Note: Header variable interpolation for
{{call.id}} is not currently supported for apiRequest tools, so extracting from the payload is the recommended approach.
Source:
- Custom Tools Documentation⤵️ Mention @Vapi Support Bot for follow-ups 🐥
abstract-brownOP•3h ago
This doesn't work - there is no
message parameter in the request.body? This is not for a function-type tool (which it looks like you may be referring to), this is an apiRequest-type tool that I have.