AI message drafts
Ready writes draft texts for you from a short description. You review them and send the one you like.
Endpoints
#Write message drafts
Writes up to 5 draft texts from a short description. Costs 5 × your per-segment rate (no carrier fee). Needs the send_sms permission.
Parameters
Idempotency-Keystring · header- Send one to retry without a second charge: a repeat with the same key returns the first answer. A
4xxisn’t stored, so a corrected retry with the same key goes through. descriptionstringRequired- What the message should say. Up to 2000 characters. The only field accepted.
Returns
datastring[]- Usually 5 drafts, each a whole text.
credits_remaininginteger | null- Next to
data, not inside it. Credits left on your balance after this charge, a whole number: one credit pays for one text segment at your rate. It is not dollars or cents.nullwhen Ready couldn’t read your balance after writing the drafts. The drafts are still good.
Errors
| HTTP | Code | When |
|---|---|---|
| 200 | generation_refused | Breaks texting rules. Charged. The body has "success": false and "refused": true. |
| 400 | description_required | description is missing or empty (Describe the message you want us to write.). |
| 400 | invalid_field | description is longer than 2000 characters, or isn’t text. |
| 400 | unknown_field | A field other than description. |
| 402 | insufficient_balance | Balance too low. error is plain text for a person, so match on error_code. When Ready read your balance first, the body also has required_cents (the price) and balance_cents (what you hold); if the charge lost a race to another one they are absent and error is Insufficient balance. Top up in Billing.. |
| 402 | client_card_required | Instead of insufficient_balance on a sub-account that pays with its own card and has not added one yet. Add one in Billing. |
| 402 | BILLING_PAST_DUE | Payment failed and no balance left, or the account was closed. FRAUD_HOLD during a security review. |
| 500 | generation_failed | Not charged: the price is taken only after the drafts are written. Retry. |
curl -X POST "https://api.tryready.com/sms/generate" \
-H "X-API-Key: $READY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "Remind patients about their cleaning next week and ask them to reply C to confirm"
}'
const res = await fetch('https://api.tryready.com/sms/generate', {
method: 'POST',
headers: {
'X-API-Key': process.env.READY_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"description": "Remind patients about their cleaning next week and ask them to reply C to confirm"
}),
signal: AbortSignal.timeout(35 * 1000),
});
const json = await res.json().catch(() => ({}));
if (!res.ok || json.success === false) {
throw new Error(`${res.status}${json.error_code || json.code ? ' ' + (json.error_code || json.code) : ''}: ${json.error || json.message || res.statusText} (request ${res.headers.get('x-request-id')})`);
}
import os, requests
r = requests.post(
"https://api.tryready.com/sms/generate",
headers={"X-API-Key": os.environ["READY_API_KEY"]},
json={
"description": "Remind patients about their cleaning next week and ask them to reply C to confirm"
},
timeout=35,
)
data = r.json() if r.headers.get("content-type", "").startswith("application/json") else {}
if not r.ok or data.get("success") is False:
raise RuntimeError(f'{r.status_code} {data.get("error_code") or data.get("code") or ""}: {data.get("error") or data.get("message") or r.reason} (request {r.headers.get("x-request-id")})')
{
"success": true,
"data": [
"Hi! Your cleaning is next week. Reply C to confirm or call us to reschedule.",
"…",
"…",
"…",
"…"
],
"credits_remaining": 1234
}