Relay SMS Platform
Autonomous Agents

Quick Start Guide

Quick Start Guide

Get your autonomous agent sending SMS messages in under 30 seconds. This guide walks through account creation, payment setup, and sending your first message.

Prerequisites

  • A working agent framework (MCP, LangChain, AutoGPT, etc.)
  • Ability to make HTTP POST requests
  • A Stripe account for payment processing
  • Email address for the human operator

Step 1: Create Account

Create an autonomous agent account with a single API call:

TerminalCode
curl -X POST https://api.relay.works/v1/accounts/autonomous \ -H "Content-Type: application/json" \ -d '{ "agent": { "name": "my-assistant-bot", "framework": "anthropic-mcp", "operator": "human@example.com", "version": "1.0.0" }, "use_case": { "category": "authentication", "description": "Send 2FA codes to users during login", "estimated_volume": "100-500/day" }, "payment": { "method": "stripe_link", "funding_source": "human_operator" } }'

Request Fields

  • agent.name: Unique identifier for your agent
  • agent.framework: Platform you're using (anthropic-mcp, langchain, autogpt, openhands, other)
  • agent.operator: Email for human escalations
  • use_case.category: Message type (authentication, transactional, notifications, alerts, marketing)
  • use_case.description: Brief explanation of your use case
  • payment.method: Always stripe_link for agents

Step 2: Save API Key

The response contains your API key ONE TIME ONLY. Store it securely:

JSONCode
{ "account_id": "550e8400-e29b-41d4-a716-446655440000", "workspace_id": "550e8400-e29b-41d4-a716-446655440000", "api_key": "rly_live_agt_abc123xyz...", "status": "active", "limits": { "daily_messages": 100, "monthly_spend": 50, "rate_per_minute": 10 }, "payment": { "stripe_link": "https://app.relay.works/api/payment/setup?workspace=...", "instructions": "Complete payment to activate account and start sending SMS" }, "compliance": { "status": "approved", "next_steps": [ "Complete payment to activate account", "Send first message to validate use case", "Limits increase automatically after 100 successful sends" ] }, "webhooks": { "status_url": "https://api.relay.works/v1/accounts/550e8400.../status", "auto_subscribe": true }, "is_initial_response": true }

Important: The API key is only shown once. If you lose it, you must create a new account.

Step 3: Complete Payment

The human operator must complete payment to activate the account:

  1. Extract the Stripe Payment Link from the response
  2. Send it to the human operator (via email or notification)
  3. Operator completes payment in browser
  4. Account automatically activates with full Starter tier subscription (base + overage)
TerminalCode
# Extract payment link from response PAYMENT_URL=$(echo $RESPONSE | jq -r '.payment.stripe_link') echo "Complete payment at: $PAYMENT_URL"

Payment Required Before Sending: You cannot send SMS messages until payment is completed. All send requests will return 402 Payment Required until the subscription is active.

Step 4: Send First Message

After payment is completed, use the Relay SDK to send your first SMS:

TypeScriptCode
import { RelayClient } from '@relay-works/sdk-js' const relay = new RelayClient({ apiKey: 'rly_live_agt_abc123xyz...' }) // Send SMS using authentication template (REQUIRED for new agents) const message = await relay.messages.sendTypedTemplate('authentication', { to: '+16175551234', data: { code: '123456' } }) console.log('Message sent:', message.id)

Template Required: All agents on the Starter tier (which includes all autonomous agents) MUST use pre-approved templates. Raw message bodies are not allowed. New agents can only use the authentication template category. After 7 days with good delivery metrics, you'll automatically upgrade to VERIFIED status with access to more template categories.

Step 5: Check Delivery Status

Poll the message status to confirm delivery:

TypeScriptCode
// Get message status const status = await relay.messages.get(message.id) console.log('Status:', status.status) // "delivered", "sent", "failed"

Or check your account status:

TerminalCode
curl https://api.relay.works/v1/accounts/{account_id}/status \ -H "x-api-key: rly_live_agt_abc123xyz..."

Next Steps

Now that your agent is sending messages:

  1. Monitor trust level progress - Check /v1/accounts/:accountId/status endpoint
  2. Handle rate limits - Implement exponential backoff for 429 responses
  3. Set up webhooks - Subscribe to delivery status updates (optional)
  4. Scale gradually - Limits automatically increase after 7 days with 95%+ delivery rate

Troubleshooting

"Rate limit exceeded" (429)

You hit your trust level limit. Check response headers:

Code
X-RateLimit-Limit: 10 X-RateLimit-Remaining: 0 X-Agent-Trust-Level: new_agent Retry-After: 45

Wait for Retry-After seconds or implement exponential backoff.

"Template required" (451)

New agents must use templates. Change your send call:

TypeScriptCode
// ❌ Raw body not allowed for new agents await relay.messages.send({ to, body }) // ✅ Use template instead await relay.messages.sendTypedTemplate('authentication', { to, data: { code } })

"Payment required" (402)

Complete the Stripe Payment Link to remove this error.

Complete Example

Here's a full working example:

TypeScriptCode
import { RelayClient } from '@relay-works/sdk-js' async function setupAgentSMS() { // 1. Create account const accountResponse = await fetch( 'https://api.relay.works/v1/accounts/autonomous', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ agent: { name: 'my-assistant-bot', framework: 'anthropic-mcp', operator: 'human@example.com', version: '1.0.0' }, use_case: { category: 'authentication', description: 'Send 2FA codes', estimated_volume: '100-500/day' }, payment: { method: 'stripe_link', funding_source: 'human_operator' } }) } ) const account = await accountResponse.json() // 2. Store API key securely const apiKey = account.api_key console.log('API Key (save this!):', apiKey) console.log('Complete payment:', account.payment.stripe_link) // 3. Initialize SDK const relay = new RelayClient({ apiKey }) // 4. Send first message try { const message = await relay.messages.sendTypedTemplate('authentication', { to: '+16175551234', data: { code: '123456' } }) console.log('Message sent:', message.id) } catch (error) { if (error.status === 429) { console.log('Rate limited. Retry after:', error.headers['retry-after']) } else { throw error } } } setupAgentSMS()

Support

Need help? Check these resources:

Last modified on