Developer DocsAPI Reference
Consent
Record user consent decisions (accept/reject) for a project. Consent is evaluated in real time and affects tracking and downstream features.
Consent
POST /{orgName}/projects/{projectName}/consents/data
Records a user's consent decision for a project. Consent is evaluated in real time and affects tracking, communications, and downstream features.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
orgName | string | Yes | Organization slug/name — routes the request to the correct organization |
projectName | string | Yes | Project slug/name — consent is recorded under this project |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Intempt API key. Format: identifier.secret |
Request Body
Content-Type: application/json
Required Fields
| Field | Type | Description |
|---|---|---|
action | string | Consent decision: accept or reject |
timestamp | string | Event timestamp in milliseconds |
validUntil | string | Expiration timestamp in milliseconds, or "unlimited" for no expiry |
source | string | Origin of the consent — e.g. "desktop" or "mobile" |
Optional Fields
| Field | Type | Description |
|---|---|---|
category | string | Specific consent category (e.g. "analytics", "marketing"). If omitted, action applies to all consent types. |
userId | string | Unique user identifier for authorization |
email | string | User email for identification and communication |
message | string | Custom note for context or debugging |
Examples
Accept Analytics Consent — Desktop
const response = await fetch(
"https://api.intempt.com/{orgName}/projects/{projectName}/consents/data?apiKey=YOUR_API_KEY",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
action: "accept",
timestamp: String(Date.now()),
validUntil: String(Date.now() + 365 * 24 * 60 * 60 * 1000),
source: "desktop",
category: "analytics",
userId: "user@example.com",
email: "user@example.com",
message: "User accepted analytics consent on cookie banner"
})
}
);Records analytics consent from a desktop web user with 1-year validity.
Reject Marketing Consent — Mobile
const response = await fetch(
"https://api.intempt.com/{orgName}/projects/{projectName}/consents/data?apiKey=YOUR_API_KEY",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
action: "reject",
timestamp: String(Date.now()),
validUntil: "unlimited",
source: "mobile",
category: "marketing",
userId: "mobile.user@domain.com",
message: "User declined marketing notifications in app settings"
})
}
);Records a marketing consent rejection from a mobile app user with unlimited validity.
Responses
200 OK
{}400 Bad Request
{
"error": "Invalid request",
"message": "Required field 'action' is missing or invalid"
}