1// connect-reqnora.mjs
2const API = process.env.REQNORA_API_URL || "https://app.reqnora.com";
3const KEY = process.env.REQNORA_API_KEY; // ak_live_...
4
5async function sendRequest() {
6 const res = await fetch(`${API}/api/v1/requests`, {
7 method: "POST",
8 headers: {
9 Authorization: `Bearer ${KEY}`,
10 "Content-Type": "application/json",
11 "Idempotency-Key": `deploy-${Date.now()}`,
12 },
13 body: JSON.stringify({
14 title: "Deploy production?",
15 message: "Version 2.8 passed all tests.",
16 severity: "warning",
17 allow_reply: true,
18 actions: [
19 { id: "approve", label: "Approve", style: "primary" },
20 { id: "reject", label: "Reject", style: "danger" },
21 ],
22 expires_in: 900,
23 }),
24 });
25
26 if (!res.ok) throw new Error(await res.text());
27 const data = await res.json();
28 console.log("created", data.id, data.expires_at);
29 return data;
30}
31
32await sendRequest();