English Swedish
Auto Light Dark
Auto Light Dark
English Swedish
Breadcrumbs

The Core User API

The Core User API lets an application act as one Dstny user. You can start and control calls, read call state, search contacts, set presence and diversions, and send SMS. The application sees and does only what that user can see and do. If the user cannot see a contact, user or queue in Dstny, the integration cannot either.

Access

You get access with an API ticket. A ticket belongs to one user and lists the APIs it may call.

  1. Sign in at bc.dstny.se with the credentials of the user the application will act as.

  2. Open the User view and select Tickets.

  3. Create a ticket and give it a name that tells you what it is for.

  4. Tick the permissions the ticket needs.

  5. Save and copy the token. You cannot read it again later.

The ticket is valid for one year. Use a dedicated user for integrations, so the ticket keeps working when a colleague leaves. A ticket can be revoked in the portal at any time.

You can also create a ticket from your application with POST /tickets/user/v1. The request uses HTTP Basic authentication with the user's name and password, and a one-time code if the user has 2FA. The body is {"expires": 3600, "ticketName": "example", "allowedApis": ["CONTACT"]}, and the response contains the token, the baseUrl to use and the expiry time. expires is in seconds. In allowedApis each scope is written in capital letters with underscores, for example CONTACT for Contact search and CALL_CONTROL for Call control. This suits interactive use better than systems that run unattended. For those, a service account can create tickets without the user's password. See the Service Account API.

Ticket scopes

A ticket works only for the scopes you select when you create it. There are 14 scopes. Each call in the API requires one of them, and a few calls require two.

Scope

What it covers

Call control

Control calls: make, answer, hold, resume, alternate, move, mute, park, pick up, send DTMF, ad-hoc conference, end a call. Read call state, follow it live and register webhooks for state changes. Start, pause, resume, stop, discard and save a recording during a call. Needs a Call Control API license for the user and "Enable Cloud CTI API" turned on for the user

Call recording

Recording control. The recording actions in the specification (start, pause, resume, stop, discard, save) are listed under Call control, so a ticket that controls recordings should have Call control as well

Call setup

Set up a call from a device, and manage diversions: the active diversion, diversion rules per line type and rule type, and the diversion tied to a presence activity. Also calendar events. Transferring a call, checking transfer status and cancelling a transfer need both Call setup and Call control

Reports

Listed when you create a ticket, but no call in the Core User API specification requires it

Communication log

List, read, mark as seen or played, and delete items in the user's call history, group inbox and voicemails

Contact search

Contacts: list, look up by number, page through the directory. Contact details, presence and availability of other users, scheduled presence, directory fields. Configuration settings such as answer places, presence roles and activities, and the legal, privacy and self-service links

ACD/attendant queues

Queue and attendant groups: list groups, group information, agent login and logout (also for federated groups), group call history, assigned calls, and subscribing to queue statistics

Event channel

Used for mobile chat. No call in the Core User API specification requires it

Line state

Read, create, update and delete line state entries, so an external telephony system can report line state for the user. Needs a Line State API license for the user

Personal contacts

Personal contacts for the user, a user group or the organization, and the favourites list (add, update, verify, delete)

Queue statistics

Current statistics for the organization, for one queue and for a user's queues. For agents and attendants in queue numbers and their supervisors

SMS sending

Sending SMS. The send call in the specification is listed under User info, so a ticket that sends SMS should have User info as well

User info

Photo, presence, activity, availability, note and role. The user's lines and active line, devices, presence shortcuts, and mobile subscriber settings such as caller ID and number presentation. Also the SMS send call

Voicemail settings

Read, update and reset the user's voicemail settings

Give the ticket the fewest scopes the integration needs.

Authenticate

Send the ticket as a bearer token. The ticket response includes the address to call (baseUrl). Always use that address, because the API only answers there.

GET {baseUrl}/api/call/state/v1/snapshot/{domain}/{userId}
Authorization: Bearer {token}
Accept: application/json

{domain} is your organization's domain and {userId} is the user the ticket belongs to. The example reads call state, so the ticket needs the Call control scope. Use JSON for requests and responses.

Common calls

Goal

Method and endpoint

Scope

List the user's queue and attendant groups and agent state

GET /user/acd-attendant-group/v1/{domain}/{user}

ACD/attendant queues

Search contacts or users by name or number

GET /contacts/list/{domain}/{user}?query=

Contact search

Look up a contact by number

GET /contacts/lookup/v1/{domain}/{user}/{number}

Contact search

Browse the contact list page by page

GET /contacts/page/v1/{domain}/{user}?index=&items=

Contact search

Read the user's current calls

GET /call/state/v1/snapshot/{domain}/{userId}

Call control

Read the user's presence

GET /user/info/{domain}/{user}/presence

User info

Read the user's call history

GET /communicationlog/{domain}/{userId}

Communication log

What you can do

  • Call control: make, answer, hold, resume, transfer, add to a conference, mute, park, send DTMF, end a call.

  • Call state: read the current state of a user or a call.

  • Contacts: search by name or number, look up an exact number, page through the directory, manage personal contacts and favourites.

  • Presence and activity: read and set presence, activity, note and availability, and manage presence shortcuts.

  • Diversions: read and set the active diversion and diversion rules.

  • Queues: log agents in and out, read queue statistics and group call history.

  • Communication log: read missed, incoming and outgoing calls.

  • Call recording: start, pause, resume, stop, discard and save a recording during a call.

  • Devices and lines: read the user's devices and lines, and set the active line.

  • Voicemail settings, and mobile subscriber settings such as caller ID and number presentation.

Live events and webhooks

Your application can get updates instead of asking repeatedly. Call state can be followed as a live stream (server-sent events) for a user or for one call. Some areas, such as call state and device changes, let you register a webhook with three values: targetUrl (where Dstny sends the updates), targetId (a name you choose, used later to remove the registration) and publicTarget. Set publicTarget to say whether your receiving address is on the same network as the Dstny service nodes or must be reached through the edge HTTP proxy.

Sending SMS

The user sends an SMS with POST /user/sms/{to} and a body such as {"smsText": "Hello"}. The user must be allowed to send SMS. The number in {to} is converted using the user's number plan rules. For example, if your organization converts 08 to +468, sending to 0890510 goes to +46890510. Replies are 200 (sent, no body), 400 (invalid request), 403 (not authorized), 404 (not found) and 503 (service unavailable).

Good to know

  • Call control actions can include a state token. The call is only changed if its state has not changed since you read it, which prevents conflicting actions.

  • The ticket gives full access to the scopes you chose, so keep it out of source code and logs. Plan to renew it before it expires.

  • Older versions of some calls are deprecated and are removed in Core 6.0.0. Use the versioned calls (/v1/) in new integrations.

Troubleshooting

What you see

Likely cause

What to do

401 or 403

The ticket expired, was deleted, or was created without the needed scope

Create a new ticket with the right scopes

Call control or call state fails although the ticket has the Call control scope

The user has no Call Control API license, or "Enable Cloud CTI API" is off

Check the license and the setting on the user

Line state reporting fails although the ticket has the Line state scope

The user has no Line State API license

Check the license on the user

Ticket creation fails

Wrong password, or the user has 2FA and no one-time code was sent

Check the login and add the one-time code

401 or 403 and the ticket looks correct

The call went to the wrong address

Use the baseUrl returned with the ticket

Contact search returns nothing

Usually a scope or permission problem, not missing data

Check that the ticket has the Contact search scope and that the user can see the contacts

The group list is empty

The user is not an agent or attendant in any group

Check the user's group membership

For access across the whole organization without a user login, see the Service Account API.

API reference

All calls, parameters and responses are in the Core User API specification.

To try the calls in Postman, import the Core User API Postman collection with File, Import. Fill in the variables baseUrl, domain, user and ticket.

Last updated: