Login and Authentication

User login

Users can connect using login, password and phone number:

var wsurl = "ws://"+server+"/xuc/api/2.0/cti?token="+token;

Agent login

An agent can be logged in using Cti.loginAgent(agentPhoneNumber, agentId). For the moment, the phone number used for agent login should be the same as the one used for user login, otherwise you will get many error messages “LoggedInOnAnotherPhone”.

Following cases are handled:

  • agent is not logged and requests a login to a known line: the agent is logged in
  • agent is not logged and requests a login to an unknown line: an error is raised:
  • agent is already logged on the requested line: the agent stays logged
  • agent is already logged on another line: an error is raised and the agent stays logged (on the number where he was logged before the new request). It’s up to the implementation to handle this case.
  • agent is not logged and requests a login to a line already used by another agent: the agent takes over the line and the agent previously logged on the line is unlogged

Generic CTI Events


  • Cti.MessageType.ERROR


  • Cti.MessageType.LOGGEDON

Directory And Favorites

Cti.directoryLookUp: function(term)

This command deprecates previously used Cti.searchDirectory(pattern). This command deprecates previously used Cti.searchDirectory(pattern) removed in xuc xivo16 versions.

Associated Handler


Triggered by command Cti.directoryLookUp(pattern).

{ "msgType": "DirectoryResult",
    "ctiMessage": {
        "entries": [
            { "status": 0, "entry": [ "hawkeye", "pierce", "1002", "0761187406", "false"]},
            { "status": -2, "entry": [ "peter", "pan", "1004", "", "false"]}],
            [""Firstname", "Lastname", "Number", "Mobile", "Favorite"]}}

Cti.getFavorites: function()

Cti.addFavorite: function(contactId, source)

Cti.removeFavorite: function(contactId, source)

Cti Events


  • Cti.MessageType.SHEET
 "msgType": "Sheet",
 "ctiMessage": {
   "timenow": 1425055334,
   "compressed": true,
   "serial": "xml",
   "payload": {
     "profile": {
       "user": {
         "sheetInfo": [
             "value": "",
             "name": "popupUrl",
             "order": 10,
             "type": "url"
             "value": "&folder=1234",
             "name": "folderNumber",
             "order": 30,
             "type": "text"
             "value": "",
             "name": "popupUrl1",
             "order": 20,
             "type": "url"
   "channel": "SIP/1k4yj2-00000013"

User Statuses

  • Cti.MessageType.USERSTATUSES : “UsersStatuses”

User Status Update

  • Cti.MessageType.USERSTATUSUPDATE : “UserStatusUpdate”,

User Config Update

  • Cti.MessageType.USERCONFIGUPDATE : “UserConfigUpdate”,
    "firstName":"Alice","lastName":"Johnson","fullName":"Alice Johnson","mobileNumber":"064574512","agentId":22,"lineIds":[5],"voiceMailId":58,"voiceMailEnabled":true}}

Phone Status Update


Phone Events

  • Cti.MessageType.PHONEEVENT

Phone events are automatically sent when application is connected.


        "otherDName":"Jane Black",
        "callDirection": "Incoming",
        username: "jblack"
fields Description
Event types
  • EventReleased
  • EventDialing
  • EventRinging
  • EventEstablished
  • EventOnHold
DN The directory number of the event
otherDN Can be calling number of called number
otherDName Can be name of caller of called number
queueName Optional, the queue name for inbound acd calls
callDirection Can be Incoming or Outgoing
UserData Contains a list of attached data, system data XIVO_ or data attached to the call key beginning by USR_
username Can be the username cti of called number, it’s only defined when the called user is an internal user

If you use the following preprocess subroutine

exten = s,1,Log(DEBUG,**** set user data ****)
same  =       n,SET(USR_DATA1=hello)
same  =       n,SET(USR_DATA2=24)
same  =       n,SET(USR_DATA3=with space)
same  =       n,Return()

you will get these data in the events. Data can also be attached using the Cti.dial command.

You can also request a message with a concatenation of PhoneEvents for current calls by Cti.getCurrentCallsPhoneEvents command. The response to this command is formatted as follows:

        "events": [
          "otherDName":"Jane Black",
          "callDirection": "Incoming",

Phone Hint Status Events

You can subscribe to PhoneHintStatusEvents using Cti.subscribeToPhoneHints, allowing you to monitor state of the phone line with a given number. PhoneHintStatusEvents has the following format:


The phone hint status code can be resolved to a name using the Cti.PhoneStatus object in the cti.js. E.g., the status 0 from the example above stands for “AVAILABLE”.

Voice Mail Status Update

  • VOICEMAILSTATUSUPDATE : “VoiceMailStatusUpdate”,

User Right Profile

  • Cti.MessageType.RIGHTPROFILE: “RightProfile”
{"msgType":"RightProfile","ctiMessage":{"profile":"Supervisor", "rights":["dissuasion","recording"]}}

This message is sent upon connection to the xuc websocket. The profile can be one of: “Supervisor”, “Admin”, “NoRight”. The rights property contains an array with additional rights:

  • “recording”: User has access to recording management settings on queues
  • “dissuasion”: User has access to dissuasion management settings on queues

Queue Statistics

  • Handler on : Cti.MessageType.QUEUESTATISTICS

The handler is executed when a notification of new statistic values is received. Each message contains one or more counters for one queue. The queue is identified by its queueId. See example below for reference. The queue’s id can be used to retrieve queue’s configuration, see Queue Configuration.

Following counters are available:

  • TotalNumberCallsEntered
  • TotalNumberCallsAnswered
  • PercentageAnsweredBefore15
  • TotalNumberCallsAbandonned
  • TotalNumberCallsAbandonnedAfter15
  • PercentageAbandonnedAfter15
  • WaitingCalls
  • LongestWaitingTime
  • EWT
  • AvailableAgents
  • TalkingAgents

Some events contain a queueRef with a queue’s name instead of the queueId. This issue should be eliminated in future versions.


Queue Calls

  • Handler on: Cti.MessageType.QUEUECALLS

Awaiting calls in a queue. Subscription to the events with : Cti.subscribeToQueueCalls(9) (9 being the queueId). Unsubscription with: Cti.unSubscribeToQueueCalls(9).

{"queueId":9,"calls":[{"position":1,"name":"John Doe","number":"33356782212","queueTime":"2015-07-16T10:40:16.626+02:00"}]}

Queue Configuration

  • QUEUECONFIG : “QueueConfig”,
{"id":8,"context":"default","name":"blue","displayName":"blue sky","number":"3506","recording_mode":"recorded","recording_activated":1}

Queue List

  • QUEUELIST : “QueueList”,
        {"id":170,"context":"default","name":"bluesky","displayName":"Bl Record","number":"3012"},
        {"id":6,"context":"default","name":"__switchboard_hold","displayName":"Switchboard hold","number":"3005"},
        {"id":2,"context":"default","name":"yellow","displayName":"yellow stone","number":"3001"},
        {"id":7,"context":"default","name":"green","displayName":"green openerp","number":"3006"},
        {"id":3,"context":"default","name":"red","displayName":"red auto polycom","number":"3002"},
        {"id":11,"context":"default","name":"pool","displayName":"Ugips Pool","number":"3100"},

Queue Member

  • Handler on : Cti.MessageType.QUEUEMEMBER

Received when an agent is associated to a queue or a penalty is updated. Penalty is -1 when agent is removed from a queue


Queue Member List

  • Handler on : Cti.MessageType.QUEUEMEMBERLIST

Agent State Event


    • AgentLogin (DEPRECATED: Agent are now going directly from AgentLoggedOut to AgentReady)
    • AgentReady
    • AgentOnPause
    • AgentOnWrapup
    • AgentRinging
    • AgentDialing
    • AgentOnCall
    • AgentLoggedOut

Agent Error

  • Cti.MessageType.AGENTERROR

Agent Directory

  • Cti.MessageType.AGENTDIRECTORY

Triggered by command Cti.getAgentDirectory

{"directory": [
    { "agent":
        {"context": "default", "firstName": "bj", "groupId": 1, "id": 8, "lastName": "agent", "number": "2000"},
        "agentState": {"agentId": 8, "cause": "", "name": "AgentReady", "phoneNb": "1001", "queues": [1, 2], "since": 2 }}]}

Agent Configuration

  • AGENTCONFIG: “AgentConfig”

Triggered when agent configuration changes

{"id":23,"firstname":"Jack","lastname":"Flash","number":"2501","context":"default","member": [

Agent List

  • Cti.MessageType.AGENTLIST

Receives agent configuration list in a javascript Array : Command Cti.getList(“agent”);


Agent Listen

  • AGENTLISTEN: “AgentListen”,

Receives agent listen stop / start event, received automatically if user is an agent, no needs to subscribe.


Agent Group List

  • AGENTGROUPLIST : “AgentGroupList”

Agent group list triggered by command : Cti.getList(“agentgroup”)


Agent Statistics

Received on subscribe to agent statistics with method Cti.subscribeToAgentStats(), current statistics are received automatically on subscribe.

  • AGENTSTATISTICS : “AgentStatistics”

Call History


Get the call history of the logged in user, limited to the last size calls.


Get the call history of the logged in agent, limited to the last size calls.

Cti.getQueueCallHistory(queue, size)

Get a call history for a queue or a set of queues. You may pass part of a queue name (not display name).

i.e. pass bl if you want to match queue name blue, black and blow

Associated Handler CALLHISTORY

Received when calling the above methods Cti.getAgentCallHistory(size) or Cti.getUserCallHistory(size) .

  • CALLHISTORY : “CallHistory”
     "start":"2014-01-01 08:00:00",

For queue calls status can be :

  • full - full queue
  • closed - closed queue
  • joinempty - call arrived on empty queue
  • leaveempty - exit when queue becomes empty
  • divert_ca_ratio -call redirected because the ratio waiting calls/agents was exceeded
  • divert_waittime - call redirected because estimated waiting time was exceeded;
  • answered - call answered
  • abandoned - call abandoned
  • timeout - maximum waiting time exceeded

For other calls

  • emitted
  • missed
  • ongoing

Callback Events

Callback lists

Received when calling Callback.getCallbackLists().

  • CALLBACKLISTS : “CallbackLists”
 "name":"Liste de test",
   "dueDate": "2016-08-01",
   "preferredPeriod": {
      "default": false,
      "name": "Afternoon",
      "periodStart": "14:00:00",
      "periodEnd": "17:00:00",
      "uuid": "d3270038-e20e-498a-af71-3cf69b5cc792"

Callback Taken

Received after taking a callback with Callback.takeCallback(uuid).

  • CALLBACKTAKEN : “CallbackTaken”

Callback Started

Received after starting a callback with Callback.startCallback(uuid, phoneNumber).

  • CALLBACKSTARTED : “CallbackStarted”

Callback Clotured

Received after giving to a callback a status different of Callback.

  • CALLBACKCLOTURED : “CallbackClotured”

Callback Released

Received after releasing a callback with Callback.releaseCallback(uuid).

  • CALLBACKRELEASED : “CallbackReleased”

Callback Updated

Received when calling Callback.updateCallbackTicket(uuid, status, description, dueDate, periodUuid) with a new due date or period.

  • CALLBACKREQUESTUPDATED : “CallbackRequestUpdated”
   "dueDate": "2016-08-01",
   "preferredPeriod": {
      "default": false,
      "name": "Afternoon",
      "periodStart": "14:00:00",
      "periodEnd": "17:00:00",
      "uuid": "d3270038-e20e-498a-af71-3cf69b5cc792"

Membership Events

User default membership

Received when calling Membership.getUserDefaultMembership(userId).

  • USERQUEUEDEFAULTMEMBERSHIP: “UserQueueDefaultMembership”
  "membership": [

Agent Methods

Cti.loginAgent(agentPhoneNumber, agentId)

Log an agent


Un log an agent

Cti.pauseAgent(agentId, reason)

Change agent state to pause.

  • agentId: Id of the agent to set state for. Can be omitted to change current loggedin agent state.
  • reason: Optional string to label the kind of pause to set.


Change agent state to ready

  • agentId: Id of the agent to set state for. Can be omitted to change current loggedin agent state.


Listen to an agent

Cti Methods


Update user status using a cti server configured status name


Set or unset do not disturb, state true or false

Phone Methods


Attach data to the device current calls. When there is a call connected to a device, Data can be attached by passing key values as a json object Cti.setData(“{‘var1’:’val1’,’USR_var2’:’val2’}”);

The folowing json message is then sent to the server :


When the call is transfered i.e. (Cti.directTransfer(destination)), data is sent in the event ringing see Phone Events, and in subsequent events. Data is not propagated in the reporting database.

   "userData":{    "XIVO_CONTEXT":"from-extern",

Note that USR_ prefix is added to the key, if the key does not start with it. Only attached data beginning with USR_ are sent back to the client API.


When transfering a call, these variables are attached to the new channel however to prevent propagation on all trunk channels, your trunk name must contain ‘trunk’ so they can be distinguished from sip devices.

Cti.dial(destination, variables)

Place a call to destination with the provided variables. Variables must take the following form:

    var1: "value 1",
    var2: "value 2"

USR_var1 and USR_var2 will be attached to the call and propagated to Phone Events

Cti.dialFromMobile(destination, variables)

Place a call from logged user’s mobile number to destination with the provided variables. Variables must take the following form:

    var1: "value 1",
    var2: "value 2"

USR_var1 and USR_var2 will be attached to the call and propagated to Phone Events

Cti.dialFromQueue(destination, queueId, callerId, variables)

Creates outgoing call to destination from some free Agent attached to queueId. Caller id on both sides is set to callerId.

Variables must take the following form:

    var1: "value 1",
    var2: "value 2"

USR_var1 and USR_var2 will be attached to the call and propagated to Phone Events

Limitations: Queue No Answer settings does not work - see No Answer. Except: when there is no free Agent to queue (none attached, all Agents on pause or busy), then No answer settings work (but Fail does not).


Line should be configured with enabled “Ring instead of On-Hold Music” enabled (on “Application: tab in queue configuration - see Queues). Otherwise the queue will answers the call and the destination rings even if there are no agents available.


Originate a call


Hangup a call


Answer a call


Put current call on hold


Tranfert to destination


Start a transfer to a destination


Complete previously started transfer


Cancel a transfer


Pause call recording


You can only pause the recording of a call answered by an agent (i.e. a call sent via a Queue towards an Agent).


Unpause call recording


You can only pause the recording of a call answered by an agent (i.e. a call sent via a Queue towards an Agent).


Request a list of configuration objects, objectType can be :

  • queue
  • agent
  • queuemember

Triggers handlers QUEUELIST, AGENTLIST, QUEUEMEMBERLIST. Subscribes to configuration modification changes, handlers QUEUECONFIG, AGENTCONFIG, QUEUEMEMBER can also be called


Request the list of conference rooms. Also receive event when the list is updated.


The xuc user must have a line.

    "number": "4000",
    "name": "public",
    "pinRequired": false,
    "startTime": 1519659524032,
    "members": [
        "joinOrder": 1,
        "joinTime": 1519659524032,
        "muted": false,
        "name": "James Bond",
        "number": "1002",
        "username": "jbond"
    "number": "4001",
    "name": "conference_support",
    "pinRequired": true,
    "startTime": 0,
    "members": []


Request PhoneEvents for current device calls. See Phone Events for answer description.


  • phoneNumbers (Array of string): list of phone numbers to subscribe

Subscribe to PhoneHintStatusEvents for a list of phone numbers. You will get an initial event with the current Phone Hint Status (see Phone Hint Status Events for details) for every subscribed phone number and then a new Phone Hint Status Events for every change to the phone number state. After the Xuc server restart it may happen that the current phone state is unknown, in which case you will not get the initial event, only the first event update. You can repeat the command to subscribe to more numbers. The subscription is valid for the current websocket and can be cancelled either by closing the websocket, or by the Cti.unsubscribeFromAllPhoneHints() command.


This command allows you to cancel all previous subscription to phone hints.

Cti.setAgentQueue(agentId, queueId, penalty)

If agent is not associated to the queue, associates it, otherwise changes the penalty

On success triggers a Queue Member event, does not send anything in case of failure :


Cti.removeAgentFromQueue(agentId, queueId)

On success triggers a queue member event with penalty equals to -1, does not send anything in case of failure :



Subscribe to agent statistics notification. When called all current statistics are receive, and a notification is received for each updates. Both initial values and updates are transmitted by the Agent Statistics events.


This command subscribes to the queue statistics notifications. First, all actual statistics values are sent for initialisation and then a notification is sent on each update. Both initial values and updates are transmitted by the QUEUESTATISTICS events.


Forward on non answer


Unconditionnal forward


Forward on busy

Callback Commands


Retrieve the lists of callbacks with teir associated callback requests, and subscribe to callback events.


Take the callback with the given uuid with the logged-in agent.


Release the callback which was previously taken

Callback.startCallback(uuid, phoneNumber)

Launch the previously taken callback with the provided phone number.

Callback.updateCallbackTicket(uuid, status, description, dueDate, periodUuid)

Update a callback ticket wih the provided description and status. Allowaed values for status are:

  • NoAnswer
  • Answered
  • Fax
  • Callback

dueDate is an optional parameter specifying the new due date using ISO format (“YYYY-MM-DD”).

periodUuid is an optional parameter specifying the new preferred period for the callback.

Membership Commands


Initialize the Membership library using the given Cti object.


Request the default membership for the given user id. Warning, the userId is not the same as the agentId.

Membership.setUserDefaultMembership(userId, membership)

Set the default membership for the given user id. Warning, the userId is not the same as the agentId. ‘membership’ should be an array of Queue membership like:


Membership.setUsersDefaultMembership(userIds, membership)

Set the default membership for the given array of user id. Warning, the userId is not the same as the agentId. ‘userIds’ should be an array of user id like :

[1, 2, 3]

‘membership’ should be an array of Queue membership like:



Apply the existing default configuration to a set of users. Warning, the userId is not the same as the agentId. ‘usersIds’ should be an array of userId like:

[1, 2, 7, 9]

Security considerations

Defining a user profile in the ConfigMGT impact the behavior of this api.

No Profile

If no profile is found, the behavior falls back on the Admin Profile behavior.

Admin Profile

An admin profile will be allowed to receive all events and send all commands.

Supervisor Profile

A supervisor profile has the some properties impacting the events he can receive:

  • A list of queue which will filter the following events based on the queues in this list (send event only for queues defined in the list):
    • QueueList
    • QueueMemberList
    • QueueStatistics
  • A list of groups which will filter the following events based on the groups in this list (send event only if matching agent group is in the list):
    • AgentStateEvent
    • AgentStatistics
    • AgentGroupList
    • AgentList