Developer

Authentication

Cara melakukan authentication ke Wahero API menggunakan API key

Metode Authentication

X-Api-Key Header

Wahero API menggunakan API key authentication. Setiap request harus menyertakan API key di header X-Api-Key.

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 X-Api-Key:

HTTP Header
X-Api-Key: wahero_live_xxxxxxxxxxxxx

Example Request (cURL):

cURL
curl -X POST https://api.wahero.id/api/v1/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "instanceId": "uuid-instance-anda",
    "phone": "628123456789",
    "message": "Hello from Wahero!"
  }'

Example (JavaScript/Fetch):

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

Example (Python/Requests):

import requests

headers = {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
}

data = {
    'instanceId': 'uuid-instance-anda',
    'phone': '628123456789',
    'message': 'Hello from Wahero!'
}

response = requests.post(
    'https://api.wahero.id/api/v1/messages/send',
    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

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