Get your API credentials
-
Generate API keys
Sign in to https://platform-dev.truconsent.io and go to Settings → API Settings.
Two key scopes are needed:
Scope Used for Admin-scope key Fetching your assetIdfrom the Management API (setup only)Consent-scope key Runtime calls made by the cookie banner SDK - Click Generate API Key, select Admin scope — save as
VITE_TRU_CONSENT_ADMIN_API_KEY. - Generate a second key, select Consent scope — save as
VITE_TRU_CONSENT_API_KEY.
- Click Generate API Key, select Admin scope — save as
-
Copy your organisation ID
On the same API Settings page, copy the Organization ID value.
Save it as
VITE_TRU_CONSENT_ORGANIZATION_ID. -
Add allowed domains
Under Allowed Domains, add every origin where the banner will run — for example
localhost:5173for development andyoursite.comfor production.Requests from unlisted domains are rejected with
403 Forbidden. -
Fetch your asset ID
An asset represents your registered website in truConsent. Fetch all assets using your admin-scope key and org ID:
Terminal window curl -X GET "https://truapi-dev.truconsent.io/api/v1/external/public/assets" \-H "X-API-Key: $VITE_TRU_CONSENT_ADMIN_API_KEY" \-H "X-Org-Id: $VITE_TRU_CONSENT_ORGANIZATION_ID"const response = await fetch("https://truapi-dev.truconsent.io/api/v1/external/public/assets",{headers: {"X-API-Key": import.meta.env.VITE_TRU_CONSENT_ADMIN_API_KEY,"X-Org-Id": import.meta.env.VITE_TRU_CONSENT_ORGANIZATION_ID,},});const { data } = await response.json();interface Asset {id: string;name: string;asset_type: string;}const response = await fetch("https://truapi-dev.truconsent.io/api/v1/external/public/assets",{headers: {"X-API-Key": import.meta.env.VITE_TRU_CONSENT_ADMIN_API_KEY,"X-Org-Id": import.meta.env.VITE_TRU_CONSENT_ORGANIZATION_ID,},});const { data }: { data: Asset[] } = await response.json();import osimport requestsurl = "https://truapi-dev.truconsent.io/api/v1/external/public/assets"headers = {"X-API-Key": os.environ["VITE_TRU_CONSENT_ADMIN_API_KEY"],"X-Org-Id": os.environ["VITE_TRU_CONSENT_ORGANIZATION_ID"],}response = requests.get(url, headers=headers)data = response.json()["data"]Sample response:
{"data": [{"asset_type": "Web App","name": "Main Marketing Website","id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","description": "Primary customer-facing website"}],"count": 1}Copy the
idof the asset that matches your website — this is yourassetId.Save it as
VITE_TRU_CONSENT_ASSET_ID.
Result
Section titled “Result”Your .env should now have all five values:
# truConsent cookie bannerVITE_TRU_CONSENT_API_URL=https://trukit-dev.truconsent.ioVITE_TRU_CONSENT_MANAGEMENT_API_URL=https://truapi-dev.truconsent.ioVITE_TRU_CONSENT_ORGANIZATION_ID=your-org-idVITE_TRU_CONSENT_ADMIN_API_KEY=your-admin-scope-keyVITE_TRU_CONSENT_API_KEY=your-consent-scope-keyVITE_TRU_CONSENT_ASSET_ID=your-asset-id