Back to Developer Help
9

Twilio-compatible API

Move an existing Twilio-compatible SMS integration to PalmText by changing only the base URL and the credentials.

Find your Account SID and the base URL in Settings → API Keys. This is a thin compatibility layer: the native API above offers more, including bulk sends, contact groups and idempotency keys.

Endpoint

POST /twilio-api/2010-04-01/Accounts/{AccountSid}/Messages.json HTTP Basic auth: Account SID as the username, a PalmText API key as the password

Request Body

Field Type
To string (E.164, recipient number)
From string (E.164, one of your registered phones)
Body string (1–1600 characters)
StatusCallback string (optional, public http(s) URL for status updates)

What it is

A thin Twilio-compatible layer over PalmText: send one SMS, fetch a message, list messages, and receive status callbacks, using the paths, parameters and response shapes your integration already uses. Messages go out from your own phones and cost one message each, as with the native API.

Base URL and credentials

  • Base URL: https://palmtext.com/twilio-api, followed by the same paths, starting at /2010-04-01/.
  • Every uri, next_page_uri and previous_page_uri in a response is relative to that base URL.
  • Username: your Account SID (AC…), shown in Settings → API Keys.
  • Password: a PalmText API key. A key created in Settings can send as any of your phones; a device's own key only as that device.
  • The Account SID in the URL must be the same as the username.

Supported endpoints and parameters

  • POST /2010-04-01/Accounts/{AccountSid}/Messages.json — To, From, Body, StatusCallback
  • GET /2010-04-01/Accounts/{AccountSid}/Messages/{MessageSid}.json
  • GET /2010-04-01/Accounts/{AccountSid}/Messages.json — To, From, DateSent, DateSent<, DateSent>, PageSize, Page, PageToken

Refused parameters

Any other parameter is refused with error 20422, naming it, so a typo or an unsupported feature never goes unnoticed.

AddressRetentionretention settings are not supported
ApplicationSidTwiML applications are not supported; use StatusCallback for status updates
Attemptattempt counts are not supported
ContentRetentionretention settings are not supported
ContentSidcontent templates are not supported; send the text in Body
ContentVariablescontent templates are not supported; send the text in Body
FallbackFromfallback senders are not supported
ForceDeliveryForceDelivery is not supported
MaxPriceMaxPrice is not supported; PalmText charges one message per SMS
MediaUrlMMS is not supported; PalmText sends SMS only
MessageIntentmessage intents are not supported
MessagingServiceSidMessaging Services are not supported; send with From set to one of your phones
PersistentActionpersistent actions are not supported
ProvideFeedbackmessage feedback is not supported
RiskCheckrisk checks are not supported
ScheduleTypescheduled sending is not supported
SendAsMmsMMS is not supported; PalmText sends SMS only
SendAtscheduled sending is not supported
ShortenUrlslink shortening is not supported
SmartEncodedsmart encoding is not supported; Body is sent as written
TrafficTypetraffic types are not supported
ValidityPeriodvalidity periods are not supported

Statuses

PalmTextReported as
pendingqueued
sendingsending
sentsent
delivereddelivered
failedfailed (30008)
expiredfailed (30001)
receivedreceived

undelivered is never reported: phones report a failure only before sending.

Status callbacks

Pass StatusCallback when you create a message. Its URL receives a form-encoded POST when the message is sent, delivered or failed, in that order, with MessageSid, SmsSid, AccountSid, From, To, MessageStatus, SmsStatus, ApiVersion and, on failure, ErrorCode. No callback is sent for queued or sending.

Each request carries an X-Twilio-Signature header. Validate it with your usual request validator, using the API key that created the message as the auth token. If you rotate that key, later callbacks are signed with the new key; if you revoke it, they stop.

Callbacks are retried three times in all, and must go to a public address: private, loopback and cloud metadata addresses are refused.

Error codes

Errors use the shape {code, message, more_info, status}. Codes from 90001 are PalmText's own, for cases with no equivalent code.

CodeHTTPMeaning
20003401Authentication failed, or the Account SID does not match the key's account.
20005403The account is suspended.
20404404No such message on this account, or the resource is not provided.
20422400An unsupported or unknown parameter, a JSON body, or a malformed filter.
20429429Too many requests. The limit is shared with the native API.
20500500Something went wrong on our side. Try again shortly.
21211400To is not an E.164 phone number.
21212400From is not an E.164 phone number.
21602400Body is missing or empty.
21603400From is missing.
21604400To is missing.
21606400From is not a phone this key may send as.
21609400StatusCallback is not a public http(s) URL.
21617400Body is longer than 1600 characters.
30001—On a message: it expired before the phone sent it.
30008—On a message: the phone reported a failure, or did not confirm sending in time.
90001402PalmText only: no messages left in this phone's group.
90002403PalmText only: the phone or device is not active.

Known differences

  • No idempotency key: retrying a create sends twice. The native API's request_id prevents duplicates.
  • SMS only: no MMS or media.
  • No scheduled sending, validity periods, Messaging Services or content templates.
  • Incoming SMS appear in the message list; there is no inbound webhook that replies with markup. Use the native message.received webhook.
  • Messages cannot be deleted or redacted through this layer.
  • price is always null: PalmText charges one message per SMS from your balance.

Helper libraries

Plain HTTP, as in the samples below, works from any language. The official Python helper library is verified: create the client with your Account SID and API key, then set its base URL:

client = Client(ACCOUNT_SID, PALMTEXT_API_KEY)
client.api.base_url = "https://palmtext.com/twilio-api"

Other helper libraries are not verified yet; use them only if they let you set the whole base URL, including the /twilio-api path.

Code Samples

# The same request your Twilio-compatible integration already makes:
# only the host and the credentials change.
curl -X POST https://palmtext.com/twilio-api/2010-04-01/Accounts/$ACCOUNT_SID/Messages.json \
  -u "$ACCOUNT_SID:$PALMTEXT_API_KEY" \
  --data-urlencode 'From=+15550001234' \
  --data-urlencode 'To=+15550009999' \
  --data-urlencode 'Body=Hello from PalmText' \
  --data-urlencode 'StatusCallback=https://yourapp.com/sms/status'

# Page through messages: follow next_page_uri until it is null
curl -u "$ACCOUNT_SID:$PALMTEXT_API_KEY" \
  'https://palmtext.com/twilio-api/2010-04-01/Accounts/'$ACCOUNT_SID'/Messages.json?PageSize=50'
import requests

ACCOUNT_SID = 'AC...'          # Settings → API Keys
API_KEY = 'sk_live_...'        # a PalmText API key
BASE = f'https://palmtext.com/twilio-api/2010-04-01/Accounts/{ACCOUNT_SID}'

resp = requests.post(
    f'{BASE}/Messages.json',
    auth=(ACCOUNT_SID, API_KEY),
    data={'From': '+15550001234', 'To': '+15550009999', 'Body': 'Hello from PalmText',
          'StatusCallback': 'https://yourapp.com/sms/status'},
)
message = resp.json()
print(message['sid'], message['status'])  # SM... queued

# Validate a status callback in your handler (pip install twilio)
from twilio.request_validator import RequestValidator

def is_genuine(request_url, form_params, signature_header):
    return RequestValidator(API_KEY).validate(request_url, form_params, signature_header)
const ACCOUNT_SID = 'AC...';
const API_KEY = 'sk_live_...';
const base = `https://palmtext.com/twilio-api/2010-04-01/Accounts/${ACCOUNT_SID}`;

const res = await fetch(`${base}/Messages.json`, {
  method: 'POST',
  headers: {
    Authorization: 'Basic ' + btoa(`${ACCOUNT_SID}:${API_KEY}`),
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  body: new URLSearchParams({ From: '+15550001234', To: '+15550009999', Body: 'Hello from PalmText' }),
});
const message = await res.json(); // { sid: 'SM...', status: 'queued', ... }
<?php
$accountSid = 'AC...';
$apiKey = 'sk_live_...';
$ch = curl_init();
curl_setopt_array($ch, [
  CURLOPT_URL => "https://palmtext.com/twilio-api/2010-04-01/Accounts/$accountSid/Messages.json",
  CURLOPT_USERPWD => "$accountSid:$apiKey",
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => http_build_query([
    'From' => '+15550001234', 'To' => '+15550009999', 'Body' => 'Hello from PalmText',
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
$message = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $message['sid'];