Skip to main content

API Overview

The LLMTAG plugin provides a comprehensive REST API for developers to integrate AI protection functionality into custom applications, external systems, and third-party tools.

REST API v1

Full CRUD OperationsWebhook SupportRate LimitingAuthenticationComprehensive Documentation

Authentication

API Key Authentication

All API requests require authentication using API keys:
1

Generate API Key

Go to LLMTAG > Settings > API and click Generate New Key
2

Configure Permissions

Set the permissions for your API key (read, write, admin)
3

Set Rate Limits

Configure rate limits for your API key
4

Test Authentication

Use the API key in your requests to verify authentication

Request Headers

Include the API key in your request headers:

Rate Limiting

API requests are rate-limited to prevent abuse:

Free Tier

Requests: 1,000 per hour Burst: 100 requests per minute Use for: Development, testing

Pro Tier

Requests: 10,000 per hour Burst: 500 requests per minute Use for: Production applications

Core Endpoints

Settings Management

Get Current Settings

Update Settings

Analytics Data

Get Analytics Summary

string
default:"24h"
Time period for analytics data. Options: 1h, 24h, 7d, 30d

Get Detailed Analytics

string
required
Start date for analytics data (ISO 8601 format)
string
required
End date for analytics data (ISO 8601 format)
string
Filter by specific AI agent
string
Filter by geographic location

AI Agent Management

Get Available Agents

Update Agent Status

llmtag.txt Management

Get Current llmtag.txt

Regenerate llmtag.txt

Webhook Integration

Webhook Configuration

Set up webhooks to receive real-time notifications:
1

Create Webhook

Go to LLMTAG > Settings > Webhooks and click Add Webhook
2

Configure Endpoint

Set the URL where webhook events should be sent
3

Select Events

Choose which events to receive notifications for
4

Set Authentication

Configure authentication for your webhook endpoint
5

Test Webhook

Send a test event to verify the webhook is working

Available Webhook Events

Agent Blocked

Triggered when an AI agent is blocked:

Settings Updated

Triggered when plugin settings are updated:

New Agent Detected

Triggered when a new AI agent is detected:

Webhook Security

Signature Verification

All webhooks include a signature for verification:

SDK and Libraries

JavaScript SDK

PHP SDK

Python SDK

Error Handling

Error Response Format

All API errors follow a consistent format:

Common Error Codes

Authentication Errors

  • INVALID_API_KEY
  • API_KEY_EXPIRED
  • INSUFFICIENT_PERMISSIONS

Validation Errors

  • INVALID_REQUEST
  • MISSING_REQUIRED_FIELD
  • INVALID_VALUE

Rate Limiting

  • RATE_LIMIT_EXCEEDED
  • QUOTA_EXCEEDED

Server Errors

  • INTERNAL_ERROR
  • SERVICE_UNAVAILABLE
  • DATABASE_ERROR

Error Handling Best Practices

1

Check HTTP Status Codes

Always check the HTTP status code before processing the response
2

Handle Rate Limiting

Implement exponential backoff for rate limit errors
3

Validate Responses

Validate API responses before using the data
4

Log Errors

Log API errors for debugging and monitoring

Testing and Development

API Testing

Using cURL

Using Postman

  1. Import the API collection from the plugin documentation
  2. Set your API key in the collection variables
  3. Test each endpoint to verify functionality

Development Environment

1

Set Up Local Environment

Install WordPress locally with the LLMTAG plugin
2

Enable Debug Mode

Enable WordPress debug mode for detailed error messages
3

Generate Test API Key

Create a test API key with full permissions
4

Test All Endpoints

Verify all API endpoints work correctly

Best Practices

API Usage

Use Appropriate HTTP Methods

Use GET for reading data, PUT for updates, POST for actions

Implement Caching

Cache API responses to reduce server load and improve performance

Handle Errors Gracefully

Implement proper error handling and user feedback

Respect Rate Limits

Implement rate limiting in your applications to avoid hitting API limits

Security

Always follow security best practices when using the API:
  • Secure API Keys: Store API keys securely and never expose them in client-side code
  • Use HTTPS: Always use HTTPS for API requests
  • Validate Input: Validate all input data before sending API requests
  • Monitor Usage: Monitor API usage for unusual patterns or abuse
  • Regular Rotation: Regularly rotate API keys for security

Performance

Follow these tips to optimize API performance:
  • Batch Requests: Combine multiple operations into single requests when possible
  • Use Pagination: Use pagination for large data sets
  • Implement Caching: Cache frequently accessed data
  • Monitor Response Times: Track API response times and optimize as needed
  • Use Webhooks: Use webhooks instead of polling for real-time updates