Receive & reply

Set up webhook-driven inbound email handling with automatic replies.

1. Create a webhook

curl
curl -X POST https://api.robotomail.com/v1/webhooks \
  -H "Authorization: Bearer $ROBOTOMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhooks/email",
    "events": ["message.received"]
  }'

2. Handle the webhook

When an email arrives, Robotomail sends a POST request to your endpoint with the message data. Verify the signature before processing:

node.js
import crypto from "crypto";

app.post("/webhooks/email", (req, res) => {
  const signature = req.headers["x-robotomail-signature"];
  const expected = crypto
    .createHmac("sha256", WEBHOOK_SECRET)
    .update(JSON.stringify(req.body))
    .digest("hex");

  if (signature !== expected) return res.status(401).send("Invalid signature");

  const { message } = req.body;
  console.log(`New email from ${message.fromAddress}: ${message.subject}`);

  res.status(200).send("OK");
});

3. Send a reply

Reply to the inbound message by passing its messageId (the RFC 5322 Message-ID header value) in the inReplyTo field:

curl
curl -X POST https://api.robotomail.com/v1/mailboxes/MAILBOX_ID/messages \
  -H "Authorization: Bearer $ROBOTOMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": ["[email protected]"],
    "subject": "Re: Their subject",
    "bodyText": "Thanks for your email! Here is my reply.",
    "inReplyTo": "<[email protected]>"
  }'

This automatically threads the reply with the original message.

Alternative: Polling

If you can't set up a webhook endpoint, poll for new messages using the since parameter:

curl
curl "https://api.robotomail.com/v1/mailboxes/MAILBOX_ID/messages?direction=INBOUND&since=2026-03-11T00:00:00Z" \
  -H "Authorization: Bearer $ROBOTOMAIL_API_KEY"