REST API

REVA Mail API Docs

Referensi API lengkap untuk mengintegrasikan REVA Mail ke aplikasi Anda. Semua endpoint mengembalikan JSON dan mendukung method HTTP standar.

REST API CSRF Protected Real-time

URL Dasar

https://revacantik.my.id/api/v1

Semua permintaan API harus dibuat ke endpoint dengan prefiks URL dasar ini.

Otentikasi

API ini menggunakan proteksi CSRF Laravel. Sertakan token CSRF dalam permintaan Anda saat melakukan panggilan dari aplikasi web.

Header yang Diperlukan:

Content-Type: application/json
X-CSRF-TOKEN: Oy3swJmewef7oq7yBO24EV9ChBiPACBFNsGgzdxJ
Accept: application/json

Manajemen Email

Buat Email

POST
/temp-emails/generate

Membuat alamat email baru dengan opsi yang dapat disesuaikan termasuk pembuatan otomatis atau username khusus, dan periode kedaluwarsa yang fleksibel.

Request Body:

{ "generation_type": "auto|custom", // optional, default: "auto" "custom_username": "myemail123", // required if generation_type is "custom" "expires_in": "1_month|6_months|1_year" // optional, default: "1_month" }

generation_type: Choose "auto" for random email or "custom" for your own username

custom_username: 3-20 characters, letters, numbers, dots, hyphens, underscores only

expires_in: Duration until email expires and becomes inactive

Response:

{ "success": true, "data": { "id": 1, "email_address": "[email protected]", "domain": "revacantik.my.id", "expires_at": "2026-04-14T08:30:45Z", "expires_in_days": 31, "created_at": "2026-03-14T08:30:45Z", "is_active": true, "generation_type": "custom" } }

Error Response (Username taken):

{ "success": false, "message": "Username already taken", "errors": { "custom_username": ["This username is already taken"] } }

Periksa Ketersediaan Username

POST
/temp-emails/check-availability

Periksa apakah username khusus tersedia sebelum membuat email. Berguna untuk validasi real-time.

Request Body:

{ "username": "myemail123" // 3-20 chars, letters, numbers, dots, hyphens, underscores }

Response:

{ "success": true, "available": true, "username": "myemail123", "email_address": "[email protected]" }

If username is taken: "available": false

Hapus Email

DELETE
/temp-emails/{emailId}

Menghapus secara permanen sebuah email dan semua pesan yang diterima.

URL Parameters:

emailId: integer (required) // The ID of the temporary email

Response:

{ "success": true, "message": "Email deleted successfully" }

Perpanjang Kedaluwarsa Email

PUT
/temp-emails/{emailId}/extend

Memperpanjang waktu kedaluwarsa email. Opsi yang tersedia: 1 bulan, 6 bulan, 1 tahun.

Request Body:

{ "extension_period": "1_month" // Options: "1_month", "6_months", "1_year" }

Response:

{ "success": true, "message": "Email expiration extended by 1 month", "data": { "new_expires_at": "2026-05-14T08:30:45.000000Z", "extended_by": "1 month" } }

Operasi Inbox

Ambil Pesan Inbox

GET
/temp-emails/{emailId}/inbox

Mengambil semua email yang diterima untuk alamat email yang ditentukan.

URL Parameters:

emailId: integer (required) // The ID of the temporary email

Response:

{ "success": true, "data": [ { "id": 1, "from_email": "[email protected]", "sender_name": "Example Service", "subject": "Welcome!", "body": "Thank you for signing up...", "verification_code": "123456", "link": "https://example.com/verify", "received_at": "2026-03-14T08:35:20.000000Z", "is_read": false } ] }

Ambil Email Spesifik

GET
/temp-emails/{emailId}/email/{messageId}

Mengambil detail dari pesan email spesifik dan menandainya sebagai sudah dibaca.

URL Parameters:

emailId: integer (required) messageId: integer (required) // IDs of email and message

Response:

{ "success": true, "data": { "id": 1, "from_email": "[email protected]", "sender_name": "Example Service", "subject": "Welcome!", "body": "Thank you for signing up...", "verification_code": "123456", "link": "https://example.com/verify", "received_at": "2026-03-14T08:35:20.000000Z", "is_read": true } }

Periksa Email Baru

GET
/temp-emails/{emailId}/check-new

Memeriksa email baru yang belum dibaca. Mengembalikan jumlah dan pesan terbaru.

Response:

{ "success": true, "data": { "new_emails_count": 2, "total_emails": 5, "has_new": true, "latest_emails": [ { "id": 5, "subject": "New Message", "from_email": "[email protected]", "received_at": "2026-03-14T09:00:00.000000Z" } ] } }

Usage Notes:

Perfect for real-time polling to check for new emails without loading the entire inbox.

Get Email Statistics

GET
/temp-emails/{emailId}/stats

Returns statistics and details about the email including remaining time.

Response:

{ "success": true, "data": { "total_emails": 3, "unread_emails": 1, "read_emails": 2, "expires_at": "2026-04-14T08:30:45.000000Z", "time_remaining": { "days": 31, "hours": 5, "minutes": 45 }, "is_active": true } }

Use Cases:

Dashboard widgets

Email counters

Expiration warnings

User notifications

Statistik Live Platform

Statistik Real-Time

GET
/stats

Mengambil statistik platform secara real-time termasuk jumlah email aktif, email dibuat hari ini, email masuk hari ini, dan total email sepanjang masa. Perfect untuk dashboard dengan auto-refresh.

Fitur Statistik:

Lagi Aktif: Email yang sedang aktif dan belum expired

Dibuat Hari Ini: Email baru yang dibuat hari ini

Masuk Hari Ini: Email yang diterima hari ini

Total Sepanjang Masa: Total email yang pernah dibuat

Header CSRF:

X-CSRF-TOKEN: Oy3swJmewef7oq7yBO24EV9ChBiPACBFNsGgzdxJ

Response Success:

{ "success": true, "data": { "stats": [ { "label": "Lagi Aktif", "emoji": "🔥", "value": 29, "description": "Email yang sedang aktif dan belum expired" }, { "label": "Dibuat Hari Ini", "emoji": "✨", "value": 7, "description": "Email baru yang dibuat hari ini" }, { "label": "Masuk Hari Ini", "emoji": "📬", "value": 2, "description": "Email yang diterima hari ini" }, { "label": "Total Sepanjang Masa", "emoji": "🏆", "value": 29, "description": "Total email yang pernah dibuat" } ], "updated_at": { "time": "14.07.43", "formatted": "Diperbarui jam 14.07.43", "full_datetime": "2026-03-16 14:07:43", "iso": "2026-03-16T14:07:43.000Z" }, "server_info": { "timezone": "UTC", "date": "16 Mar 2026", "day_name": "Sunday" } } }

Kegunaan Statistik Live:

Dashboard real-time

Monitoring platform

Analytics integration

Auto-refresh support

Mobile-friendly response

Timezone aware

Pengujian & Simulasi

Simulasi Email Masuk

POST
/simulate/email

Mensimulasikan penerimaan email untuk tujuan pengujian. Sempurna untuk skenario pengembangan dan demo.

Request Body:

{ "temp_email_id": 1, "from_email": "[email protected]", "sender_name": "Test Sender", "subject": "Test Email", "body": "This is a test message", "verification_code": "123456", "link": "https://example.com/verify" }

Response:

{ "success": true, "message": "Email simulated successfully", "data": { "id": 1, "from_email": "[email protected]", "subject": "Test Email", "received_at": "2026-03-14T08:35:20.000000Z" } }

Receive Email (Server Integration)

POST
/receive/email

Endpoint for email server integration. Used by mail servers to deliver emails to temporary addresses.

Server Integration Only

This endpoint is designed for mail server integration and requires proper email server configuration.

Request Body:

{ "to_email": "[email protected]", "from_email": "[email protected]", "sender_name": "Sender Name", "subject": "Email Subject", "body": "Email body content", "verification_code": "123456", "link": "https://example.com/link" }

Response:

{ "success": true, "message": "Email received successfully", "data": { "message_id": 1, "temp_email_id": 1, "received_at": "2026-03-14T08:35:20.000000Z" } }

Bulk Receive Emails

POST
/receive/bulk-emails

Process multiple emails in a single request. Useful for bulk email processing.

Request Body:

{ "emails": [ { "to_email": "[email protected]", "from_email": "[email protected]", "subject": "Email 1", "body": "Content 1" }, { "to_email": "[email protected]", "from_email": "[email protected]", "subject": "Email 2", "body": "Content 2" } ] }

Response:

{ "success": true, "message": "Processed 2 emails", "data": { "processed": 2, "successful": 2, "failed": 0, "results": [ {"index": 0, "success": true, "message_id": 1}, {"index": 1, "success": true, "message_id": 2} ] } }

Penanganan Error

Format Respons Error

Semua error API mengembalikan struktur JSON yang konsisten:

{ "success": false, "message": "Error description", "errors": { "field_name": ["Validation error message"] } }

Kode Status HTTP Umum

200 Success
400 Bad Request / Validation Error
404 Not Found
419 CSRF Token Mismatch
429 Rate Limit Exceeded
500 Server Error

Contoh Kode

JavaScript (Fetch API)

// Generate email const response = await fetch('/api/v1/temp-emails/generate', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content } }); const result = await response.json(); console.log('Generated email:', result.data.email_address); // Check inbox const inboxResponse = await fetch(`/api/v1/temp-emails/${result.data.id}/inbox`); const inbox = await inboxResponse.json(); console.log('Inbox emails:', inbox.data);

PHP (cURL)

<?php // Check username availability $checkData = json_encode(['username' => 'myemail123']); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://revacantik.my.id/api/v1/temp-emails/check-availability'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $checkData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'X-CSRF-TOKEN: ' . $csrfToken ]); $availabilityResponse = curl_exec($ch); $availability = json_decode($availabilityResponse, true); if ($availability['available']) { // Generate custom email $data = json_encode([ 'generation_type' => 'custom', 'custom_username' => 'myemail123', 'expires_in' => '6_months' ]); curl_setopt($ch, CURLOPT_URL, 'https://revacantik.my.id/api/v1/temp-emails/generate'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); $result = json_decode($response, true); echo 'Generated email: ' . $result['data']['email_address']; } else { echo 'Username not available'; } curl_close($ch); ?>

Python (requests)

import requests # Generate email response = requests.post( 'https://revacantik.my.id/api/v1/temp-emails/generate', headers={ 'Content-Type': 'application/json', 'X-CSRF-TOKEN': csrf_token } ) data = response.json() email_id = data['data']['id'] email_address = data['data']['email_address'] print(f'Generated email: {email_address}') # Simulate incoming email simulate_data = { 'temp_email_id': email_id, 'from_email': '[email protected]', 'sender_name': 'Test Sender', 'subject': 'Test Email', 'body': 'This is a test message' } simulate_response = requests.post( 'https://revacantik.my.id/api/v1/simulate/email', json=simulate_data, headers={'X-CSRF-TOKEN': csrf_token} ) print('Email simulated:', simulate_response.json()['success'])

Pembatasan Rate

Batas Saat Ini:

60 requests per minute per IP

10 email generations per hour

20 simulations per hour

Header Pembatasan Rate:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1640995200

Panduan Integrasi

Aplikasi Mobile

Sempurna untuk aplikasi mobile yang membutuhkan verifikasi email tanpa registrasi pengguna.

Aplikasi Web

Integrasikan langsung ke form web dan proses registrasi untuk privasi yang lebih baik.

Pengujian & Otomasi

Ideal untuk skenario pengujian otomatis dan pipeline CI/CD yang membutuhkan verifikasi email.