Williham
07/15/2025, 9:39 AMChiranjeet Mishra
07/16/2025, 10:52 AMjavascript
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).Williham
07/16/2025, 6:13 PMChiranjeet Mishra
07/16/2025, 11:46 PMChiranjeet Mishra
07/26/2025, 1:44 PM