Authentication
Understand the two auth methods and when to use each. Read more →
This guide walks you through making your first two API calls: recording a consent decision for a user, then fetching that user’s consent status to confirm it was stored. You only need curl and the two values from your dashboard listed below.
display_id of a collection point you created in the dashboard (for example, signup-form or checkout-page)Get your API key
Log in to your truConsent dashboard and go to Settings → API Keys. Create a new key and copy it — the dashboard only shows it once.
All server-to-server requests must include this key in the X-API-Key header. Do not embed it in client-side code.
Record a consent decision
Call POST /consent/{collection_point_id}/consent with the user’s ID, their overall action, and a list of per-purpose decisions.
Replace your-collection-point-id with the display_id of your collection point, and your-api-key with the key you just copied.
curl -X POST https://api.truConsent.io/consent/your-collection-point-id/consent \ -H "X-API-Key: your-api-key" \ -H "Content-Type: application/json" \ -d '{ "userId": "user_123", "action": "approved", "purposes": [ { "id": "purpose_abc", "name": "Marketing", "consented": "approved", "is_mandatory": false } ] }'const response = await fetch('https://api.truConsent.io/consent/your-collection-point-id/consent', { method: 'POST', headers: { 'X-API-Key': 'your-api-key', 'Content-Type': 'application/json', }, body: JSON.stringify({ userId: 'user_123', action: 'approved', purposes: [ { id: 'purpose_abc', name: 'Marketing', consented: 'approved', is_mandatory: false, }, ], }),});const data = await response.json();import requests
response = requests.post( 'https://api.truConsent.io/consent/your-collection-point-id/consent', headers={ 'X-API-Key': 'your-api-key', 'Content-Type': 'application/json', }, json={ 'userId': 'user_123', 'action': 'approved', 'purposes': [ { 'id': 'purpose_abc', 'name': 'Marketing', 'consented': 'approved', 'is_mandatory': False, }, ], },)data = response.json()A successful response returns HTTP 201 with the created consent record:
{ "id": "c3d4e5f6-...", "action": "approved", "purpose_consents": [ { "purpose_id": "purpose_abc", "purpose_name": "Marketing", "status": "approved", "is_mandatory": false, "purpose_version": 1 } ], "timestamp": "2026-04-21T10:30:00.000Z"}Valid values for action are approved, declined, partial_consent, revoked, and no_action. The consented field on each purpose follows the same set of values.
Verify by fetching consent status
Call GET /consent/user-consent-status to retrieve the user’s full consent state across all collection points.
curl "https://api.truConsent.io/consent/user-consent-status?userId=user_123" \ -H "X-API-Key: your-api-key"const response = await fetch('https://api.truConsent.io/consent/user-consent-status?userId=user_123', { headers: { 'X-API-Key': 'your-api-key', },});const data = await response.json();import requests
response = requests.get( 'https://api.truConsent.io/consent/user-consent-status', headers={ 'X-API-Key': 'your-api-key', }, params={'userId': 'user_123'},)data = response.json()The response lists every collection point the user has a consent record for, along with the most recent decision for each:
{ "user_id": "user_123", "total_consents": 1, "collection_points": [ { "collection_point": { "id": "a1b2c3d4-...", "display_id": "your-collection-point-id", "name": "Sign-up Form", "description": null, "consent_type": "explicit" }, "latest_consent": { "id": "c3d4e5f6-...", "action": "approved", "purpose_consents": [...], "timestamp": "2026-04-21T10:30:00.000Z", "status": "pending", "request_id": "r7e8f9..." } } ], "timestamp": "2026-04-21T10:30:05.000Z"}If collection_points contains the record you just created, your integration is working.
Authentication
Understand the two auth methods and when to use each. Read more →
Consent model
Learn how collection points, purposes, and consent logs fit together. Read more →