Skip to main content
Solved

How to obtain the telephonySessionId for an inbound call answered by the softphone in case of multi-softphones in a single-queue case?

  • June 16, 2026
  • 17 replies
  • 178 views

## Setup

We use `ringcentral-softphone` to answer inbound calls that are routed through a single RingCentral **call queue** to one of several **agent softphones**.
- **4 softphones** sit behind one queue, each a distinct RC user/extension with its own SIP credentials.

## What we're trying to do

For every call we need to capture two kinds of data and store them under **one phone call record**, then display them together for a single call in our own UI:

1. **Internal logs** (from the Node softphone process): a small set of details we write to our database when the call starts, against a unique identifier.
2. **Telephony lifecycle**: the full call history — transfer → answered/rejected → transferred again → ended — which we obtain from an **account-level `telephony/sessions` webhook subscription** (or any better approach you'd recommend).

**The core question: how can we tie these two records together with the same identifier?**

## The problem

From the SIP connection in `ringcentral-softphone(-ts)`, the only identifier we get is the SIP **`Call-ID`** — we cannot obtain the **`telephonySessionId`**, which is the key the telephony webhook (and the Call Log API) use.

We tried your suggestion of subscribing to extension/account `telephony/sessions` events via webhook, and we *can* see a matching session id inside **`sipData`** — but with a catch:

- `sipData` is only present for the softphone whose **own credentials** were used
  to create the subscription.
- To get `sipData` for every call in the queue, we'd have to create a separate
  subscription **per softphone**, each using that softphone's own client
  ID/secret/credentials.

That approach is hard to maintain and debug (one subscription and credential set per softphone), and every softphone's subscription also receives **all** account events, which adds a lot of duplicate noise.

## Questions

What is the recommended, maintainable way to obtain or correlate the `telephonySessionId` for a call answered by one of several softphones in a single queue — ideally without creating and managing a separate subscription per softphone?

Specifically:
- Is the `telephonySessionId` (or `partyId`) available to the softphone in any SIP header on the INVITE that we could read? If so, could `ringcentral-softphone` expose it on the `CallSession` (e.g. `callSession.telephonySessionId`)?
- If not, is there a better correlation strategy than one subscription per softphone?

Thanks for the library — any guidance on this multi-softphone / single-queue case
would be a big help.

Best answer by PhongVu

@PhongVu 

The user active calls API provides response like:
 

{
"uri":"https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/active-calls?view=Simple&page=1&perPage=100"
"records":[
0:{
"uri":"https://platform.ringcentral.com/restapi/v1.0/account/123318033/extension/1234352/call-log/GSbrwP..."
"id":"GSbwerwPldcwIOswP"
"sessionId":"31243523123"
"startTime":"2026-06-18T15:32:07.000Z"
"duration":185
"durationMs":185000
"type":"Voice"
"internalType":"LocalNumber"
"direction":"Inbound"
"action":"Phone Call"
"result":"Accepted"
"to":{
"name":"Bibek chaulagain"
"phoneNumber":"+44123456782"
}
"from":{
"name":"AI Receptionist"
"phoneNumber":"+4412322345"
}
"recording":{
"uri":""
"id":"100033003404"
"type":"Automatic"
"contentUri":""
}
"extension":{
"uri":""
"id":132456784
}
"reason":"Accepted"
"reasonDescription":"The call was connected to and was accepted by this number."
"telephonySessionId":"s-w120msa235023231203213123"
"partyId":"p-w120msa235023231203213123-1"
}

The sample response you provided was from the subscribing to the presence event.
Could you please look into this?

My bad, call this API to get the call Id of an active call. Remember to set the “detailedTelephonyState=true”

17 replies

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • June 16, 2026

You can subscribe to the presence event notification instead of the telephony session event.

var eventFilters = [
'/restapi/v1.0/account/~/extension/AgentExt1ID/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/~/extension/AgentExt2ID/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/~/extension/AgentExt3ID/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/~/extension/AgentExt4ID/presence?detailedTelephonyState=true'
]

When a call is answered by an agent, you will get the event with the "telephonyStatus": "CallConnected" and an active call object which contains the call Id.

{
"extensionId": Agent4ExtId,
"telephonyStatus": "CallConnected",
"activeCalls": [
{
"id": "e9d2b7f8-0d9f-4dde-b0f3-a93596b7425c",
"direction": "Inbound",
"fromName": "...",
"from": "+1...",
"toName": "Agent 4",
"to": "+1...",
"telephonyStatus": "CallConnected",
"sessionId": "211010xxxx",
"startTime": "2026-06-....",
"partyId": "p-a0d7bc9041c98z19ed138595dz69b29d0000-2",
"telephonySessionId": "s-a0d7bc9041c98z19ed138595dz69b29d0000"
}
],
...

The active call Id “e9d2b7f8-0d9f-4dde-b0f3-a93596b7425c” can be used to match with the call-Id header value from your SIP phone. And thus you can use the partyId and the telephonySessionId values for your call log.


@PhongVu Thank you for your reply.

 

We store internal logs associating the call-Id header value from SIP phone.
And we have to track and save all Telephony lifecycle: the full call history —call answered → transfer → answered/rejected → transferred again → ended — which we obtain only from an account-level `telephony/sessions` webhook subscription.
The extension level webhook subscription does not seem to provide event after the call is transferred to another extension.

  1. How can we obtain full Telephony lifecycle and correlate with the internal logs (stored with call-Id header value from SIP phone) using your approach?
  2. And is there anyway we can achieve this without maintaining four subscription for each softphone users?

If we create subscriptions for all softphone users:

  1. Can we control the subscription expiration time ourselves? What is the maximum expiration period allowed?
  2. Are there any scenarios where a subscription could become invalid or stop delivering events? If so, what is the recommended approach to automatically renew or recreate subscriptions to ensure call logging continues without interruption?
  3. If we create a new subscription without revoking the existing one, will both subscriptions continue receiving the same events, or will only the most recently created subscription receive them?

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • June 17, 2026

@PhongVu Thank you for your reply.

 

We store internal logs associating the call-Id header value from SIP phone.
And we have to track and save all Telephony lifecycle: the full call history —call answered → transfer → answered/rejected → transferred again → ended — which we obtain only from an account-level `telephony/sessions` webhook subscription.
The extension level webhook subscription does not seem to provide event after the call is transferred to another extension.

  1. How can we obtain full Telephony lifecycle and correlate with the internal logs (stored with call-Id header value from SIP phone) using your approach?
  2. And is there anyway we can achieve this without maintaining four subscription for each softphone users?

If we create subscriptions for all softphone users:

  1. Can we control the subscription expiration time ourselves? What is the maximum expiration period allowed?
  2. Are there any scenarios where a subscription could become invalid or stop delivering events? If so, what is the recommended approach to automatically renew or recreate subscriptions to ensure call logging continues without interruption?
  3. If we create a new subscription without revoking the existing one, will both subscriptions continue receiving the same events, or will only the most recently created subscription receive them?

In your case, you will need to use that workaround solution by subscribe to both telephony session event and user presence?detailedTelephonyState=true event. You can use the telephony event payload to create your call log. The presence event payload is only for getting the call-Id to match with the agent’s SIP phone as you were asking in your previous question. Since the call queue is small (4 members) and if the queue is not very busy, you can call the user active calls API to read active call data instead of subscribing to the presence? event. Remember that the call-Id is only available in the active call object after the call is answered/connected.

Since you have only 4 agents, the best approach is to use a super admin user to subscribe to event notifications for all 4 agents.

var eventFilters = [
'/restapi/v1.0/account/~/extension/AgentExt1ID/telephony/sessions',
'/restapi/v1.0/account/~/extension/AgentExt1ID/telephony/sessions',
'/restapi/v1.0/account/~/extension/AgentExt1ID/telephony/sessions',
'/restapi/v1.0/account/~/extension/AgentExt1ID/telephony/sessions',
'/restapi/v1.0/account/~/extension/AgentExt1ID/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/~/extension/AgentExt2ID/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/~/extension/AgentExt3ID/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/~/extension/AgentExt4ID/presence?detailedTelephonyState=true'
]

Q/ Can we control the subscription expiration time ourselves? What is the maximum expiration period allowed?

A/ Set the expiresIn parameter when you create the subscription

Q/ Are there any scenarios where a subscription could become invalid or stop delivering events? If so, what is the recommended approach to automatically renew or recreate subscriptions to ensure call logging continues without interruption?

A/ If your server becomes unreachable, the subscription will be blacklisted. Read this dev guide article for details.

Q/ If we create a new subscription without revoking the existing one, will both subscriptions continue receiving the same events, or will only the most recently created subscription receive them?

A/ Multiple subscriptions will work. Each user can have max 20 active subscriptions. Avoid multiple subscriptions if you don’t really need them. Use update instead of revoke and create new one.


@PhongVu 

Thank you for your reply.

How can we detect when a subscription has been blacklisted or when event delivery has stopped, so that we can automatically renew the subscription or create a new one?

Additionally, if a subscription becomes blacklisted, what is the recommended approach: should we attempt to renew the existing blacklisted subscription, or should we delete it and create a new subscription instead?


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • June 17, 2026

@PhongVu 

Thank you for your reply.

How can we detect when a subscription has been blacklisted or when event delivery has stopped, so that we can automatically renew the subscription or create a new one?

Additionally, if a subscription becomes blacklisted, what is the recommended approach: should we attempt to renew the existing blacklisted subscription, or should we delete it and create a new subscription instead?

No notification if the subscription is blacklisted!

You need to make sure that the deliver address is always publicly accessible.

You should return 200 Ok for every notification event.

You can create a subscription with the expiresIn = 87000 (over a day) and renew it daily.

Once the subscription is blacklisted, delete and create a new one.


@PhongVu Thank you for your reply.

  1. When the subscription becomes invalid or blacklisted which we are able to renew/re-create after 10 minutes of blacklisted, then can we recover the logs in between that 10 minutes?
  2. Can you suggest approach to automatically renew or recreate subscriptions to ensure call logging continues without interruption?

If we use Active Calls API, what is the throttle limit for that API? As we can sometimes have 10/12 calls within a minute, we have to hit Active Calls API 10/12 times per minute, which could lead to threshold limit error.

Does Active Calls API provide both call-Id header value from SIP phone and telephonySessionId so we can correlate with internal logs store with the call-Id header value from SIP phone?


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • June 18, 2026

@PhongVu Thank you for your reply.

  1. When the subscription becomes invalid or blacklisted which we are able to renew/re-create after 10 minutes of blacklisted, then can we recover the logs in between that 10 minutes?
  2. Can you suggest approach to automatically renew or recreate subscriptions to ensure call logging continues without interruption?

If we use Active Calls API, what is the throttle limit for that API? As we can sometimes have 10/12 calls within a minute, we have to hit Active Calls API 10/12 times per minute, which could lead to threshold limit error.

Does Active Calls API provide both call-Id header value from SIP phone and telephonySessionId so we can correlate with internal logs store with the call-Id header value from SIP phone?

The answers to these questions can be found from my previous answers. Please click the dev guide article and the API reference links I provided above.


@PhongVu 
Does Active Calls API provide both call-Id header value from SIP phone and telephonySessionId so we can correlate with internal logs store with the call-Id header value from SIP phone?

I could not find any ID that matches the call-Id header value from SIP phone, however Active Call API mentioned that we get a sipUuidInfo which is Call session identifier, required for Telephony REST API. But when I checked I could not find sipUuidInfo in the API response.


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • June 18, 2026

@PhongVu 
Does Active Calls API provide both call-Id header value from SIP phone and telephonySessionId so we can correlate with internal logs store with the call-Id header value from SIP phone?

I could not find any ID that matches the call-Id header value from SIP phone, however Active Call API mentioned that we get a sipUuidInfo which is Call session identifier, required for Telephony REST API. But when I checked I could not find sipUuidInfo in the API response.

This was the answer!


“the queue is not very busy, you can call the user active calls API to read active call data instead of subscribing to the presence? event. Remember that the call-Id is only available in the active call object after the call is answered/connected.”

Sample response
 

{
"extensionId": 5958xxxx,
"telephonyStatus": "CallConnected",
"activeCalls": [
{
"id": "b56d82b9-8311-4482-8e8d-13d19eb73e9e",
"direction": "Inbound",
"fromName": "...",
"from": "+1650XXXXXX",
"toName": "Agent 1",
"to": "11XXX",
"telephonyStatus": "CallConnected",
"sessionId": "113625875XXX",
"startTime": "2026-06-17T14:53:33.787Z",
"partyId": "p-a78c620287a9ez19ed6127181z3c07e40000-3",
"telephonySessionId": "s-a78c620287a9ez19ed6127181z3c07e40000"
}
],

 


@PhongVu 

The user active calls API provides response like:
 

{
"uri":"https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/active-calls?view=Simple&page=1&perPage=100"
"records":[
0:{
"uri":"https://platform.ringcentral.com/restapi/v1.0/account/123318033/extension/1234352/call-log/GSbrwP..."
"id":"GSbwerwPldcwIOswP"
"sessionId":"31243523123"
"startTime":"2026-06-18T15:32:07.000Z"
"duration":185
"durationMs":185000
"type":"Voice"
"internalType":"LocalNumber"
"direction":"Inbound"
"action":"Phone Call"
"result":"Accepted"
"to":{
"name":"Bibek chaulagain"
"phoneNumber":"+44123456782"
}
"from":{
"name":"AI Receptionist"
"phoneNumber":"+4412322345"
}
"recording":{
"uri":""
"id":"100033003404"
"type":"Automatic"
"contentUri":""
}
"extension":{
"uri":""
"id":132456784
}
"reason":"Accepted"
"reasonDescription":"The call was connected to and was accepted by this number."
"telephonySessionId":"s-w120msa235023231203213123"
"partyId":"p-w120msa235023231203213123-1"
}

The sample response you provided was from the subscribing to the presence event.
Could you please look into this?


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • Answer
  • June 18, 2026

@PhongVu 

The user active calls API provides response like:
 

{
"uri":"https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/active-calls?view=Simple&page=1&perPage=100"
"records":[
0:{
"uri":"https://platform.ringcentral.com/restapi/v1.0/account/123318033/extension/1234352/call-log/GSbrwP..."
"id":"GSbwerwPldcwIOswP"
"sessionId":"31243523123"
"startTime":"2026-06-18T15:32:07.000Z"
"duration":185
"durationMs":185000
"type":"Voice"
"internalType":"LocalNumber"
"direction":"Inbound"
"action":"Phone Call"
"result":"Accepted"
"to":{
"name":"Bibek chaulagain"
"phoneNumber":"+44123456782"
}
"from":{
"name":"AI Receptionist"
"phoneNumber":"+4412322345"
}
"recording":{
"uri":""
"id":"100033003404"
"type":"Automatic"
"contentUri":""
}
"extension":{
"uri":""
"id":132456784
}
"reason":"Accepted"
"reasonDescription":"The call was connected to and was accepted by this number."
"telephonySessionId":"s-w120msa235023231203213123"
"partyId":"p-w120msa235023231203213123-1"
}

The sample response you provided was from the subscribing to the presence event.
Could you please look into this?

My bad, call this API to get the call Id of an active call. Remember to set the “detailedTelephonyState=true”


@PhongVu Thank you very much. You are a genius.

One final question:

If we receive a 429 Too Many Requests error because more than threshold of any RingCentral API calls are made within a minute, can we work around this by rotating between different RingCentral Client ID/Client Secret pairs that are connected to the same user account?

Or is the rate limit enforced at the user account level, meaning that rotating Client IDs and Secrets for the same user would not bypass the throttle limit?

Do you have any recommendations or best practices for handling this scenario and avoiding rate-limit issues?


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • June 18, 2026

@PhongVu Thank you very much. You are a genius.

One final question:

If we receive a 429 Too Many Requests error because more than threshold of any RingCentral API calls are made within a minute, can we work around this by rotating between different RingCentral Client ID/Client Secret pairs that are connected to the same user account?

Or is the rate limit enforced at the user account level, meaning that rotating Client IDs and Secrets for the same user would not bypass the throttle limit?

Do you have any recommendations or best practices for handling this scenario and avoiding rate-limit issues?

This endpoint is in the Light usage group. E.g. 50 API calls per minute. If that is not enough, then the best approach is to use the /presence event notification.

Rate limit is per API, per user, per app (app client Id).


@PhongVu Got it, I will check this once. And Thanks again.


@PhongVu 

We are using the List Company Call Records API to retrieve call logs and store the logs in our own database. But we are not able to determine whether a call has fully ended or not, so we can store only those logs which has full call legs.

Is there a specific field in the call log response that reliably indicates that a call has been ended completely or is there any recommended approach to find this out?


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • June 23, 2026

@PhongVu 

We are using the List Company Call Records API to retrieve call logs and store the logs in our own database. But we are not able to determine whether a call has fully ended or not, so we can store only those logs which has full call legs.

Is there a specific field in the call log response that reliably indicates that a call has been ended completely or is there any recommended approach to find this out?

The call log API returns only completed call records. If you call the API too close to the current time (set by the dateFrom and dateTo params), you may miss those active calls which is in progress (if any), unless you call the API again with overlap dateFrom and dateTo time range.

You can use the extract sync API instead, the API also returns only completed call records, but it keep track of the active calls and will return those in the next sync.


@PhongVu Thank you for the reply.

For now we've stuck with the List Company Call Records API and handle completeness like this:

  • We poll once a minute with overlapping dateFrom(3 hours before dateTo)/dateTo(current datetime while logging) windows, and keep each call "pending" until its record shows up, so we don't miss in-progress calls. And the API seems to return In progress calls as well.
  • Before storing, we confirm the call has actually ended by cross-checking List Company Active Calls — if the telephonySessionId is still there with result: "In Progress", we skip it.
  • Once it's no longer active, we wait for a short cooling period until the record's lastModifiedTime stops changing, since RingCentral appends the final legs/duration/recording shortly after the call ends. Only then do we save it.

- Does this approach looks feasible to log ended call logs?

- Also, we are currently assuming that result: "In Progress" from the Active Calls API indicates that a call has not yet ended. Are there any other possible result values, besides "In Progress", that also represent a call that is still active and has not been completed?