Server-Side Control and JWT Parameters for Web Cal...
# support
w
Hi Vapi Team, We're in the process of building an application using your web client and have a couple of architectural questions to ensure we're on the right track. Our plan is to use your recommended JWT-based authentication. Our server will generate short-lived, Public Scoped Tokens, and we will then initialize the Vapi web client using new Vapi(token). We have two main questions regarding this workflow: Dynamic maxDuration via JWT: We need to set different call duration limits for different users. If we include a custom claim like "maxDuration": 300 inside the signed payload of our Public Scoped JWT, will the Vapi backend automatically recognize and enforce this time limit on a web call? Or is the maxDuration only configurable via the REST API for phone calls? Web Call Termination via REST API: For managing active user sessions, we also need the ability to programmatically end a call from our server. Can the POST /call/{id}/end REST API endpoint be used to terminate a live web call that was initiated from a browser using vapi.start()? Or does this endpoint exclusively apply to phone calls? Thanks for your help and clarification!
c
For implementing server-side control with JWT parameters for web calls, you can follow these guidelines: 1. **JWT Token for Web Client**: To initialize the Vapi web client, you'd generate a public-scoped JWT token. The public scope restricts access to limited API endpoints, like creating web calls. Here’s a sample payload setup for a public JWT token:
Copy code
javascript
   const payload = {
     orgId: process.env.ORG_ID,
     token: {
       tag: "public",
       restrictions: {
         allowedOrigins: ["https://example.vapi.ai"],
         allowedAssistantIds: ["your-assistant-id"],
       },
     },
   };
   const key = process.env.PRIVATE_KEY;
   const options = { expiresIn: "short-duration" }; // Define token's time limit
   const token = generateJWT(payload, key, options);
2. **Dynamic maxDuration via JWT**: To manage call duration limits dynamically, you might consider enhancing the server logic to determine and set these parameters before the token is generated. In the current setup, the max duration isn't an aspect controlled directly by the JWT, but server-side logic can set it by influencing the client's configuration or execution path once the call is initiated. For detailed steps on generating tokens and using them with the Vapi API, please refer to the [JWT Authentication guide](https://docs.vapi.ai/customization/jwt-authentication).
w
Yeah I read the JWT Authentication guide and I don’t feel like it was suffice to answer my questions. That’s why I asked them here. I am still not sure if I got an answer regarding Web Call termination with rest api. Is it possible to end a web call from our server? Could you also expand on how server logic could solve the maxDuration issue before token generation? Thanks in advance!
c
Hey Williham, I wanted to let you know that we're managing a high volume of support requests at the moment, so our response time might be a bit slower than usual. I truly appreciate your understanding and will get back to you as soon as possible!  Thanks again for your patience!
Hi, First off, we want to sincerely apologize for the delay in getting back to you. We understand how frustrating it is to wait - especially when you're counting on us - and we owe you a clear explanation of what’s been happening and how we’re addressing it. Over the past few weeks, we've seen a significant increase in support requests. While this reflects exciting growth, it has also stretched our small team and exposed some real challenges in scaling our support operations. To improve your experience, we’ve taken a step back to reassess our approach. Here’s what we’re implementing: - Smarter Support Through Automation: We’re investing in our AI support systems to help you resolve issues more efficiently. Soon, our support bot will offer expanded capabilities, making it easier to access accurate, instant help—particularly for common or repetitive queries. - Expanding the Support Team: To meet growing demand, we’re adding 2–3 new team members focused on managing support volume and improving response times. - Prioritized SLAs for High-Usage Accounts: We’re introducing service level improvements for users who are growing with us: - Accounts with usage over 1,000 minutes/month will receive prioritized support. - For all general inquiries, we’re establishing a standardized 48-hour response time. We’re confident these steps will lead to faster, more reliable support and help us better serve you as you grow with us. Also, in case you still need help with this ongoing ticket, do let us know, and we will help you get this resolved as soon as possible. Thank you for your continued patience and for being part of our journey. Warm regards, Vapi Team
3 Views