ZapSMTP / Docs / Received emailsResponse
Reply to a received email
POST/v1/emails/receiving/{id}/reply
Reply to a received email: recipients, subject, sender and threading headers default to the email's, so the answer lands in the sender's conversation.
Requires a full-access key. Live keys: the From domain must be verified for sending.
Our Message-ID of the reply names its thread, so the customer's answer joins the conversation even from a mail client that keeps only In-Reply-To.
Every other rule of POST /emails applies: suppressions, quotas, tracking, test keys.
Loop protection: replies to automated email need allow_automated, and one conversation takes at most 20 replies an hour.
Path parameters
idstring (UUID)required- Received email id
Headers
Idempotency-Keystring- optional, 1-256 bytes (see Idempotency)
Body parameters
textstring- Plain-text body. Either text or html (or a template) is required.
htmlstring- HTML body.
fromstring- Default: the address that received the email (e.g.
support@acme.com), which must be on a verified sending domain. Required when the email came to a managed*.in.zapsmtp.xyzaddress (those only receive): 422 missing_required_field. tostring | string[]- Default: the email's Reply-To, else its From. Limits: 422 missing_required_field when the email has neither.
reply_allboolean- Also copy everyone on the email's To and Cc, except the receiving address, the sender you reply from and anyone already addressed. Default
false. allow_automatedboolean- Answer an automated email anyway (see
automatedon the received email). Without it a reply to a bounce, out-of-office, auto-reply or notification is refused with 422 automated_message: two auto-responders answering each other is a mail loop. Bulk mail can be answered without it. Defaultfalse. auto_replyboolean- This answer is itself automatic (an acknowledgement, a ticket receipt): adds
Auto-Submitted: auto-repliedandX-Auto-Response-Suppress: All(RFC 3834), so other auto-responders do not answer it. Defaultfalse. ccstring | string[]- Added to the Cc (reply_all adds the email's recipients after these).
bccstring | string[]- Bcc recipients.
reply_tostring | string[]- Default: the receiving address when you reply from another one, so the customer's answer comes back to the same inbox.
subjectstring- Default:
Re:+ the email's subject (kept as is when it already starts with Re:). headersobject- Custom headers.
In-Reply-ToandReferencesare set for you (RFC 5322 threading); a value you give wins. attachments, tags, metadata, stream, tracking, template, scheduled_at- As in POST /emails.
Errors
validation_errorHTTP 400- invalid JSON / unknown field
invalid_idempotency_keyHTTP 400- Idempotency-Key must be 1 to 256 bytes
domain_not_verifiedHTTP 403- sender domain is not verified for this account
restricted_api_keyHTTP 403not_foundHTTP 404- email not found
idempotency_key_reusedHTTP 409idempotency_request_in_progressHTTP 409missing_required_fieldHTTP 422- from (managed receiving address), to (no sender on the email), or the body
automated_messageHTTP 422- the email is a bounce, out-of-office, auto-reply or notification; pass allow_automated: true
rate_limit_exceededHTTP 429thread_reply_limitHTTP 429- too many replies in this conversation in the last hour (a mail loop?); at most 20 per hour; Retry-After: 3600
inbound_not_configuredHTTP 503
curl -X POST 'https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply' \
-H "Authorization: Bearer $ZAP_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"text": "Thanks, it ships today."
}'const res = await fetch('https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ZAP_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"text": "Thanks, it ships today."
}),
});
// 204 No Content (e.g. a delete) has no body
const data = res.status === 204 ? null : await res.json();
if (!res.ok) throw new Error(`${data.name}: ${data.message}`);
console.log(data);import os
import requests
res = requests.post(
"https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply",
headers={"Authorization": f"Bearer {os.environ['ZAP_API_KEY']}"},
json={
"text": "Thanks, it ships today.",
},
timeout=30,
)
res.raise_for_status()
print(res.json() if res.status_code != 204 else "deleted")<?php
$ch = curl_init('https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ZAP_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Thanks, it ships today.',
]),
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status >= 400) {
throw new RuntimeException($data['message']);
}
print_r($data);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"text": "Thanks, it ships today."
}`)
req, err := http.NewRequest(
"POST",
"https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply",
body,
)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ZAP_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(out))
}require 'net/http'
require 'json'
uri = URI('https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply')
req = Net::HTTP::Post.new(uri)
req['Authorization'] = "Bearer #{ENV.fetch('ZAP_API_KEY')}"
req['Content-Type'] = 'application/json'
req.body = {
text: "Thanks, it ships today."
}.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.code, (JSON.parse(res.body) unless res.body.to_s.empty?)import java.net.URI;
import java.net.http.*;
public class ZapRequest {
public static void main(String[] args) throws Exception {
var request = HttpRequest.newBuilder(URI.create("https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply"))
.header("Authorization", "Bearer " + System.getenv("ZAP_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"text": "Thanks, it ships today."
}"""))
.build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}using System.Net.Http.Headers;
using System.Text;
using var http = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://zapsmtp.xyz/v1/emails/receiving/019a1f2e-7c3b-7d41-9a52-0c4b8e6f1a23/reply");
request.Headers.Authorization = new AuthenticationHeaderValue(
"Bearer", Environment.GetEnvironmentVariable("ZAP_API_KEY"));
request.Content = new StringContent("""
{
"text": "Thanks, it ships today."
}
""", Encoding.UTF8, "application/json");
var response = await http.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");Set
ZAP_API_KEY in your environment.Response 200 OK
{
"id": "019a1f41-8b2c-7e3d-9f40-5a6b7c8d9e0f",
"thread_id": "3f1c9a52-6b0e-5d4f-8a71-2c9e0b4d6f13"
}