Add email to an app you build with an AI assistant
You describe it, your assistant writes it. Here is what to tell it, and what to check before you accept its code.
Create a test key
In the console, open API keys and create a key named after your app. Keep it in test mode while you build: a test key accepts every request, sends nothing to a real inbox and costs nothing. Your app needs only the emails:send permission.
Put the key in your project secrets
Every AI app builder and editor has a place for secrets or environment variables. Add the key there as WOYRA_API_KEY. Never paste a key into the chat, and never let the assistant write it into your code: secrets stay on the server, out of your repository and out of the browser.
Give your assistant this prompt
Be specific about the three things that matter: the server sends, the key comes from the environment, and a retry can never send twice. Change the sender to an address on your own domain.
Add order confirmation emails with the Woyra Email API (docs.woyra.io). Send from the server only, never from the browser. POST to https://api.woyra.io/v1/emails with the key from the WOYRA_API_KEY environment variable; never put the key in code. Send from "Your Shop <orders@yourdomain.com>" and use the order ID as the Idempotency-Key.Review two things before you accept the code
- The key is read from the environment, as
process.env.WOYRA_API_KEYor your language’s equivalent, and appears nowhere else. - The request runs on the server: a route, an action or a function, never a component that ships to the browser.
Test it, then check your logs
Trigger the email in your preview. Woyra accepts it at once and returns its ID and status, and the console’s Logs page shows it with every status it has had.
Add a webhook for bounces and complaints
In the console, open Webhooks, add your app’s address and choose Bounced and Marked as spam. Save the signing secret in your project secrets as WOYRA_WEBHOOK_SECRET, then ask your assistant to handle the events.
Add a Woyra webhook at POST /api/woyra-webhook. Verify the Woyra-Signature header with WOYRA_WEBHOOK_SECRET as shown at docs.woyra.io and reject anything that fails. When an email bounces (email.undelivered) or is marked as spam (email.complained), stop emailing that address.When something fails, paste the error into the chat
Every Woyra error has a code and a message that says what happened, such as invalid_api_key. Copy the exact text into the chat: your assistant can fix the cause instead of guessing.
Go live
Add your domain in the console and publish its DNS records. Once it is verified, create a live key, put it in your secrets in place of the test key, and publish. The code does not change.
Questions
Can I paste my API key into the chat so the assistant can test?
No. Put it in your project secrets and tell the assistant its name. Anything in a chat can end up in logs, history or code; a secret never leaves the server.
Can the email be sent from the browser?
No. Code in the browser is visible to everyone who opens your app, so the key would be too. The send must run on the server.
Which AI tools does this work with?
Any of them. It is one HTTPS request, so it works with every language and framework your assistant writes. Point it at docs.woyra.io, or at docs.woyra.io/llms.txt for the plain-text version.
Next
Get a test key and run any of this in about ninety seconds.