Skip to content

Create a consent link

POST /api/consent/consent-links


This endpoint accepts two authentication methods. Use whichever fits your integration:

MethodHeaderWhen to use
Bearer tokenAuthorization: Bearer <token>Dashboard user session token — typically used from the dashboard or when calling on behalf of a logged-in user.
API keyX-API-Key: <key>Server-to-server calls from your backend. Requires a key with the consent (or admin) scope.

To generate an API key, go to Settings → API Settings in the truConsent dashboard. See Get API key and org ID for step-by-step instructions.


Terminal window
curl -X POST "https://api.truconsent.io/api/consent/consent-links" \
-H "Authorization: Bearer YOUR_SESSION_TOKEN" \
-H "X-Org-Id: YOUR_ORG_ID" \
-H "Content-Type: application/json" \
-d '{
"collection_point_id": "550e8400-e29b-41d4-a716-446655440000",
"asset_id": "79bf87f5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"phone": "+919876543210",
"expiry_hours": 24
}'

Terminal window
curl -X POST "https://api.truconsent.io/api/consent/consent-links" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Org-Id: YOUR_ORG_ID" \
-H "Content-Type: application/json" \
-d '{
"collection_point_id": "550e8400-e29b-41d4-a716-446655440000",
"asset_id": "79bf87f5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"phone": "+919876543210",
"expiry_hours": 24
}'

* Required
FieldTypeDescription
collection_point_id *UUID or stringUUID of the collection point, or its display_id (e.g. CP010).
asset_id *UUIDAsset the collection point belongs to. Must match the collection point’s asset.
phone *stringData principal’s phone number. Use E.164 format (+919876543210) or a 10-digit number (automatically prefixed with +91).
emailstringIf provided, a branded consent email is also sent to this address.
expiry_hoursintegerHow long the link stays valid. Defaults to 24. Maximum 24.
data_collection_timestampISO 8601 datetimeWhen the underlying data was originally collected. Defaults to the current time.

Link created successfully. The consent_link is ready to send to the data principal.

{
"request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"event_id": "e5f6a7b8-c9d0-1234-efab-567890abcdef",
"consent_link": "{COLLECTOR_BASE_URL}/your-subdomain/CP010/e5f6a7b8-c9d0-1234-efab-567890abcdef",
"expires_at": "2025-05-13T10:00:00+00:00",
"delivery_status": {}
}

When email is provided, delivery_status contains the send result:

{
"request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"event_id": "e5f6a7b8-c9d0-1234-efab-567890abcdef",
"consent_link": "{COLLECTOR_BASE_URL}/your-subdomain/CP010/e5f6a7b8-c9d0-1234-efab-567890abcdef",
"expires_at": "2025-05-13T10:00:00+00:00",
"delivery_status": { "email": "sent" }
}
FieldDescription
consent_linkThe URL to share with the data principal. Format: {base}/{org-subdomain}/{cp-display-id}/{event-id}.
event_idUnique ID for this consent event. Use it to query the audit log.
request_idUnique ID for this link request.
expires_atISO 8601 UTC timestamp after which the link is no longer valid.
delivery_statusEmpty {} when no email was given. {"email": "sent"} or {"email": "failed"} when email was provided.