Call duration
# support
j
I'm using a server url to catch events from vapi. Is there not a 'call duration' value that can be received in the json payload?
v
Hi @jnetic_, I'm an AI assistant for Vapi. I'll analyze available sources and get back to you shortly.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Developing Locally]() * [Server Events]() * [Server URLs]() * [Tools Calling]() -----------------------------
### Answer The JSON payloads sent to your server URL for various events, such as call status updates or end-of-call reports, do not explicitly include a 'call duration' value. However, you can calculate the call duration using the timestamps provided in the call events. For instance, when a call ends, the end-of-call report will include
startedAt
and
endedAt
timestamps. By subtracting the
startedAt
timestamp from the
endedAt
timestamp, you can determine the call's duration [(1)]() . Remember, the timestamps are provided in ISO 8601 date-time format, facilitating straightforward calculation in most programming environments. For more details on the structure of the payloads for different event types and how to work with them, refer to the Server Events documentation [(2)]() .
Glad I could be helpful. Feel free to create a new thread with any new questions you may have.
j
+1 on this, currently you have to use the GET Call endpoint to find the startedAt & endedAt parameters. I have added it to the feature request list, please +1 it here https://vapi.canny.io/feature-requests/p/calllength-in-end-of-call-report
j
Yea it would be nice to just get a callDuration as part of json payload
I found 'secondsFromStart' on the last message from end of call report that can also be used to approximate duration of call
2 Views