Empire Unified: API specification - Empire Telecom

Empire Unified: API specification

Empire Telecom · Empire Unified

Empire Unified SIP trunks run on the same platform as EmpireUC, so you can read and manage your trunks, numbers, call records, recordings, 911 addresses and live events through the NetSapiens API v2.

Open the customer portal →Where: Sign in to the Empire Telecom customer portal at empiretelecom.io.
Direct link: https://empiretelecom.io

Empire Unified is Empire Telecom's SIP trunking service for sites that keep their own phone system (PBX) and want Empire to carry their calls. It runs on the same platform as EmpireUC, Empire's cloud phone system, which is built on NetSapiens. That means Empire Unified customers use the same NetSapiens API v2: a JSON REST API with bearer-token authentication. For a SIP trunk customer, the useful parts are your domain, your SIP connections (trunks), your phone numbers and where they route, call detail records, recordings, emergency (911) addresses and event subscriptions. In short: everything you need to monitor and report on a trunk is available, while core routing changes are normally made by Empire Telecom.

This article covers only the parts of the API that matter for SIP trunking. For authentication, error codes, paging and the full endpoint list, see the companion article "EmpireUC: API specification".

Tip: You do not need code to see your calls and numbers. Empire Unified customers can view them in the Phones section of the Empire Telecom customer portal. Use the API when you want to feed call data into your PBX reporting, billing or monitoring tools.

At a glance

ItemDetail
API typeREST over HTTPS (OpenAPI 3.1)
API versionNetSapiens API v2, platform release 44.x
Base URLhttps://<your-EmpireUC-API-server>/ns-api/v2 (Empire Telecom provides the server address)
AuthenticationToken from POST /tokens (client ID + secret + login), or an API key; sent as Authorization: Bearer <token>. Details in "EmpireUC: API specification"
Data formatJSON, kebab-case field names
Your accountA domain with a numeric ID; ~ means "my domain"
TrunksSIP connections under your domain
SandboxNo public sandbox; test against a quiet period or test number arranged with Empire Telecom
Rate limitsNot published; poll gently and use event subscriptions for live data
Webhooks / eventsEvent subscriptions (POST /subscriptions), near-real-time (about every 3 seconds)
SDKsNone official; any HTTP client, or generate one from the OpenAPI file
Developer portaldocs.ns-api.com (version 44.4)
Status pageNo public status page; contact Empire Telecom support
How to get accessAsk Empire Telecom for API access; we request the client ID and secret and set the scope

Getting access

1Ask Empire Telecom for API access and say it is for an Empire Unified (SIP trunk) account. Empire requests an API client (client ID and client secret) for you and delivers it securely.
2Agree a scope. Tell Empire Telecom what you need to do. Office Manager scope covers your own domain - its connections, numbers, call records and recordings. For reporting and monitoring tools, a read-only API key is the safer choice.
3Get the server address from Empire Telecom. Your base URL is https://<your-EmpireUC-API-server>/ns-api/v2.
4Get a token with POST /tokens (JSON body, grant_type password, then refresh_token to renew). The client ID and secret are two separate fields; putting both in one field returns Invalid_client.
5Test with a read call, such as GET /domains/~ and GET /domains/~/connections.
6For unattended servers, consider a read-only API key restricted to your server's IP addresses. Creating one needs a bearer token first; Empire Telecom can arrange it.

Authentication

Same as EmpireUC. In brief:

POST https://<your-EmpireUC-API-server>/ns-api/v2/tokens
Content-Type: application/json

{
"grant_type": "password",
"client_id": "<client_id>",
"client_secret": "<client_secret>",
"username": "<user>@<domain>",
"password": "<password>"
}

Use the returned access_token as Authorization: Bearer <access_token>. When it expires, call POST /tokens again with "grant_type": "refresh_token" and the refresh_token. API keys (60 characters, prefixed nsd_ for Office Manager scope) are also sent as a bearer token. Full details, MFA and JWT options are in "EmpireUC: API specification".

Endpoints and resources

Paths are relative to https://<your-EmpireUC-API-server>/ns-api/v2. {domain} is your numeric domain ID or ~.

Domain (your account)

MethodPathWhat it does
GET/versionAPI version and server time (a good health check)
GET/domains/~Your own domain
GET/domains/{domain}Read domain settings
GET/domains/{domain}/billingDomain with billing summary

SIP connections (trunks)

A connection is the SIP trunk between the platform and your PBX or SBC. It holds the match pattern that identifies your traffic, your PBX address, optional SIP registration credentials, transport (UDP, TCP or TLS), media and caller ID handling, and call limits.

MethodPathWhat it does
GET/domains/{domain}/connectionsList the trunks on your domain
GET/domains/{domain}/connections/{connection-id}Read one trunk
PUT/domains/{domain}/connections/{connection-orig-match-pattern}Update a trunk
DELETE/domains/{domain}/connections/{connection-id}Delete a trunk
POST/connectionsCreate a connection (requires connection-orig-match-pattern and domain)
GET/connectionsAll connections visible to your token
GET/connections/countCount connections

Useful connection fields:

FieldMeaning
connection-orig-match-patternPattern that identifies calls from your PBX
connection-term-match-patternPattern used for calls to your PBX (defaults to the originating pattern)
connection-addressYour PBX or SBC address
descriptionFree-text label
connection-orig-enabled, connection-term-enabledWhether calls from and to your PBX are allowed (yes/no)
connection-sip-transport-protocolUDP (default), TCP or TLS
connection-sip-registration-username, -password, -realmCredentials if your PBX registers to the platform
connection-require-encrypted-audio-enabledRequire SRTP: yes, no or optional
connection-audio-relay-enabledWhether media is relayed through the platform
limits-max-active-calls-orig, -term, -totalCall path (concurrent call) limits
dial-plan, dial-policyDial plan and dialling permissions applied to the trunk
time-zoneTime zone for the trunk

Important: Changing a connection's address, transport or match pattern can stop calls immediately. Ask Empire Telecom to make trunk changes, or test them in a maintenance window. Concurrent call limits are tied to the number of call paths on your Empire Unified plan.

Carrier-side routes (/routes and /routes/{route-id}/routecon) are platform-level objects above your domain; ask Empire Telecom if a carrier route needs to change.

Phone numbers (DIDs) and where they go

MethodPathWhat it does
GET/domains/{domain}/phonenumbersList your numbers and their routing
GET/domains/{domain}/phonenumbers/countCount numbers
GET/domains/{domain}/phonenumbers/{phonenumber}Read one number
PUT/domains/{domain}/phonenumbers/{phonenumber}Change where a number is delivered

For a SIP trunk, numbers are normally delivered to your connection. The routing is in dial-rule-application; the trunk-related values include to-connection, to-connection-or-user-no-failover, to-connection-no-timeout, to-connection-block-caller-id, to-connection-add-header and to-connection-add-header-force-caller-id. The destination is dial-rule-translation-destination-user (and -host). Other values such as to-user, to-callqueue and to-voicemail send the number to EmpireUC features instead, which is handy as a failover.

PUT /domains/~/phonenumbers/12015550100
{
"dial-rule-application": "to-connection",
"dial-rule-translation-destination-user": "[*]",
"dial-rule-description": "Main line to on-site PBX"
}

New numbers and porting are ordered through Empire Telecom.

Dial plans and dial rules

Dial rules translate and route numbers inside a dial plan (for example, a short code that goes to a particular destination).

MethodPathWhat it does
GET/domains/{domain}/dialplans/{dialplan}/dialrulesRead the dial rules in a dial plan
POST/domains/{domain}/dialplans/{dialplan}/dialrulesAdd a dial rule
PUT/domains/{domain}/dialplans/{dialplan}/dialrules/{dialrule}Update a dial rule
DELETE/domains/{domain}/dialplans/{dialplan}/dialrules/{dialrule}Delete a dial rule
POST/domains/{domain}/dialplansCreate a dial plan for the domain

Rules use fields such as dial-rule-matching-to-uri and dial-rule-translation-destination-user. Most trunk customers never need to change these; ask Empire Telecom first.

Call detail records (CDRs)

MethodPathWhat it does
GET/domains/{domain}/cdrsCall records for your domain (datetime-start, datetime-end required)
GET/domains/{domain}/cdrs/countCount calls and total minutes

Filters: datetime-start, datetime-end, type (Inbound, Outbound, On-net, Off-net, Missed, Received), dialled, caller, start, limit (up to 1,000 per page). Fields that matter for trunk reporting: id, call-direction, call-start-datetime, call-answer-datetime, call-disconnect-datetime, call-orig-caller-id, call-orig-to-user, call-term-user, call-talking-duration-seconds, call-total-duration-seconds, call-disconnect-reason-text, call-audio-codec, call-orig-ip-address, call-term-ip-address, call-orig-call-id and call-term-call-id. The IP address and codec fields are useful when troubleshooting a trunk.

Live calls

MethodPathWhat it does
GET/domains/{domain}/callsCalls in progress on your domain
GET/domains/{domain}/calls/countNumber of calls in progress (compare with your call path limit)

Recordings

Recordings are fetched by call ID from the CDR (call-orig-call-id):

MethodPathWhat it does
GET/domains/{domain}/recordings/{callid}Recording for a call; the response includes file-access-url, file-duration-seconds and call-recording-status

A recording exists only if recording is turned on for that traffic; ask Empire Telecom. Many PBX sites record locally on the PBX instead.

Emergency (911) addresses

Every location that can dial 911 needs a validated address. Keep addresses current when phones or buildings change.

MethodPathWhat it does
GET/domains/{domain}/addressesList your emergency addresses
POST/domains/{domain}/addresses/validateCheck an address before saving
POST/domains/{domain}/addressesCreate an address
PUT/domains/{domain}/addresses/{emergency-address-id}Update an address
DELETE/domains/{domain}/addresses/{emergency-address-id}Delete an address
GET/domains/{domain}/addresses/countCount addresses
GET/domains/{domain}/addresses/endpointsAddress endpoints (named locations, optionally with a callback number)
POST/domains/{domain}/addresses/endpointsCreate an address endpoint

Required fields: address-name, caller-name, address-line-1, address-city, address-state-province-abbreviation, address-postal-code, address-country-abbreviation, address-location-description.

Important: With a SIP trunk, your PBX decides which caller ID is sent on a 911 call. Make sure each building's outbound caller ID matches a number whose 911 address is that building. Ask Empire Telecom to review your 911 setup when you add a site.

Webhooks and events

Use event subscriptions to have the platform push changes to your HTTPS URL.

MethodPathWhat it does
POST/subscriptionsCreate a subscription
GET/subscriptionsList subscriptions
GET/subscriptions/{id}Read one
PUT/subscriptions/{id}Update one
DELETE/subscriptions/{id}Delete one
GET/domains/{domain}/subscriptionsSubscriptions for your domain

The most useful models for trunks are cdr (one event per completed call, ideal for billing and reporting) and call (changes to calls in progress, for live dashboards). Example:

POST /ns-api/v2/subscriptions
{
"model": "cdr",
"post-url": "https://hooks.example.org/empire-unified/cdr",
"domain": "<domain>"
}

Events are JSON arrays sent by HTTP POST. Each post includes an X-Correlation-ID header with the subscription ID. Delivery is near-real-time: the platform checks for changes about every 3 seconds. Subscriptions created with a timed token expire with it unless you set subscription-expires-datetime.

Errors, limits and good practice

  • Status codes: 200 success; 202 accepted (change queued); 400 bad request; 401 token missing or expired (refresh and retry once); 403 your scope does not allow it; 404 not found; 409 already exists.
  • Paging: start and limit on collection reads; CDRs return up to 1,000 per page.
  • Rate limits: not published. Pull CDRs in hourly or daily batches, or subscribe to the cdr model, rather than polling every few seconds.
  • Change control: prefer read-only access for monitoring tools. Trunk and number routing changes take effect immediately.
  • Security: store credentials in a secrets vault, restrict keys by IP, share them with as few people as possible, test before production and log API activity.

Common tasks

Pull last month's trunk minutes

1Get a token with POST /tokens.
2Call GET /domains/~/cdrs/count?datetime-start=2026-09-01 00:00:00&datetime-end=2026-09-30 23:59:59 for the total calls and minutes.
3For call-by-call detail, call GET /domains/~/cdrs with the same dates, paging with start and limit=1000.

Check how many call paths are in use

1Call GET /domains/~/calls/count.
2Compare with limits-max-active-calls-total on your connection (GET /domains/~/connections).
3If you regularly reach the limit, ask Empire Telecom about adding call paths.

Confirm where a number is delivered

1Call GET /domains/~/phonenumbers/{phonenumber}.
2Check dial-rule-application (for example to-connection) and dial-rule-translation-destination-user.

Troubleshoot a failed call

1Find the call with GET /domains/~/cdrs using caller or dialled and a narrow time window.
2Note call-disconnect-reason-text, call-audio-codec and the IP address fields.
3Send the call ID and time to Empire Telecom support for a full trace.

Send completed calls to your billing system

1Create a subscription: POST /subscriptions with "model": "cdr" and your HTTPS post-url.
2Verify the X-Correlation-ID header on each post.
3Store each record keyed on id so a repeated post is not counted twice.

Add a 911 address for a new building

1Validate it: POST /domains/~/addresses/validate.
2Create it: POST /domains/~/addresses.
3Ask Empire Telecom to link the building's outbound numbers to the new address.

More information

Need a hand? Call Empire Telecom support at (732) 363-9898, email support@empiretelecomnj.com, or open a ticket in the customer portal.