| 14 | } |
| 15 | |
| 16 | async function runTest() { |
| 17 | console.log("🚀 Sending Test Broadcast via Kit API..."); |
| 18 | |
| 19 | const url = `https://api.convertkit.com/v3/broadcasts`; |
| 20 | const payload = { |
| 21 | api_key: KIT_API_KEY, |
| 22 | api_secret: KIT_API_SECRET, |
| 23 | subject: "OpenStock Manual Test " + new Date().toISOString(), |
| 24 | content: "<h1>Test Email</h1><p>If you see this, the API connection is working.</p>", |
| 25 | public: true |
| 26 | }; |
| 27 | |
| 28 | try { |
| 29 | const response = await fetch(url, { |
| 30 | method: 'POST', |
| 31 | headers: { 'Content-Type': 'application/json' }, |
| 32 | body: JSON.stringify(payload) |
| 33 | }); |
| 34 | |
| 35 | const data = await response.json(); |
| 36 | console.log("👉 API Response Status:", response.status); |
| 37 | console.log("👉 Full Response Body:", JSON.stringify(data, null, 2)); |
| 38 | |
| 39 | } catch (e) { |
| 40 | console.error("❌ Request Failed:", e); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | runTest(); |