Developer

Authentication

Cara melakukan authentication ke Wahero API menggunakan API key

Metode Authentication

Bearer Token (API Key)

Wahero API menggunakan Bearer Token authentication. Setiap request harus menyertakan API key di header Authorization.

Cara Mendapatkan API Key

  1. 1

    Login ke dashboard Wahero

  2. 2

    Navigasi ke Settings → API Keys

  3. 3

    Klik "Generate New API Key"

  4. 4

    Copy dan simpan API key dengan aman (hanya ditampilkan sekali!)

Cara Menggunakan API Key

Sertakan API key di header Authorization dengan prefix Bearer:

HTTP Header
Authorization: Bearer wahero_live_xxxxxxxxxxxxx

Example Request (cURL):

cURL
curl -X POST https://api.wahero.id/v1/send-message \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "628123456789",
    "message": "Hello from Wahero!"
  }'

Example (JavaScript/Fetch):

fetch('https://api.wahero.id/v1/send-message', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    phone: '628123456789',
    message: 'Hello from Wahero!'
  })
})
.then(res => res.json())
.then(data => console.log(data));

Example (Python/Requests):

import requests

headers = {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
}

data = {
    'phone': '628123456789',
    'message': 'Hello from Wahero!'
}

response = requests.post(
    'https://api.wahero.id/v1/send-message',
    headers=headers,
    json=data
)

print(response.json())

API Key Types

LIVE
wahero_live_...

Production Key

Untuk production/live environment. Mengirim pesan WhatsApp yang sebenarnya.

  • • Kirim pesan real
  • • Charged per message
  • • Rate limit sesuai paket
TEST
wahero_test_...

Test/Sandbox Key

Untuk development/testing. Simulasi tanpa mengirim pesan real.

  • • Tidak kirim pesan real
  • • Starter unlimited
  • • Response simulasi success

Error Responses

401Unauthorized

API key tidak valid, missing, atau expired

{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid API key"
  }
}
403Forbidden

API key valid tapi tidak punya akses ke resource

{
  "success": false,
  "error": {
    "code": "FORBIDDEN",
    "message": "This API key does not have access to this resource"
  }
}

Keamanan API Key

Penting!

API key seperti password. Jangan pernah share atau expose di public.

✅ DO

  • • Simpan di environment variables
  • • Gunakan secret management tools
  • • Regenerate secara berkala
  • • Gunakan different keys untuk dev/prod
  • • Revoke key yang tidak terpakai

❌ DON'T

  • • Jangan commit ke git/GitHub
  • • Jangan hardcode di source code
  • • Jangan share via email/chat
  • • Jangan pakai di client-side code
  • • Jangan screenshot atau log

Rotate/Regenerate API Key

Jika API key Anda ter-expose atau dicurigai bocor, segera regenerate:

  1. 1. Login ke dashboard → Settings → API Keys
  2. 2. Klik "Regenerate" pada key yang ingin di-rotate
  3. 3. Copy key baru dan update di aplikasi Anda
  4. 4. Old key akan di-revoke dalam 24 jam (grace period)

Mulai Integrasikan API

Dapatkan API key dan mulai kirim pesan WhatsApp via API