Submit and poll
Submit request - curl
curl https://replyinmyvoice.com/api/v1/rewrite \
-H "Authorization: Bearer rmv_live_xxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: crm-reply-123" \
-d '{ "draft": "Sam, your order is delayed and ships next week." }'
Submit request - Node (fetch)
const apiKey = process.env.RIMV_API_KEY ?? "rmv_live_xxx";
const response = await fetch("https://replyinmyvoice.com/api/v1/rewrite", {
method: "POST",
headers: {
Authorization: "Bearer " + apiKey,
"Content-Type": "application/json",
"Idempotency-Key": "crm-reply-123",
},
body: JSON.stringify({
draft: "Sam, your order is delayed and ships next week.",
}),
});
console.log(response.status, response.headers.get("Location"));
console.log(await response.json());
Submit request - Python (requests)
import os
import requests
api_key = os.environ.get("RIMV_API_KEY", "rmv_live_xxx")
response = requests.post(
"https://replyinmyvoice.com/api/v1/rewrite",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
"Idempotency-Key": "crm-reply-123",
},
json={"draft": "Sam, your order is delayed and ships next week."},
timeout=30,
)
print(response.status_code, response.headers.get("Location"))
print(response.json())
Submit response202 Accepted
HTTP/1.1 202 Accepted
Location: /api/v1/rewrite/7f3c2c1a-9d4e-4b8a-b1f2-3a5d8e9c0f11
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1812345678
{
"id": "7f3c2c1a-9d4e-4b8a-b1f2-3a5d8e9c0f11",
"status": "processing"
}
Poll request - curl
curl https://replyinmyvoice.com/api/v1/rewrite/7f3c2c1a-9d4e-4b8a-b1f2-3a5d8e9c0f11 \
-H "Authorization: Bearer rmv_live_xxx"
Poll request - Node (fetch)
const apiKey = process.env.RIMV_API_KEY ?? "rmv_live_xxx";
const id = "7f3c2c1a-9d4e-4b8a-b1f2-3a5d8e9c0f11";
const response = await fetch(
"https://replyinmyvoice.com/api/v1/rewrite/" + encodeURIComponent(id),
{
headers: {
Authorization: "Bearer " + apiKey,
},
},
);
console.log(await response.json());
Poll request - Python (requests)
import os
import requests
api_key = os.environ.get("RIMV_API_KEY", "rmv_live_xxx")
job_id = "7f3c2c1a-9d4e-4b8a-b1f2-3a5d8e9c0f11"
response = requests.get(
f"https://replyinmyvoice.com/api/v1/rewrite/{job_id}",
headers={"Authorization": f"Bearer {api_key}"},
timeout=30,
)
print(response.json())
Poll response
{
"id": "7f3c2c1a-9d4e-4b8a-b1f2-3a5d8e9c0f11",
"status": "succeeded",
"rewrittenText": "Hi Sam, thanks for your patience. Your order is running a little behind and ships next week.",
"signal": {
"draft": 78,
"rewrite": 24
}
}