Relay
Relay mode sends every incoming text to your HTTPS endpoint as a signed POST, and texts back whatever you return in {"reply": "..."}. It's the strict contract: your endpoint checks our signature, always answers JSON with a reply field, and gets one retry on a timeout or 5xx.
Just want to paste a URL and answer with plain text? Use webhook mode: same payload, no secret to set up, any reply format. The wizard picks relay automatically when your endpoint answers with {"reply": …}.
You own the thinking. We own the number, consent, STOP/HELP, the sender-to-thread mapping, formatting, rate limits, logs and billing.
Create a relay line
curl -s -X POST "https://silverarrows.dev/v1/lines" \
-H "Authorization: Bearer $SA_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My Agent",
"keyword": "MYAGENT",
"mode": "relay",
"webhook_url": "https://example.com/api/sms"
}'
| Field | Required | Notes |
|---|---|---|
name |
yes | Up to 60 characters. |
keyword |
yes | 2 to 20 letters or digits, unique. |
mode |
yes | "relay" |
webhook_url |
yes | Full https:// URL. |
webhook_secret |
no | 16 to 200 characters. If omitted we generate one (whsec_...) and return it once in the response. |
async |
no | true if your endpoint always answers via the reply endpoint (n8n, Make, Zapier, Tasklet). |
share_phone |
no | true to include the texter's raw phone number. Default false. |
Rotate the secret later with PATCH /v1/lines/:id and {"rotate_webhook_secret": true}.
The request we send
POST /api/sms HTTP/1.1
Host: example.com
Content-Type: application/json
User-Agent: SilverArrows/1.0 (+https://silverarrows.dev)
X-Arrow-Signature: sha256=5d1c0e...9f2a
X-Arrow-Delivery: msg_Zk3pW8qNc1Vb6Lr0Ta9y
X-Arrow-Attempt: 1
X-Arrow-Delivery is the inbound message.id; it is the same on the retry. X-Arrow-Attempt is 1, or 2 on the retry.
{
"line_id": "line_8Hq2kVd0sPZx1mLw4TfR",
"conversation_id": "conv_Q2m9VtX0aLr7Bc1nYp4e",
"sender_id": "snd_3f9a1c0b7e2d4a6b8c1d2e3f",
"message": {
"id": "msg_Zk3pW8qNc1Vb6Lr0Ta9y",
"body": "what's my card today?",
"media_urls": [],
"received_at": "2026-10-05T18:02:10.000Z"
},
"history": [
{ "direction": "in", "body": "draw a card for me", "at": "2026-10-04T08:00:01.000Z" },
{ "direction": "out", "body": "The Star: hope after a hard stretch...", "at": "2026-10-04T08:00:03.000Z" }
]
}
| Field | Meaning |
|---|---|
line_id |
Your line. Use it to call /v1/lines/:id/reply or /send. |
conversation_id |
One per (number, texter). Stable for the life of the thread, including after a move to a number of its own. |
sender_id |
Stable hashed id for the texter (snd_...). Use it as your user id. |
phone |
Only present when the owner turned on "share phone number with my agent" (share_phone: true). E.164, like +14155551234. |
account_id |
Only present once this phone texted a code from your app: your own id for the account. See Phone login. |
message.id |
Pass this as in_reply_to if you answer later. Also a good idempotency key. |
message.body |
The text, as typed. |
message.media_urls |
Photos and other MMS attachments, as URLs. Empty array for plain texts. |
message.received_at |
ISO 8601 timestamp. |
message.tapback |
Optional reaction inferred from an English SMS fallback for one of the six classic Apple Tapbacks. |
history |
Up to the last 20 messages before this one, oldest first. in is the texter, out is what was sent back. |
For example, Liked “See you at 9” includes "tapback": { "action": "add", "emoji": "👍", "quoted_text": "See you at 9" } alongside the original message.body. A removal uses "action": "remove". SMS supplies quoted text without a provider message ID, so treat this field as a hint. The endpoint can return {"reply":null} to acknowledge the webhook silently.
Things that never reach your endpoint: STOP, HELP, START, PAUSE, YES (when it confirms scheduled texts), texts from opted-out numbers, and texts over the rate limit. We handle those.
The keyword itself doesn't reach you either. On the shared number, texting your keyword is the opt-in: we send the opt-in confirmation, plus your line's optional welcome text (welcome_text, up to 320 characters, checked by the same content rules and not counted as a reply). Your endpoint gets the texter's next message. On a dedicated number there is no keyword: the first text gets the opt-in confirmation and then goes to your endpoint like any other.
Nothing reaches your endpoint until the line passes its connection test (POST /v1/lines/:id/test, or the live test in the wizard). Until then, texts for the line get the generic "No assistant matches that keyword" reply on the shared number and silence on a dedicated number. Changing webhook_url means testing again.
sender_id vs phone
By default you get sender_id, a salted hash of the phone number. It is the same every time the same person texts the same line, so it works as a user id, but you can't recover the number from it. If your agent genuinely needs the number (to look up an existing customer, say), the owner can enable share_phone on the line and we add phone to the payload. Treat it as personal data.
MMS
Inbound photos arrive in message.media_urls. Fetch them like any other URL. A photo with no caption has an empty body. We don't send outbound MMS; replies are text only.
Timeouts and retries
- We wait 10 seconds for your response.
- On a timeout, a network error, or a 5xx, we retry once with the same
X-Arrow-Delivery(themessage.id) andX-Arrow-Attempt: 2. Dedupe onmessage.id: if your first attempt did its side effects (filed a ticket, charged a card) and only answered slowly, don't do them again. - We connect to the IP address we checked when we validated your URL (it must resolve only to public addresses), so a DNS change mid-request can't redirect us to a private network. We don't follow redirects. TLS still verifies your hostname's certificate.
- If both attempts fail (or you return a non-2xx, or a body without a
replyfield), we text the line's fallback message and log the failure:
Sorry, I'm having trouble right now. Try again in a minute.
Owners can change the fallback text with PATCH /v1/lines/:id and {"fallback_text": "..."}. Every request is logged with status code and duration on the line's dashboard.
If your agent regularly needs more than a few seconds, don't fight the timeout: answer __async__ and reply later.
Responses you can return
Always status 200 with Content-Type: application/json.
| Response | What happens |
|---|---|
{"reply": "Your card is The Star."} |
We text it back. |
{"reply": null} |
We send nothing. |
{"reply": "__async__"} |
We send nothing now. You answer within 5 minutes with POST /v1/lines/:id/reply. See Async and scheduled. |
{"reply": "Sure, one card every morning.", "request_schedule_consent": true} |
We text your reply, then text the texter the scheduled-messages opt-in prompt. See Async and scheduled. |
Reply format
- Plain text, 320 characters or fewer. Aim for about 280 to leave room for footers ("Reply STOP to opt out." on the first reply of the day, "Sent via Silver Arrows" on free lines). The footer counts toward the 320.
- Markdown is stripped (
**bold**becomesbold, headings and bullet symbols are removed). Write plain text and you'll get exactly what you wrote. - Longer replies are cut at a word boundary and end with
.... If the owner raisesmax_reply_chars(up to 1,600), longer replies are split into several texts of at most 320 characters each instead.
Verify the signature
X-Arrow-Signature is sha256= followed by the lowercase hex HMAC-SHA256 of the raw request body, keyed with your webhook secret. Always compute it over the exact bytes you received, before any JSON parsing, and compare in constant time. Reject anything that doesn't match with a 401.
Webhook POSTs and texter-message requests are signed the same way.
Node
import crypto from "node:crypto";
export function verifySilverArrows(rawBody, header, secret) {
if (!header || !secret) return false;
const expected = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(String(header).trim());
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
Python
import hashlib
import hmac
def verify_silver_arrows(raw_body: bytes, header: str | None, secret: str) -> bool:
if not header or not secret:
return False
expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, header.strip())
Flask example:
import os
from flask import Flask, request, jsonify
app = Flask(__name__)
SECRET = os.environ["ARROW_WEBHOOK_SECRET"]
@app.post("/api/sms")
def sms():
raw = request.get_data() # raw bytes, before parsing
if not verify_silver_arrows(raw, request.headers.get("X-Arrow-Signature"), SECRET):
return "bad signature", 401
payload = request.get_json()
text = payload["message"]["body"]
return jsonify(reply=f"You said: {text}"[:300])
Next.js route handler
app/api/sms/route.ts:
import crypto from "node:crypto";
export const runtime = "nodejs";
const SECRET = process.env.ARROW_WEBHOOK_SECRET!;
function verify(raw: string, header: string | null): boolean {
if (!header) return false;
const expected = "sha256=" + crypto.createHmac("sha256", SECRET).update(raw, "utf8").digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(header.trim());
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
type Payload = {
line_id: string;
conversation_id: string;
sender_id: string;
phone?: string;
message: { id: string; body: string; media_urls: string[]; received_at: string };
history: { direction: "in" | "out"; body: string; at: string }[];
};
export async function POST(req: Request) {
const raw = await req.text(); // read the raw body first
if (!verify(raw, req.headers.get("x-arrow-signature"))) {
return new Response("bad signature", { status: 401 });
}
const payload = JSON.parse(raw) as Payload;
try {
const reply = await myAgent(payload.message.body, payload.history, payload.sender_id);
return Response.json({ reply: reply.slice(0, 300) });
} catch {
return Response.json({ reply: null });
}
}
async function myAgent(text: string, history: Payload["history"], userId: string): Promise<string> {
return `You said: ${text}`; // call your real agent here
}
Express
Use express.raw on this route so you get the bytes we signed. express.json() would re-serialise the body and the signature would no longer match.
import express from "express";
import crypto from "node:crypto";
const app = express();
const SECRET = process.env.ARROW_WEBHOOK_SECRET;
function verify(raw, header) {
if (!header) return false;
const expected = "sha256=" + crypto.createHmac("sha256", SECRET).update(raw).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(String(header).trim());
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
app.post("/api/sms", express.raw({ type: "application/json" }), async (req, res) => {
if (!verify(req.body, req.get("X-Arrow-Signature"))) {
return res.status(401).send("bad signature");
}
const { message, history, sender_id } = JSON.parse(req.body.toString("utf8"));
const reply = `You said: ${message.body}`; // call your real agent here
res.json({ reply: reply.slice(0, 300) });
});
app.listen(process.env.PORT || 3001);
Test it
curl -s -X POST "https://silverarrows.dev/v1/lines/$LINE_ID/test" \
-H "Authorization: Bearer $SA_KEY" \
-H "Content-Type: application/json" \
-d '{"body": "hello"}'
The test runs a signed synthetic inbound through your endpoint and returns the reply (or a plain-English error) with latency. It doesn't send an SMS or count as a reply.
Related
- Quickstart
- Async and scheduled
- Lovable, Bolt, Replit and v0: get a builder to write this endpoint for you
- API reference