SiapInbox API

API Docs

Dokumentasi lengkap untuk dashboard API, public API, dan inbound endpoint dari Cloudflare Worker.

Base URLs

Dashboard/App: https://mail.siapdigital.web.id
Inbound API: https://mail.siapdigital.web.id/api/inbound-email
Public API: https://mail.siapdigital.web.id/api/public

Authentication

`/api/inbound-email` memakai `Authorization: Bearer INBOUND_EMAIL_SECRET`.

Public API memakai Bearer API key dari tabel `api_keys`.

Dashboard API memakai session login dashboard.

Public Permissions

`addresses:create` untuk membuat random atau custom email dari platform lain.

`emails:read` untuk membaca messages, latest message, dan latest OTP.

Cloudflare Worker Env

INBOUND_API_URL=https://mail.siapdigital.web.id/api/inbound-email
INBOUND_EMAIL_SECRET=<same value as Next.js>
VERCEL_AUTOMATION_BYPASS_SECRET=<optional if deployment protection is enabled>

Jika project Vercel memakai Deployment Protection, Worker harus mengirim header x-vercel-protection-bypass dengan secret automation bypass dari Vercel.

Inbound Endpoint

POST /api/inbound-email
Dipanggil oleh Cloudflare Email Worker untuk menyimpan email masuk.
Request Format
{
  "message_id": "<message-id>",
  "from_email": "sender@example.com",
  "from_name": "Sender Name",
  "to_email": "lead@siapdigital.web.id",
  "subject": "Test Email",
  "text_body": "Hello from email",
  "html_body": "<p>Hello from email</p>",
  "raw_headers": {},
  "raw_payload": {},
  "attachments": []
}
curl -X POST "https://mail.siapdigital.web.id/api/inbound-email" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer INBOUND_EMAIL_SECRET" \
  -d '{
    "message_id": "<message-id>",
    "from_email": "sender@example.com",
    "from_name": "Sender Name",
    "to_email": "lead@siapdigital.web.id",
    "subject": "Test Email",
    "text_body": "Hello from email",
    "html_body": "<p>Hello from email</p>",
    "raw_headers": {},
    "raw_payload": {}
  }'
Success Response
{
  "success": true,
  "email_id": "uuid"
}

Public API

POST /api/public/email-addresses
Membuat custom email address tetap dengan `local_part` tertentu.
curl -X POST "https://mail.siapdigital.web.id/api/public/email-addresses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "local_part": "support-project-a",
    "project": "project-a",
    "label": "Support Project A",
                    "purpose": "Fixed address for support testing"
  }'
Response Format
{
  "email_address": {
    "id": "uuid",
    "email": "support-project-a@siapdigital.web.id",
    "local_part": "support-project-a",
    "label": "Support Project A",
    "project": "project-a",
    "status": "active",
    "created_at": "2026-05-13T10:00:00Z"
  }
}
POST /api/public/email-addresses/random
Membuat email address dari prefix ditambah 2 digit angka acak tanpa tanda pisah.
curl -X POST "https://mail.siapdigital.web.id/api/public/email-addresses/random" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prefix": "otp-test",
    "project": "automation-tool",
    "label": "OTP Test"
  }'
Response Format
{
  "email": "otptest42@siapdigital.web.id"
}
GET /api/public/email-addresses/:email/messages
Mengambil daftar message berdasarkan email address.
curl "https://mail.siapdigital.web.id/api/public/email-addresses/otptest42@siapdigital.web.id/messages" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response Format
{
  "messages": [
    {
      "id": "uuid",
      "from_email": "noreply@example.com",
      "from_name": "No Reply",
      "subject": "Verify your email",
      "text_body": "Click the button below",
      "html_body": "<a href=\"https://example.com\">Verify</a>",
      "received_at": "2026-05-13T10:00:00Z",
      "status": "unread"
    }
  ]
}
GET /api/public/email-addresses/:email/latest
Mengambil email terbaru. Cocok untuk polling OTP.
curl "https://mail.siapdigital.web.id/api/public/email-addresses/otptest42@siapdigital.web.id/latest" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response Format
{
  "message": {
    "id": "uuid",
    "subject": "Your OTP Code",
    "text_body": "Your code is 123456",
    "html_body": "<p>Your code is <b>123456</b></p>",
    "received_at": "2026-05-13T10:00:00Z",
    "from_email": "noreply@example.com",
    "from_name": null,
    "status": "unread"
  }
}
GET /api/public/email-addresses/:email/latest-otp
Mencari OTP 4-8 digit dari beberapa email terbaru.
curl "https://mail.siapdigital.web.id/api/public/email-addresses/otptest42@siapdigital.web.id/latest-otp" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response Format
{
  "otp": "123456",
  "source_message_id": "uuid",
  "received_at": "2026-05-13T10:00:00Z"
}
GET /api/public/email-addresses/:email/latest-links
Mengambil semua link dari `html_body` email terakhir.
curl "https://mail.siapdigital.web.id/api/public/email-addresses/otptest42@siapdigital.web.id/latest-links" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response Format
{
  "message_id": "uuid",
  "subject": "Verify your email",
  "received_at": "2026-05-13T10:00:00Z",
  "links": [
    {
      "url": "https://example.com/verify?token=abc",
      "text": "Verify Email"
    }
  ]
}
GET /api/public/email-addresses/:email/latest-primary-link
Mengambil link utama dari email terakhir, cocok untuk verify/confirm/reset link.
curl "https://mail.siapdigital.web.id/api/public/email-addresses/otptest42@siapdigital.web.id/latest-primary-link" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response Format
{
  "message_id": "uuid",
  "subject": "Verify your email",
  "received_at": "2026-05-13T10:00:00Z",
  "link": {
    "url": "https://example.com/verify?token=abc",
    "text": "Verify Email"
  }
}

Dashboard API

`POST /api/email-addresses/random` untuk create random address dari dashboard.

`POST /api/email-addresses` untuk create custom address.

`GET /api/email-addresses` untuk list seluruh address.

`GET /api/email-addresses/:id/messages` untuk list messages per address.

`GET /api/emails/:id` dan `PATCH /api/emails/:id` untuk detail dan update status/label.

`GET /api/api-keys`, `POST /api/api-keys`, `PATCH /api/api-keys/:id` untuk manajemen API key.