Skip to content

HTTP API ​

The HTTP API is the interface of a self-hosted server. A client that does not embed the library uses these routes. SMSBridge.send() does not call this API.

The server listens on port 8080 unless PORT is set.

Authentication ​

/v1/sms/* requires:

http
Authorization: Bearer <profile API key>

The API key is printed on the first start of the server. See Self-hosting.

A missing header, a header that is not a bearer token, or an unknown key returns status 401 and { "error": string, "code": "UNAUTHORIZED" }. The error string is "Missing or invalid Authorization header" when the header is absent or is not a bearer token, and "Invalid API key" when the token does not match a profile.

The other routes on this page do not read that header.

metadata is not accepted on these routes. Per-message vendor fields are available only to SMSBridge.send().

Routes ​

The process registers every path in this table. The dashboard UI is mounted at /portal and calls the same handlers with that prefix. /api/v1/providers is the exception: the UI calls /portal/api/providers.

MethodPathAlso at
GET/health
GET/metrics
POST/v1/sms/send
GET/v1/sms/:id/status
GET/api/v1/providers/portal/api/providers
PATCH/api/v1/providers/:id/portal/api/providers/:id
GET/api/portal/stats/portal/api/portal/stats
GET/api/portal/queue-status/portal/api/portal/queue-status
GET/api/portal/queue-jobs/portal/api/portal/queue-jobs
POST/api/portal/test-send/portal/api/portal/test-send
GET/api/portal/messages/portal/api/portal/messages
GET/api/portal/messages/:id/logs/portal/api/portal/messages/:id/logs
GET/api/portal/providers/portal/api/portal/providers
POST/api/portal/providers/portal/api/portal/providers
PATCH/api/portal/providers/:id/portal/api/portal/providers/:id
DELETE/api/portal/providers/:id/portal/api/portal/providers/:id
GET/api/portal/profiles/portal/api/portal/profiles
POST/api/portal/profiles/portal/api/portal/profiles
PATCH/api/portal/profiles/:id/portal/api/portal/profiles/:id
DELETE/api/portal/profiles/:id/portal/api/portal/profiles/:id
GET/api/portal/profile-providers/portal/api/portal/profile-providers
POST/api/portal/profile-providers/portal/api/portal/profile-providers
DELETE/api/portal/profile-providers/:id/portal/api/portal/profile-providers/:id
GET/api/portal/sender-ids/portal/api/portal/sender-ids
POST/api/portal/sender-ids/portal/api/portal/sender-ids
DELETE/api/portal/sender-ids/:id/portal/api/portal/sender-ids/:id
POST/sandbox/bulksmsbd/smsapi/portal/api/sandbox/bulksmsbd/smsapi
POST/sandbox/bulksmsbd/getBalanceApi/portal/api/sandbox/bulksmsbd/getBalanceApi
POST/sandbox/greenweb/g_api.php/portal/api/sandbox/greenweb/g_api.php
GET/sandbox/greenweb/g_api.php/portal/api/sandbox/greenweb/g_api.php
GET/sandbox/messages/portal/api/sandbox/messages
GET/sandbox/settings/portal/api/sandbox/settings
POST/sandbox/settings/:providerType/portal/api/sandbox/settings/:providerType
DELETE/sandbox/messages/portal/api/sandbox/messages
GET/portal/Dashboard UI. /portal redirects to /portal/.
GET/portal/*A file from the dashboard build, or index.html when the path has no file extension.

JSON error bodies from the SMS routes are { "error": string, "code": string }. A handler that throws an unexpected error returns status 500 and { "error": "Gateway Error", "code": "INTERNAL_ERROR" }.

GET /health ​

Status 200: { "status": "ok" }.

GET /metrics ​

Status 200. Body is Prometheus text. Content-Type is the Prometheus content type.

POST /v1/sms/send ​

Enqueue a message for delivery. Requires a profile API key.

Request body ​

Content-Type: application/json

FieldTypeRequiredDescription
recipientstringyesRecipient number. Length 10 to 20.
bodystringyesMessage text. Length 1 to 1600.
prioritystringnolow, normal, high, or critical. Default: normal.
routingHintstringnoProvider id, name, or type. The named provider has to be a candidate for the profile.
isMaskedbooleannoWhen true, only a provider with a masked sender ID can be selected. Default: false.
bash
curl -sS -X POST http://localhost:8080/v1/sms/send \
  -H "Authorization: Bearer $SMS_BRIDGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"recipient":"01700000000","body":"Your code is 123456"}'

Response ​

Status 202:

FieldTypeDescription
messageIdstringId of the stored message.
statusstringqueued.

Errors ​

StatuscodeCondition
400VALIDATION_ERRORrecipient, body, or priority is invalid.
401UNAUTHORIZEDThe profile API key is missing or unknown.

GET /v1/sms/:id/status ​

Return one stored message. :id is the messageId from POST /v1/sms/send. Requires a profile API key.

Response ​

Status 200:

FieldTypeDescription
idstringMessage id.
statusstringpending, queued, sent, failed, delivered, or dead.
recipientstringRecipient passed at creation.
providerIdstring or nullProvider that accepted the message, after one has been selected.
retryCountnumberDelivery attempts recorded on the message.
createdAtstringCreation time.
updatedAtstringLast update time.

Errors ​

StatuscodeCondition
404NOT_FOUNDNo message exists with :id.
401UNAUTHORIZEDThe profile API key is missing or unknown.

GET /api/v1/providers ​

List the providers loaded from the environment or from configs.yaml.

Status 200. Each element:

FieldTypeDescription
idstringProvider id, such as bulksmsbd.
displayNamestringLabel stored for the dashboard.
enabledbooleanWhen false, routing skips the provider.
prioritynumberLower numbers are tried first under priority ordering.
configuredbooleantrue when credentials for id are loaded.
senderIdsstring[]Sender IDs from the configuration.
balancenumberResult of checkBalance(), or 0 when the call fails.
createdAtstring
updatedAtstring

PATCH /api/v1/providers/:id ​

Change enablement or priority. :id is the provider id.

Request body ​

FieldTypeRequiredDescription
enabledbooleanno
prioritynumberno

At least one field is required. Status 400 and { "error": "No valid update fields provided" } when the body has neither. Status 400 and { "error": "Provider ID is required" } when :id is empty. An unknown id returns status 404.

Status 200 returns the updated row: id, displayName, enabled, priority, createdAt, updatedAt.

Portal ​

The paths below are also available under /portal/api/portal. Responses are the stored rows. Timestamps are ISO strings. Boolean columns are JSON booleans.

GET /api/portal/stats ​

Status 200:

FieldTypeDescription
totalnumberMessages stored.
sentnumberMessages with status sent.
failednumberMessages with status failed.
pendingnumberMessages with status pending.
activeProvidersnumberRows in providers with isActive true.
todayCountnumberMessages created since local midnight.
sandboxCountnumberMessages captured by the sandbox.

GET /api/portal/messages ​

Query limit. Default 50. Status 200: an array of message rows.

FieldType
id, profileId, recipient, bodystring
prioritylow, normal, high, or critical
routingHint, providerId, providerName, senderIdstring or null
isMaskedboolean
statuspending, queued, sent, failed, delivered, or dead
routingStrategy, pivotedFrom, responseBodystring or null
costnumber or null
retryCount, latencynumber
queuedAt, dequeuedAt, processedAt, createdAt, updatedAtstring or null

GET /api/portal/messages/:id/logs ​

Status 200: an array of { "id", "messageId", "event", "detail", "createdAt" }, newest first.

GET /api/portal/queue-status ​

Status 200:

FieldTypeDescription
counts.activenumber
counts.waitingnumberJobs waiting in Redis.
counts.failednumber
counts.completednumber
counts.delayednumber
activeJobsarrayUp to 50 jobs. See the job fields below.
waitingJobsarrayUp to 50 jobs.
failedJobsarrayUp to 50 jobs.

GET /api/portal/queue-jobs ​

QueryDefaultDescription
typesactiveComma-separated BullMQ states, such as wait,failed.
start0First index.
end49Last index.

Status 200: an array of jobs.

FieldType
idstring
namestring
dataobject
statusstring
failedReasonstring, when the job failed
stacktracestring[], when present
processedOn, finishedOnnumber, epoch milliseconds, when present
timestampnumber

POST /api/portal/test-send ​

Enqueue a message the same way POST /v1/sms/send does. This route does not check the profile API key. The caller supplies profileId.

FieldTypeRequired
recipientstringyes
bodystringyes
profileIdstringyes
prioritystringno. Default normal.

Status 200: { "messageId": string, "status": "queued" }.

Providers, profiles, and sender IDs ​

GET /api/portal/providers returns the rows in the providers table. This is separate from GET /api/v1/providers, which returns the providers loaded from configuration.

POST /api/portal/providers inserts a row. Status 201.

FieldTypeRequired
namestringyes
typestringyes. bulksmsbd or greenweb.
baseUrlstringyes
apiKeystringyes
apiSecretstringno
isActivebooleanno. Default true.
realBalancenumberno. Default 0.

PATCH /api/portal/providers/:id writes the JSON fields onto that row. DELETE /api/portal/providers/:id returns { "success": true }.

GET /api/portal/profiles returns profile rows: id, name, apiKey, routingStrategy, routingConfig, fixedProviderId, createdAt.

POST /api/portal/profiles inserts a profile. Status 201. apiKey is generated as sb_ plus 32 hex characters when the body omits it. routingStrategy defaults to priority_failover. routingConfig defaults to "{}".

FieldTypeRequired
namestringyes
apiKeystringno
routingStrategystringno. priority_failover, weighted_distribution, health_aware, rule_based, fixed, or priority.
routingConfigstringno. JSON text.
fixedProviderIdstringno

PATCH /api/portal/profiles/:id updates the row. DELETE /api/portal/profiles/:id returns { "success": true }.

GET /api/portal/sender-ids returns { "id", "providerId", "senderId", "isMasked", "isActive", "createdAt" }.

POST /api/portal/sender-ids inserts one. Status 201.

FieldTypeRequired
providerIdstringyes
senderIdstringyes
isMaskedbooleanno. Default false.
isActivebooleanno. Default true.

DELETE /api/portal/sender-ids/:id returns { "success": true }.

GET /api/portal/profile-providers returns links between a profile and a provider. Query profileId limits the list to one profile. Each row is { "id", "profileId", "providerId", "senderId", "createdAt" }.

POST /api/portal/profile-providers inserts a link. Status 201. Body: profileId, providerId, and optional senderId.

DELETE /api/portal/profile-providers/:id returns { "success": true }.

Sandbox ​

These routes imitate BulkSMSBd and GreenWeb, and they store the captured messages. Point a provider base_url at this server to exercise delivery without the vendor.

POST /sandbox/bulksmsbd/smsapi ​

Content-Type: application/x-www-form-urlencoded or multipart/form-data.

FieldDescription
senderidSender ID.
numberRecipient.
messageText.

When the sandbox settings for bulksmsbd exist and a random draw falls under failureRate, the response is text, the configured errorCode, or 1005. Otherwise status 200:

json
{ "response_code": 202, "message_id": 0, "success": "SMS Submitted Successfully" }

The successful call is appended to the captured messages.

POST /sandbox/bulksmsbd/getBalanceApi ​

Status 200: { "response_code": 202, "balance": 10000 }.

POST /sandbox/greenweb/g_api.php ​

JSON or form body. The message is smsdata[0]:

FieldDescription
toRecipient.
messageText.
fromSender ID.

A simulated failure returns { "status": "<errorCode or FAILED>" }. Success returns an array of one object: to, message, status (SENT), message_id.

GET /sandbox/greenweb/g_api.php ​

Query json. When json is present, the body is { "balance": "10000.00" }. Otherwise the body is the text 10000.00.

GET /sandbox/messages ​

Status 200: up to 100 captured messages, newest first. Each row is { "id", "providerType", "recipient", "body", "senderId", "rawRequest", "createdAt" }.

DELETE /sandbox/messages ​

Deletes every captured message. Status 200: { "success": true }.

GET /sandbox/settings ​

Status 200: an array of { "providerType", "failureRate", "errorCode", "latency", "updatedAt" }.

POST /sandbox/settings/:providerType ​

Inserts or replaces the settings for :providerType (bulksmsbd or greenweb).

FieldTypeDescription
failureRatenumber0 to 1. The fraction of calls that fail.
latencynumberMilliseconds to wait before responding.
errorCodestringReturned when a call is selected to fail.

Status 200: the stored settings row.

Dashboard UI ​

GET /portal redirects to GET /portal/. That response is index.html from dashboard/dist. GET /portal/<file> returns that file when it exists. A path with no file extension returns index.html, and the UI's hash router selects the screen. A missing asset returns status 404.