PortSMS

Developers

Bulk SMS API reference

The PortSMS SMS API is a REST API with JSON over HTTPS and Bearer keys: send bulk SMS, estimate the cost, check delivery status and receive signed delivery webhooks.

V1https://portsms.com/api/v1

Getting started

Sending through the API takes three steps.

  1. 1Create an account. The sign-in token you save is your account.
  2. 2Top up from $40 with crypto in the PortSMS checkout, on the top-up page.
  3. 3Create an API key on the API keys page. It is shown once, so copy it to your server right away.

The API is available after the first top-up

Once your first top-up is credited you can create an API key, and the key can send right away.

Base address and keys

All calls go to the address below. Send your key in the Authorization header. Anyone with the key can spend your balance, so keep it on your server only.

https://portsms.com/api/v1
Request headers
Authorization: Bearer psm_your_api_key
Content-Type: application/json

Limits: 300 calls a minute per account, 1,000 recipients per request, 50,000 messages per account in 24 hours.

Send a message

Sends one text to one or more numbers. Numbers must be in international format (+ and the country code). The whole cost is taken from your balance when the request is accepted; numbers that cannot be sent are listed in rejected with the reason and are not charged.

POST/api/v1/messages

FieldNotes
tostring or arrayRecipient numbers, up to 1,000. Each item can also be an object { "to": "+1415...", "vars": ["Alice"] } whose vars fill {{1}}, {{2}} in the text
textstringMessage text, up to 10 parts per recipient
namestring, optionalA name for the send, shown in your history (80 characters)
schedule_atstring, optionalISO 8601 time to start, from 5 minutes to 29 days ahead. Charged now; cancel before it starts for a full refund
opt_outboolean, optionaltrue adds "Reply STOP to opt out" on a new line at the end
refstring, optionalYour own reference, returned in webhooks (64 characters)
Request (cURL)
curl https://portsms.com/api/v1/messages \
  -H "Authorization: Bearer $PORTSMS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to": ["+14155550123", "+447700900123"],
       "text": "Your code is 482913",
       "name": "Login codes",
       "ref": "order-1042"}'
Request body: scheduled, with values
{"to": [{"to": "+14155550123", "vars": ["Alice", "A-1042"]},
        {"to": "+447700900123", "vars": ["Ben", "A-1043"]}],
 "text": "Hi {{1}}, your order {{2}} has shipped.",
 "schedule_at": "2026-10-14T09:00:00Z",
 "opt_out": true}
Response 201 Created
{
  "campaign": {
    "id": "c_7kq2m9xd4tpa", "name": "Login codes", "source": "api",
    "text": "Your code is 482913", "encoding": "gsm7", "parts": 1,
    "recipients": 2, "cost": "0.0156", "refunded": "0.0000",
    "status": "sending", "ref": "order-1042", "scheduled_at": null,
    "created_at": "2026-10-13T09:30:00.000Z", "done_at": null
  },
  "messages": [
    { "id": "m_3hx8q2vkd7mrtc", "campaign_id": "c_7kq2m9xd4tpa", "to": "+14155550123",
      "country": "US", "status": "queued", "error": null, "parts": 1, "price": "0.0061",
      "created_at": "2026-10-13T09:30:00.000Z", "sent_at": null, "done_at": null }
  ],
  "rejected": []
}
Node.js 18+
const res = await fetch("https://portsms.com/api/v1/messages", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.PORTSMS_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({ to: ["+14155550123"], text: "Your code is 482913" }),
});
const data = await res.json();
Python 3 (requests)
import os, requests
r = requests.post("https://portsms.com/api/v1/messages",
    headers={"Authorization": "Bearer " + os.environ["PORTSMS_KEY"]},
    json={"to": ["+14155550123"], "text": "Your code is 482913"})
print(r.status_code, r.json())

Estimate before sending

Same body as sending. Returns encoding, parts, cost and the numbers that would be refused, and sends nothing.

POST/api/v1/estimate

Response 200 OK
{ "encoding": "gsm7", "characters": 19, "parts": 1, "recipients": 2,
  "cost": "0.0156", "balance": "120.00",
  "rejected": [ { "to": "4155550123", "reason": "format" } ] }

Check one message

Status of one recipient, by the id returned when sending.

GET/api/v1/messages/{id}

Response 200 OK
{ "message": { "id": "m_3hx8q2vkd7mrtc", "to": "+14155550123", "status": "delivered",
  "error": null, "price": "0.0061", "done_at": "2026-10-13T09:30:06.000Z", ... } }

Campaigns (one per send)

Every send request is a campaign with the status scheduled, sending, done or canceled. List your last 100, open one to see counts per status and every recipient (500 per page, ?page=2 for more), or cancel a scheduled one with POST /api/v1/campaigns/{id}/cancel for a full refund.

GET/api/v1/campaigns

GET/api/v1/campaigns/{id}?page=1

POST/api/v1/campaigns/{id}/cancel

Response 200 OK
{ "campaign": { "id": "c_7kq2m9xd4tpa", "status": "done", "recipients": 2,
    "counts": { "queued": 0, "sent": 0, "delivered": 1, "failed": 1 }, ... },
  "messages": [ ... ], "page": 1, "page_size": 500 }

Balance and prices

Your balance in US dollars, and the price per part for every country on sale.

GET/api/v1/balance

GET/api/v1/prices

Response 200 OK
{ "balance": "120.00", "currency": "USD" }

{ "prices": [ { "country": "US", "name": "United States", "dial_code": "+1", "price_per_part": "0.0061" }, ... ] }

Message statuses

StatusMeaning
queuedAccepted and charged, waiting to be handed to the carrier route
sentHanded to the carrier route, waiting for a delivery report
deliveredThe carrier reported delivery to the phone
failedRejected or not deliverable. The price was refunded to your balance

Delivery webhooks

Set an https address on the API key page. When a message becomes delivered or failed we POST it as JSON. Until your server answers with a 2xx status, we send up to 8 attempts including the first, over about 2 hours (at intervals of 0 s, 30 s, 1 min, 2 min, 5 min, 15 min, 30 min and 1 h).

Webhook request to your server
POST https://your-server.example/portsms
X-PortSMS-Signature: t=1791883806,v1=5f2c...e91a
Content-Type: application/json

{ "event": "sms.status",
  "data": { "id": "m_3hx8q2vkd7mrtc", "campaign_id": "c_7kq2m9xd4tpa", "to": "+14155550123",
            "country": "US", "status": "delivered", "error": null, "parts": 1, "price": "0.0061",
            "ref": "order-1042", "done_at": "2026-10-13T09:30:06.000Z", ... } }

Verify the X-PortSMS-Signature header: t is a Unix time and v1 is the HMAC-SHA256 of "t.body" with your signing secret. Reject requests older than five minutes.

Verify the signature (Node.js)
import crypto from "node:crypto";
function verify(raw, header, secret) {
  const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header || "");
  if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > 300) return false;
  const want = crypto.createHmac("sha256", secret).update(m[1] + "." + raw).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(want), Buffer.from(m[2]));
}

Handle each event once

A webhook can arrive more than once when a retry overlaps a slow answer. Use the message id and the status together as a key and ignore an event you have already stored.

Errors

Errors come back as JSON with an error code and an HTTP status.

Response 402 Payment Required
// 1,000 numbers in Germany, 1 part each
{ "error": "insufficient_balance", "cost": "17.5000" }
CodeWhat to do
bad_keyHTTP 401The key is missing or wrong
no_depositHTTP 403The API is available once your first top-up is credited
insufficient_balanceHTTP 402Top up the cost of this send to send it (the cost is included)
no_recipientsHTTP 4000 numbers can be sent (rejected lists the reasons)
too_many_recipientsHTTP 413Up to 1,000 numbers per request
empty_textHTTP 400Write the message text
text_too_longHTTP 400A text can have up to 10 parts
bad_scheduleHTTP 400schedule_at must be a time from 5 minutes to 29 days ahead
daily_limitHTTP 429The account's 24-hour sending limit is used up
rate_limitedHTTP 429Up to 300 calls per minute
not_foundHTTP 404No message, send or page matches the id or address
not_scheduledHTTP 409Only a scheduled campaign that has not started can be canceled

Why a number is rejected

ReasonWhat to do
formatWrite it again in international format (wrong format or length)
countryA calling code that is not on the price list
priceA country without a price right now
duplicateThe same number appears twice in one request
too_longWith its vars filled in, the text is over 10 parts

Limits

Calls
300 a minute per account
Numbers per request
1,000
Messages per account
50,000 in 24 hours
Parts per message
10 (1,530 GSM-7 or 670 Unicode characters)
Scheduling
5 minutes to 29 days ahead
Webhook retries
Up to 8 attempts including the first, over about 2 hours, until your server answers 2xx

Create a key right after your first top-up.

Top up from $40, create a key on the API keys page and send your first request.