Skip to content

Authentication

All API requests must be authenticated using an API key. This guide covers how to generate and use API keys securely. Security

API integration settings

  1. Navigate to Settings

    Go to Settings → API Keys in your dashboard.

  2. Click Generate New Key

    Start the key generation process.

  3. Name your key

    Give it a descriptive name (e.g., “Production Server”, “Development”).

  4. Copy and store securely

    ⚠️ The key won’t be shown again! Store it immediately in a secure location.

Include your API key in the Authorization header of all requests:

Terminal window
curl -X POST https://api.mygptassistants.com/api/v1/chat/YOUR_BOT_ID/message \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Hello"}'

Read

View conversations and bot settings. Safe for analytics and monitoring.

Write

Send messages and update settings. Required for most integrations.

Admin

Full Access

Full access including key management. Use sparingly.

PermissionCapabilities
readView conversations, bot settings, analytics
writeSend messages, update settings, manage conversations
adminAll above + key management, team settings

Recommended for most cases

Terminal window
# .env file (never commit this!)
MGA_API_KEY=your_api_key_here
// Access in code
const apiKey = process.env.MGA_API_KEY;
  1. Go to Settings

    Navigate to Settings → API Keys.

  2. Find the key

    Locate the key you want to revoke in the list.

  3. Click Revoke

    Select the revoke option for that key.

  4. Confirm

    Verify you want to revoke the key.

  1. Create a new key

    Generate a new API key in your dashboard.

  2. Update applications

    Deploy the new key to all your applications.

  3. Verify functionality

    Ensure all integrations work with the new key.

  4. Revoke the old key

    Once confirmed, revoke the previous key.

Error CodeDescriptionSolution
401 UnauthorizedMissing or invalid API keyCheck header format
403 ForbiddenKey lacks required permissionUse key with correct permissions
429 Too Many RequestsRate limit exceededImplement backoff and retry

Environment Variables

Store keys in env vars, not code.

.gitignore

Ensure .env is in .gitignore.

Minimal Permissions

Use the least privilege needed.

Regular Rotation

Rotate keys every 90 days.