Documentation

Authentication

How to authenticate with the Chatbase API using API keys

Authentication

The Chatbase API uses Bearer token authentication. Every request must include your API key in the Authorization header.


Getting Your API Key

  1. Log in to your CRM dashboard
  2. Navigate to API Manage in the sidebar
  3. Click Create API Client
  4. Enter a descriptive name (e.g. production-server, crm-integration)
  5. Optionally set IP allowlist and route restrictions
  6. Click Create — copy the key immediately, it is shown only once

Using the API Key

Include the key as a Bearer token in every request:

Authorization: Bearer wpapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

cURL example

curl https://chatbase.in/api/v1/whatsapp/me \
  -H "Authorization: Bearer wpapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

JavaScript (fetch)

const response = await fetch('https://chatbase.in/api/v1/whatsapp/messages/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer wpapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    to: '919876543210',
    type: 'text',
    text: { body: 'Hello from Chatbase API!' },
  }),
});

Node.js (axios)

const axios = require('axios');

const api = axios.create({
  baseURL: 'https://chatbase.in/api/v1/whatsapp',
  headers: {
    Authorization: 'Bearer wpapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  },
});

const { data } = await api.post('/messages/send', {
  to: '919876543210',
  type: 'text',
  text: { body: 'Hello from Chatbase!' },
});

Key Properties

PropertyDescription
NameHuman-readable label for the client
Project IDIdentifies which WhatsApp Business account to use
Allowed IPsRestrict requests to specific IP addresses (optional)
Allowed RoutesRestrict which API endpoints the key can access (optional)
Rate LimitMaximum requests per minute (set by your plan)

Rotating Keys

If a key is compromised, go to API Manage → find the client → click Rotate Key. The old key is immediately invalidated and a new key is shown once.


Security Best Practices

  • Never expose your API key in client-side code (browser JavaScript, mobile apps)
  • Store keys in environment variables, not source code
  • Use IP allowlists in production
  • Create separate API clients for each environment (dev, staging, production)
  • Rotate keys periodically and immediately if suspected compromise

Error Responses

StatusMeaning
401 UnauthorizedMissing or malformed Authorization header
403 ForbiddenValid key but access denied (IP/route restriction, feature not in plan)
429 Too Many RequestsRate limit exceeded — back off and retry