Intempt Docs
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

ParameterTypeRequiredDescription
orgNamestringYesOrganization slug/name — routes the request to the correct organization
projectNamestringYesProject slug/name — consent is recorded under this project

Query Parameters

ParameterTypeRequiredDescription
apiKeystringYesIntempt API key. Format: identifier.secret

Request Body

Content-Type: application/json

Required Fields

FieldTypeDescription
actionstringConsent decision: accept or reject
timestampstringEvent timestamp in milliseconds
validUntilstringExpiration timestamp in milliseconds, or "unlimited" for no expiry
sourcestringOrigin of the consent — e.g. "desktop" or "mobile"

Optional Fields

FieldTypeDescription
categorystringSpecific consent category (e.g. "analytics", "marketing"). If omitted, action applies to all consent types.
userIdstringUnique user identifier for authorization
emailstringUser email for identification and communication
messagestringCustom note for context or debugging

Examples

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.

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"
}

On this page