Skip to content

Creating an API Token

API tokens are used to authenticate your requests to the WhatGate API. This guide will show you how to create and manage your API tokens.

Prerequisites

Before you can create an API token, you need to:

  • Have an active WhatsGate account
  • Be logged in to your account

Creating a New Token

To create a new API token:

  1. Log in to your WhatGate dashboard
  2. Navigate to the "API Tokens" section in the sidebar
  3. Click the "Create Token" button
  4. Enter a name for your token (e.g., "Production API", "Testing", etc.)
  5. Click "Create" to generate your token

WARNING

Your token will only be shown once. Make sure to copy it and store it securely. If you lose your token, you'll need to create a new one.

Using Your Token

To use your API token, include it in the header of all your API requests:

Access-Token: your_api_token_here

Example Request (cURL)

bash
curl -X POST \
  https://{subdomain}.whatsgate.net/api/send/text \
  -H 'Access-Token: your_api_token_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "sender_device": "123456789",
    "phone": "987654321",
    "message": "Hello, this is a test message"
}'

Managing Your Tokens

You can manage your API tokens from the "API Tokens" section in your dashboard:

  • View tokens: See a list of all your active tokens
  • Regenerate tokens: Create a new token value for an existing token (invalidates the old token)
  • Delete tokens: Remove tokens you no longer need

TIP

Create separate tokens for different applications or environments. This makes it easier to manage access and revoke tokens if needed.

Security Best Practices

  • Keep your API tokens secure and never share them publicly
  • Store tokens in environment variables, not in your code
  • Regenerate tokens periodically for enhanced security
  • Delete unused tokens to minimize security risks

Next Steps

Now that you have created an API token, you can:

Released under the MIT License.