Variable interpolation seem not works for the URL ...
# support
i
Hi VAPI Team, I’m encountering an issue when using dynamic variables in a tool that makes an HTTP request. Here’s the situation: - I created a custom tool of type apiRequest that performs a simple HTTP call. - The tool uses Liquid syntax (e.g. {{variable}}) to insert dynamic parameters. - When I place these variables inside the Request Body, they are correctly resolved at runtime. - However, when I place the same variables directly inside the URL (for example: https://api.example.com/data/{{id}}), the variable is not replaced and stays as {{id}} in the final request. It seems that variable interpolation currently works for the body but not for the URL field of the tool definition. Could you please confirm if this is a known limitation, or if there’s a specific way to ensure variables in the URL are properly evaluated (for example, through a particular Liquid filter, parameter declaration, or encoding rule)? Any guidance or clarification would be greatly appreciated, especially if there’s a recommended best practice for passing dynamic parameters in the URL with VAPI tools. Thanks in advance for your help! Best regards.
v
Based on the documentation, variable interpolation in the URL field of an API request tool should work using LiquidJS syntax. For example:
Copy code
json
{
  "url": "https://api.example.com/data/{{id}}",
  "method": "GET"
}
If the variable is not being replaced, double-check that the variable name matches exactly and is included in the tool's parameters. If the issue persists, it may be a bug—please ensure your configuration matches the documented example and consider reaching out to support with your tool definition for further troubleshooting. Reference: See the "Dynamic Variables with LiquidJS" section in the [Vapi API Request tool documentation](https://docs.vapi.ai/tools/default-tools). Source: - [Default Tools – Vapi Documentation](https://docs.vapi.ai/tools/default-tools)
i
Hey @User, @User , 👋 I double-checked and made sure I’m using the correct variable name (copy-pasted to avoid typos). In the screenshots I attached, you can see that in my API Request tool I’m using the same variable {{therapist_id}} both in the URL and in the request body. When I run a test call, the last image shows the JSON payload sent to my backend: The variable in the body is correctly resolved, but the variable in the URL stays as {{therapist_id}} instead of being replaced. Could this be a limitation with URL interpolation, or am I missing something in the setup? https://cdn.discordapp.com/attachments/1432495554734329947/1432500951859728525/image.png?ex=6901f0b9&is=69009f39&hm=ac562c80a05351295258d050e9b1d9b04096d1dcd017725b9e7d7dbeb9fb3e76& https://cdn.discordapp.com/attachments/1432495554734329947/1432500952245735556/image.png?ex=6901f0b9&is=69009f39&hm=084e430a8396e13f6722304808a447a960da295de1d6f98b082cb4aeb24a9038& https://cdn.discordapp.com/attachments/1432495554734329947/1432500952954441809/image.png?ex=6901f0b9&is=69009f39&hm=eccc8feb2ba755f3fa02c0be2f18a102d8d0783af7e25d71890c6411d3f8ea8a&
c
Hi IG3N, It looks like you're dealing with an issue related to variable substitution using Liquid syntax within the URL of an
apiRequest
tool. As per the available documentation, there's a known constraint that Liquid syntax may resolve correctly in the request body but not directly in the URL. To address this, you might consider using predefined parameters within your tool setup where possible, and ensure any variable substitution logic is accounted for prior to executing the HTTP request. If you have control over the logic triggering these requests, you could handle these variables in your application logic before constructing the URL for the request. If there are specific encoding rules or filters that you suspect might affect the behavior, verifying those with your URL construction method could be key. For any best practices, there may not be a one-size-fits-all solution, so some testing with different implementations may be needed. For further guidance, you can consult your development team to explore workarounds based on your specific integration scenario. For more detailed descriptions, you can refer to the [tool integration documentation](https://docs.vapi.ai/api-reference/tools/update). I hope this helps clarify the situation. If you have further questions, feel free to ask.
2 Views