Examples

Redirect Call to a new RCML

Live Call Modification POST request example:

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls/CALL_SID.json  \
   -d 'Url=http://mycompany.com/api19/demos/dial­alice.xml' \
   -u 'API_Token'

Redirect Call to a new RCML and connect both call legs

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls/CALL_SID.json  \
   -d 'Url=http://mycompany.com/tcml/demos/conference.xml' \
   -d 'MoveConnectedCallLeg=true' \
   -u 'API_Token'

Terminate In Progress call

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls/CALL_SID.json  \
   -d 'Status=completed' \
   -u 'API_Token'

Terminate Ringing call

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls/CALL_SID.json  \
   -d 'Status=canceled' \
   -u 'API_Token'

Modifying Live Calls - Example

  • In order to accomplish this, you need to create a client called Alice

  • Start a SIP phone and register Alice

  • From the terminal run the following curl command

  • Make sure Alice is using the port 5061

  • The "From=" could be any number of your choice

  • The Url is the default sample example provided with CallAPI.

Modifying a Live Call

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls.json  \
   -d 'From=+16175551212' \
   -d 'To=sip:alice@mycompany.com' \
   -d 'Url=https://ACCOUNT_SID:AUTH_TOKEN@mycompany.com/callapi/demos/hello-play.xml' \
   -u 'API_Token'

You will see an output similar to the one below:

{
  "sid": "CAfa51b104354440b09213d04752f50271",
  "date_created": "2013-11-01T03:41:14.488-06:00",
  "date_updated": "2013-11-01T03:41:14.488-06:00",
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "to": "alice",
  "from": "+16175551212",
  "status": "queued",
  "start_time": "2013-11-01T03:41:14.488-06:00",
  "price": "0.0",
  "direction": "outbound-api",
  "api_version": "2012-04-24",
  "uri": "/2012-04-24/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAfa51b104354440b09213d04752f50271.json",
  "subresource_uris": {
    "notifications": "/call/2012-04-24/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAfa51b104354440b09213d04752f50271/Notifications",
    "recordings": "/call/2012-04-24/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAfa51b104354440b09213d04752f50271/Recordings"
  }
}

Notice the "sid": "CAfa51b104354440b09213d04752f50271", This Call ID is what you must use to interact with the current call. You can now redirect the current call to another application as shown below Notice that the Call ID is referenced The call will now be redirected to the Url specified(hello-play.xml).

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls/CALL_SID.json  \
   -d 'From=+16175551212' \
   -d 'To=sip:alice@mycompany.com' \
   -d 'Url=https://ACCOUNT_SID:AUTH_TOKEN@mycompany.com/callapi/demos/hello-play.xml' \
   -u 'API_Token'

The output showing the same Call ID:

<CallResponse>
  <Call>
    <Sid>CAfa51b104354440b09213d04752f50271</Sid>
    <DateCreated>2013-11-01T03:41:14.488-06:00</DateCreated>
    <DateUpdated>2013-11-01T03:41:14.488-06:00</DateUpdated>
    <ParentCallSid/>
    <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
    <To>alice</To>
    <From>+16175551212</From>
    <PhoneNumberSid/>
       ..... TRUNCATED

You can still redirect the current call back to the previous application

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls/CALL_SID.json  \
   -d 'Url=https://ACCOUNT_SID:AUTH_TOKEN@mycompany.com/callapi/demos/hello-play.xml' \
   -u 'API_Token'

The output showing the same Call ID

<CallResponse>
  <Call>
    <Sid>CAfa51b104354440b09213d04752f50271</Sid>
    <DateCreated>2013-11-01T03:41:14.488-06:00</DateCreated>
    <DateUpdated>2013-11-01T03:41:14.488-06:00</DateUpdated>
    <ParentCallSid/>
    <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
    <To>alice</To>
    <From>+16175551212</From>
    <PhoneNumberSid/>
   ..... TRUNCATED

You can still redirect the current call back to the previous application

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Calls/CALL_SID.json  \
   -d 'Status=completed' \
   -u 'API_Token'

The output showing the same Call ID

<CallResponse>
  <Call>
    <Sid>CAfa51b104354440b09213d04752f50271</Sid>
    <DateCreated>2013-11-01T03:41:14.488-06:00</DateCreated>
    <DateUpdated>2013-11-01T03:41:14.488-06:00</DateUpdated>
    <ParentCallSid/>
    <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
    <To>alice</To>
    <From>+16175551212</From>
    <PhoneNumberSid/>
   ..... TRUNCATED

You can Mute/unMute an in progress call as shown bellow

curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Conferences/CONFERENCE_SID/Participants/CALL_SID.json  \
   -d 'Mute=true' \
   -u 'API_Token'

Sample Mute Response

<CallResponse>
  <Call>
    <Sid>CA02b649d3ffe24408a1e141be089f347b</Sid>
    <ConferenceSid>CFcc373b0637114f088eae954fa73f0f57</ConferenceSid>
    <DateCreated>Wed, 15 Mar 2017 10:10:57 +0000</DateCreated>
    <DateUpdated>Wed, 15 Mar 2017 10:15:33 +0000</DateUpdated>
    <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
    <Muted>true</Muted>
    <Hold>false</Hold>
    <StartConferenceOnEnter>true</StartConferenceOnEnter>
    <EndConferenceOnEnter>false</EndConferenceOnEnter>
    <Uri>/2012-04-24/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CA02b649d3ffe24408a1e141be089f347b</Uri>
  </Call>
</CallResponse>
curl -X POST https://v1.api19.com/call/2012-04-24/Accounts/ACCOUNT_SID/Conferences/CONFERENCE_SID/Participants/CALL_SID.json  \
   -d 'Mute=false' \
   -u 'API_Token'

Sample unMute Response

<CallResponse>
  <Call>
    <Sid>CA02b649d3ffe24408a1e141be089f347b</Sid>
    <ConferenceSid>CFcc373b0637114f088eae954fa73f0f57</ConferenceSid>
    <DateCreated>Wed, 15 Mar 2017 10:10:57 +0000</DateCreated>
    <DateUpdated>Wed, 15 Mar 2017 10:16:44 +0000</DateUpdated>
    <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
    <Muted>false</Muted>
    <Hold>false</Hold>
    <StartConferenceOnEnter>true</StartConferenceOnEnter>
    <EndConferenceOnEnter>false</EndConferenceOnEnter>
    <Uri>/2012-04-24/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CA02b649d3ffe24408a1e141be089f347b</Uri>
  </Call>
</CallResponse>

Last updated