Relay.Haus Docs

Send an SMS

Send SMS messages through a paired Relay.Haus Android device.

Use POST /gateway/send-sms to send one message to one or more recipients. Phone numbers should include the country calling code, such as +14155550101.

curl -X POST "https://api.relay.haus/api/v1/gateway/send-sms" \
  -H "x-api-key: $RELAYHAUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipients": ["+14155550101"],
    "message": "Hello from Relay.Haus"
  }'

The API chooses your account's default enabled device when deviceId is omitted. You can target a particular paired device by including its ID in the JSON body:

{
  "deviceId": "YOUR_DEVICE_ID",
  "recipients": ["+14155550101"],
  "message": "Hello from Relay.Haus"
}

Node.js

Run this code on your server, where RELAYHAUS_API_KEY is available as a secret environment variable:

const response = await fetch(
  'https://api.relay.haus/api/v1/gateway/send-sms',
  {
    method: 'POST',
    headers: {
      'x-api-key': process.env.RELAYHAUS_API_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      recipients: ['+14155550101'],
      message: 'Hello from Relay.Haus',
    }),
  }
)

if (!response.ok) {
  throw new Error(`Relay.Haus API returned ${response.status}`)
}

console.log(await response.json())

Send different messages in one request

Use POST /gateway/send-bulk-sms when each recipient or group needs a different message:

curl -X POST "https://api.relay.haus/api/v1/gateway/send-bulk-sms" \
  -H "x-api-key: $RELAYHAUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "recipients": ["+14155550101"], "message": "Hi Alice" },
      { "recipients": ["+16475550187"], "message": "Hi Bob" }
    ]
  }'

The send response contains an smsBatchId that you can use to find delivery results in message history. Sending requires an enabled, online device with SMS permission; an unavailable device or account quota can cause the API to return an error.