TagConsent API Documentation

DPDP Act 2023 compliant consent management platform API

The TagConsent API allows you to programmatically manage consent collection, track analytics, configure webhooks, and generate compliance reports. All API endpoints are served over HTTPS from https://tagconsent.com/api.

Authentication

All API requests require authentication via a Bearer token in the Authorization header.

Authorization: Bearer YOUR_API_TOKEN

Obtain your token by logging in via the dashboard or the login endpoint:

POST/api/auth/login
Authenticate and receive a JWT token
{
  "email": "[email protected]",
  "password": "your_password"
}

Quick Start

Add the TagConsent banner to your website with one line of code:

<script src="https://tagconsent.com/sdk/consent.js"
  data-domain-id="YOUR_DOMAIN_ID"></script>

That's it! The consent banner will automatically appear for new visitors. You can customize the banner's appearance, position, and behavior from the dashboard.

POST/api/consent
Record a new consent action
ParameterTypeRequiredDescription
domain_idUUIDRequiredDomain identifier
actionStringRequiredaccept, reject, withdraw
categoriesArrayOptionalConsent categories: necessary, analytics, marketing, preferences
countryStringOptionalISO 3166-1 country code
gpc_signalBooleanOptionalGlobal Privacy Control signal detected
GET/api/consent/:id
Retrieve a specific consent record
POST/api/consent/:id/withdraw
Withdraw a previously given consent

Domains API

GET/api/domains
List all domains for your organization
POST/api/domains
Register a new domain
{
  "domain": "example.com",
  "framework": "dpdp"
}
PUT/api/domains/:id/banner
Update banner configuration for a domain
{
  "primaryColor": "#D97706",
  "theme": "light",
  "position": "bottom",
  "layout": "box",
  "language": "en",
  "showDeclineAll": true,
  "showPreferences": true,
  "respectGPC": true,
  "autoBlockCookies": true
}

Analytics API

GET/api/analytics/trends?period=30d
Consent trends over time
GET/api/analytics/breakdown?period=30d
Consent action breakdown (accept/reject/withdraw)
GET/api/analytics/geo?period=30d
Geographic distribution of consents
GET/api/analytics/export?period=30d
Export consent data as CSV

Available periods: 7d, 30d, 90d, 12m

Webhooks API

GET/api/webhooks
List all webhook endpoints
POST/api/webhooks
Create a new webhook endpoint
{
  "url": "https://your-app.com/webhook",
  "description": "My integration",
  "events": ["consent.given", "consent.withdrawn"]
}

Supported Events

EventDescription
consent.givenUser accepted cookies/consent
consent.withdrawnUser withdrew their consent
consent.updatedUser changed consent preferences
domain.addedNew domain registered
domain.removedDomain removed
user.createdTeam member added
user.deletedTeam member removed
data_erasure.requestedData erasure request received
data_erasure.completedData erasure completed
POST/api/webhooks/:id/test
Send a test webhook delivery
POST/api/webhooks/:id/rotate-secret
Rotate the webhook signing secret

Billing API

GET/api/billing/plans
List available subscription plans (public, no auth required)
GET/api/billing/subscription
Get current subscription details
GET/api/billing/usage
Get current billing period usage

Audit Reports API

GET/api/audit-reports/compliance?period=30d
Generate DPDP compliance audit report
GET/api/audit-reports/export?period=30d
Export audit data as CSV

JavaScript SDK

The TagConsent JavaScript SDK provides a simple way to integrate consent management into your website.

Installation

<script src="https://tagconsent.com/sdk/consent.js"
  data-domain-id="YOUR_DOMAIN_ID"></script>

Programmatic API

// Check if user has given consent
TagConsent.hasConsent('analytics'); // true/false

// Get all consent preferences
TagConsent.getPreferences();
// { necessary: true, analytics: true, marketing: false, preferences: true }

// Listen for consent changes
TagConsent.on('consent', function(data) {
  console.log('Consent updated:', data.action, data.categories);
});

// Show the consent banner programmatically
TagConsent.show();

// Withdraw consent
TagConsent.withdraw();

Webhook Security

Every webhook delivery includes a signature header for verification:

X-TagConsent-Signature: v1=<hmac_sha256_hex>
X-TagConsent-Timestamp: <unix_timestamp>
X-TagConsent-Event: consent.given

Verifying Signatures (Node.js)

const crypto = require('crypto');

function verifyWebhook(payload, signature, timestamp, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(timestamp + '.' + payload)
    .digest('hex');
  return 'v1=' + expected === signature;
}

// In your Express handler:
app.post('/webhook', (req, res) => {
  const sig = req.headers['x-tagconsent-signature'];
  const ts = req.headers['x-tagconsent-timestamp'];

  if (!verifyWebhook(JSON.stringify(req.body), sig, ts, WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature');
  }

  // Process the event
  console.log('Event:', req.body.event);
  res.status(200).send('OK');
});

Error Codes

CodeDescription
400Bad Request — invalid parameters
401Unauthorized — invalid or missing token
403Forbidden — insufficient permissions
404Not Found — resource does not exist
429Too Many Requests — rate limit exceeded
500Internal Server Error

Rate Limits

EndpointLimitWindow
Login10 requests15 minutes
Registration5 requests1 hour
Password Reset5 requests15 minutes
General API100 requests1 minute
Need help? Contact us at [email protected] or visit the dashboard for live support.