How can I get the call ID injected into an apiRequ...
# support
d
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? https://cdn.discordapp.com/attachments/1433464292744757411/1433464293424103544/image.png?ex=6904c928&is=690377a8&hm=166f9d30e39bd246ab770ced31cf461af0681b143d675554e032d76d7ec2b527&
v
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:
Copy code
js
// Example: Express.js handler
app.post('/your-tool-endpoint', (req, res) => {
  const callId = req.body.message?.call?.id;
  // Use callId as needed
});
This ensures you always have the correct call ID, as documented in the Vapi Custom Tools guide. 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](https://docs.vapi.ai/tools-calling)
d
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.
Hi Support Team - is there any update on this?