URGENT: Invoke Tool at call start
# support
m
Hi we need to call a tool to fetch a bearer token to pass the token to subsequent API calls. Currently, not matter what we try, the bearer token API gets called at the same time as the 2nd API, and so we don't get the token in time and the 2nd API fails. The {{token}} is a required variable in the 2nd API call but VAPI just sends a blank. Is it possible to force VAPI to get the bearer token as soon as the call starts?
c
Hi there, Thank you for your message. Our team is currently out of the office. We operate Monday through Friday, from 9:00 AM to 8:00 PM Pacific Standard Time (PST). We’ll get back to you as soon as possible during our normal business hours. If your message is urgent, please mark it accordingly or include “URGENT” in the subject line, and we’ll do our best to respond promptly. Warm regards, Vapi Customer Support Team
v
The recommended solution is to use Vapi's OAuth 2.0 credential system, which automatically fetches and injects bearer tokens for your API calls—no need to manually invoke a tool at call start. Setup Example:
Copy code
json
{
  "server": {
    "url": "https://your-server.com/webhook",
    "credentialId": "cred_oauth_xyz789"
  }
}
Create the OAuth 2.0 credential in the Vapi dashboard and reference its ID as shown above. Vapi will handle token fetching and refreshing automatically for all subsequent API calls ([see docs](https://docs.vapi.ai/server-url/server-authentication#create-oauth-20-credential)). Source: - [Server authentication](https://docs.vapi.ai/server-url/server-authentication)
m
Unfortunately, the backend is not OAuth 2.0. It's some 3rd-party custom scheme where we simply send an API key to a URL and they send back a bearer token.
2 Views