Endpoint
POST
/api/v1/messages
Requires authentication (X-API-Key)
Request Body
| Field | Type |
|---|---|
| from | string (E.164, must be a registered phone) |
| to | string (E.164, recipient number) |
| content | string (message text) |
| request_id | string (optional, for idempotency) |
Common Error Responses
403
FORBIDDEN
Sender phone is not registered to your account.
402
INSUFFICIENT_CREDITS
Insufficient credits. Your group balance is 0.
409
DUPLICATE_REQUEST
A message with this request_id already exists.
Code Samples
curl -X POST https://api.palmtext.com/api/v1/messages \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"from": "+15550001234", "to": "+15550005678", "content": "Hello from PalmText!"}'
import requests
resp = requests.post(
'https://api.palmtext.com/api/v1/messages',
headers={'X-API-Key': 'YOUR_API_KEY'},
json={
'from': '+15550001234',
'to': '+15550005678',
'content': 'Hello from PalmText!'
}
)
print(resp.json())
const res = await fetch('https://api.palmtext.com/api/v1/messages', {
method: 'POST',
headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({
from: '+15550001234',
to: '+15550005678',
content: 'Hello from PalmText!'
})
});
const data = await res.json();
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.palmtext.com/api/v1/messages',
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'from' => '+15550001234',
'to' => '+15550005678',
'content' => 'Hello from PalmText!'
]),
CURLOPT_RETURNTRANSFER => true,
]);
$resp = curl_exec($ch);
echo $resp;
curl_close($ch);
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]string{
"from": "+15550001234",
"to": "+15550005678",
"content": "Hello from PalmText!",
})
req, _ := http.NewRequest("POST",
"https://api.palmtext.com/api/v1/messages", bytes.NewBuffer(body))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
fmt.Println(resp.Status)
}