← All guides

Add SMS to a Lovable App: OTP Codes and Messages

To add SMS to a Lovable app, save your Telmian key as a project secret named TELMIAN_API_KEY (never VITE_), then ask Lovable to call https://app.telmian.com/v1 from a server function or Edge Function. Send a code with POST /v1/verify and check it with POST /v1/verify/check. Start free in the sandbox with an sk_test_ key.

Where Telmian code runs in a Lovable app
Your appWhere server code runsHow it reads the key
Created from 13 May 2026 (TanStack Start)Server functions and API routes inside the appFrom Secrets, injected on the server
Older React + Vite appEdge Functions on the built-in backendDeno.env.get('TELMIAN_API_KEY')
Your own Supabase projectSupabase Edge FunctionsSecret set in Supabase under Edge Functions settings
  1. Get a sandbox key

    On your computer, run npx telmian@1 login, then npx telmian@1 init: it writes an sk_test_ sandbox key to .env, and you copy the value from there. The sandbox is free and needs no card. SMS are simulated: +393000000001 always receives code 000000 and +393000000002 always fails.

  2. Save the key as a Lovable secret

    Add "Ask me for any API keys you need" to your prompt and Lovable opens a secure secret form, or go to More → Settings → Secrets → Add secret. Name it TELMIAN_API_KEY. Lovable refuses VITE_ names because those end up in the browser, and the form keeps the key out of your chat history.

  3. Ask Lovable to build the server code

    Describe the feature in the project chat. Apps created from 13 May 2026 run server code as server functions; older React + Vite apps use Edge Functions on the built-in backend. Either way the key stays on the server.

    Add phone verification with the Telmian SMS API.
    Base URL: https://app.telmian.com/v1. Auth: Bearer token from the secret TELMIAN_API_KEY. Ask me for any API keys you need.
    Call Telmian only from server-side code (server function or Edge Function), never from the browser.
    POST /v1/verify {"phone"} sends a code (send an Idempotency-Key header, one per sign-up attempt).
    POST /v1/verify/check {"phone","code"} returns {"valid":true|false}.
    Check who is calling before sending.
  4. Check the code Lovable writes

    The function should look roughly like this. signupAttemptId is one ID per attempt: if a request fails, retry only with the same ID so the user does not get two codes. Anyone who knows a function's address can call it, so make sure it checks the caller.

    // Edge Function (Deno). The key never reaches the browser.
    const TELMIAN_API_KEY = Deno.env.get('TELMIAN_API_KEY');
    
    // 1. Send the code
    const res = await fetch('https://app.telmian.com/v1/verify', { method: 'POST', headers: { Authorization: `Bearer ${TELMIAN_API_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': signupAttemptId }, body: JSON.stringify({ phone }) });
    
    // 2. Check the code the user typed
    const check = await fetch('https://app.telmian.com/v1/verify/check', { method: 'POST', headers: { Authorization: `Bearer ${TELMIAN_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ phone, code }) }); const { valid } = await check.json();
  5. Choose your phone sign-in route

    Lovable's built-in phone sign-in only lists Twilio, Twilio Verify, TextLocal, Vonage and MessageBird, so Telmian is not there. Use Telmian's OTP from your server code as above and mark the user verified when valid is true. Or connect your own Supabase project and set Telmian as its Send SMS hook: see the Supabase guide.

  6. Receive delivery reports and replies

    Ask Lovable to create an Edge Function that works as a webhook endpoint. Copy its address from More → Database → Manage → Edge functions → Copy URL and give it to Telmian. Telmian signs every webhook, so ask Lovable to verify the signature on each call (the telmian npm SDK has verifyWebhook).

  7. Go live

    Set an approved business name in the Telmian panel at https://app.telmian.com; real codes need it. Top up by card from €5 (a first top-up of at least €10 gets €5 more, once), create an sk_live_ key in the panel and replace the secret value with it. Each SMS segment costs €0.05 plus VAT, and SMS refused by the network or not delivered are refunded automatically.

Questions

Can I pick Telmian in Lovable's built-in phone sign-in settings?

No. That list only has Twilio, Twilio Verify, TextLocal, Vonage and MessageBird. Use Telmian's OTP from a server function or Edge Function, or connect your own Supabase project and use Telmian as the Send SMS hook. The MCP tool setup_supabase_sms gives you the hook URL and secret.

Why can't I name the key VITE_TELMIAN_API_KEY?

VITE_ values are built into the browser code, so anyone visiting your app could read them. Lovable refuses VITE_ names in Secrets for this reason. Use TELMIAN_API_KEY and call Telmian only from server code.

Can strangers use my function to send SMS on my credit?

Anyone who knows a function's address can call it, so ask Lovable to check who is calling before sending. Also send an Idempotency-Key with every send and retry only with the same key, so a retry never sends a second SMS.

Can I send reminders or order updates, not just codes?

Yes. Use POST /v1/messages with an approved template (GET /v1/templates lists them) and the customer's number. A new template is reviewed by AI in seconds or by a person. Reminders can be scheduled with send_at. Free text is only for alerts to your own verified numbers.

Can I connect the Telmian MCP server to Lovable?

It is an optional extra while building. You can try Connectors → Add custom → MCP server with https://app.telmian.com/mcp and OAuth; if the sign-in completes, Lovable can read Telmian context in chat. It is never part of your published app, which still needs the server code and secret above.

Updated