Empire Telecom · EmpireUC developers
Send and receive texts and pictures from your EmpireUC numbers in your own software.
Send and receive texts (SMS) and picture messages (MMS) from your EmpireUC business numbers in your own software: a patient reminder system, a CRM, a front-desk app. Texts you send this way show up in the same conversation in the EmpireUC apps and the Phones portal, so your team sees the whole thread.
Tip: Just want texts to reach a person or a chat app? You do not need code: set an alert on Text message received (see Alerts and webhooks), or use the Incoming text start in a call flow.
At a glance
| Item | Detail |
|---|
| API | The EmpireUC phone system API (REST, JSON over HTTPS). Sign-in, base address and keys are in the API specification |
| Base address | https://<your-EmpireUC-API-server>/ns-api/v2 (Empire Telecom gives you the server address) |
| Authentication | Authorization: Bearer <token or API key> |
| Who sends | A user (extension) that has a text-enabled number. Messages are filed under that user |
| Message types | sms (text, up to 1,600 characters, sent in parts by the carrier) and mms (JPG, PNG or GIF, up to 1.5 MB) |
| Group texts | Up to 10 recipients in one conversation |
| Incoming texts | Pushed to you by webhook (alert rule or event subscription), or read from the conversation list |
| Business texting rules | Numbers must be registered for A2P 10DLC (US carriers). Empire Telecom handles the registration with you |
Before you start
| 1 | Ask Empire Telecom to enable texting on the numbers you want to use and register them for business texting (10DLC). Unregistered numbers are blocked by US carriers. |
| 2 | Get API access for the user (extension) that will send the texts. See Getting access. |
| 3 | Find your domain and the user's extension. GET /domains/~ returns your domain; the extension is the user's number in the portal. |
1. See which numbers can text
Lists the text-enabled numbers this user can send from, and whether each can send pictures.
| curl -s "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/smsnumbers" \
-H "Authorization: Bearer $TOKEN" |
Each row has number and mms-capable (yes or no). Use the number exactly as returned (digits only, for example 17325550100).
2. Send a text
Messages live in conversations (message sessions). To start a new conversation, make up an ID yourself (any random string of letters and numbers, 32 characters works well) and send to it. To reply in an existing conversation, reuse its ID.
| curl -s -X POST \
"https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions/{conversation-id}/messages" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{
"type": "sms",
"message": "Hi Pat, this is Sunrise Senior Living confirming your tour tomorrow at 10 AM. Reply STOP to opt out.",
"destination": "12125550100",
"from-number": "17325550100"
}' |
| Field | Required | What it is |
|---|
type | Yes | sms or mms |
message | Yes for sms | The text. Up to 1,600 characters |
destination | Yes | The number to text, digits only with country code (12125550100). For a group text, a list of up to 10 numbers: ["12125550100","19175550101"] |
from-number | Yes | One of the user's text-enabled numbers from step 1 |
data | MMS only | The picture, base64 encoded |
mime-type | MMS only | image/jpeg, image/png or image/gif |
size | MMS only | The picture size in bytes (under 1,500,000) |
Send a picture (MMS)
| IMG=$(base64 -w0 flyer.jpg)
curl -s -X POST "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions/{conversation-id}/messages" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d "{\"type\":\"mms\",\"message\":\"Our new menu\",\"destination\":\"12125550100\",\"from-number\":\"17325550100\",\"data\":\"$IMG\",\"mime-type\":\"image/jpeg\",\"size\":$(stat -c%s flyer.jpg)}" |
3. Read conversations and messages
| # Every conversation for this user, newest first
curl -s "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions?limit=200" -H "Authorization: Bearer $TOKEN"
# The messages in one conversation
curl -s "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions/{conversation-id}/messages?limit=300" -H "Authorization: Bearer $TOKEN"
# Every conversation in the account (admin access)
curl -s "https://<server>/ns-api/v2/domains/{domain}/messagesessions" -H "Authorization: Bearer $TOKEN" |
| Conversation field | Meaning |
|---|
messagesession-id | The conversation ID (use it to reply) |
messagesession-remote | The other person or people |
messagesession-sms-number | Your number in the conversation |
messagesession-last-message | The latest text |
messagesession-last-datetime | When it was sent |
| Message field | Meaning |
|---|
id | The message ID |
timestamp | When it was sent or received |
direction | In or out |
from-number | Who sent it |
terminating-number | Who received it |
text | The text (a picture arrives as a link here) |
media-type | Set when it is a picture |
status | Delivery status |
4. Get incoming texts the moment they arrive
Do not poll. Choose one:
- No code: in Phones > Alerts, make a rule with the event Text message received and add your web address under Send to > Webhook. Each text arrives as a signed JSON post (event
message.received). Details in Alerts and webhooks. - API: create an event subscription for the
message model with POST /subscriptions (see the Webhooks and events section of the API specification).
Rules that keep your texts delivered
- Opt-in and opt-out: only text people who agreed to it, and honour STOP. The call flow Check consent step can do this for you.
- Identify yourself in the first message (your business name).
- No shortened links from public shorteners: carriers often block them.
- Pace bulk sends: about one text per second per number. For campaigns, ask us about the right setup first.
Errors
| What you see | What to do |
|---|
| 401 | The token expired: refresh it, or check the API key |
| 403 | This user cannot text from that number, or the number is not text-enabled |
| 400 | Check the number format (digits with country code), message length and picture type and size |
| Sent but never delivered | Usually a 10DLC registration issue. Contact Empire Telecom with the number and time |
More