PolicyForge Consent API
Record and retrieve user consent for compliance audits
Record and retrieve user consent for compliance audits
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/policyforge-co:policyforge-co-consent-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: PolicyForge Consent API
description: 'AI-assisted policy workflow API. Generate, retrieve, update, and host policy drafts programmatically, and manage consent records. Generated content is not legal advice and should be reviewed before publication.
## Authentication
Operations require a Bearer token unless they explicitly declare no security requirement. Generate an API key from your PolicyForge API Dashboard. Keys are prefixed with `pf_live_`.
## Rate Limits
| Tier | Requests/min | Requests/day |
|------|-------------|-------------|
| Free | 10 | 100 |
| Pro | 60 | 5,000 |
| Enterprise | 300 | 50,000 |
Rate limit headers (`X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`) are included in every response.'
version: 1.0.0
contact:
name: PolicyForge Support
url: https://policyforge.co
email: support@policyforge.co
license:
name: Proprietary
servers:
- url: https://policyforge.co
description: Production
security:
- BearerAuth: []
tags:
- name: Consent
description: Record and retrieve user consent for compliance audits
paths:
/api/v1/consent:
post:
operationId: recordConsent
summary: Record user consent
description: Record a website visitor's consent preferences. Use this to track which cookie/data categories a visitor has accepted or rejected. The consent record is stored and can be retrieved later for compliance audits.
tags:
- Consent
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentCreateRequest'
examples:
tos_at_checkout:
summary: ToS at checkout (linked to a specific policy)
value:
user_id: user_47821
policy_version: v2.1
policy_id: 8331bf67-3748-471f-b595-9ba55a972cd5
consents:
tos: true
marketing: false
ip_address: 203.0.113.42
user_agent: Mozilla/5.0...
full_consent:
summary: Visitor accepts all cookie categories
value:
user_id: visitor_abc123
policy_version: v2.1
consents:
essential: true
analytics: true
marketing: true
ip_address: 203.0.113.42
user_agent: Mozilla/5.0...
partial_consent:
summary: Visitor accepts only essential
value:
user_id: visitor_xyz789
policy_version: v2.1
consents:
essential: true
analytics: false
marketing: false
responses:
'200':
description: Consent recorded
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentResponse'
'400':
description: Missing required fields
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/RateLimited'
get:
operationId: listConsent
summary: List consent records
description: 'List all consent records for the authenticated API key owner, paginated and filterable. Returns consents recorded via both the embeddable banner (`source: "banner"`) and the POST /api/v1/consent API (`source: "api"`). Use the cursor returned in `next_cursor` to page.'
tags:
- Consent
parameters:
- name: from
in: query
required: false
schema:
type: string
format: date-time
description: Lower bound on `recorded_at` (ISO 8601). Inclusive.
- name: to
in: query
required: false
schema:
type: string
format: date-time
description: Upper bound on `recorded_at` (ISO 8601). Inclusive.
- name: end_user_id
in: query
required: false
schema:
type: string
description: Filter to a single end-user. Equivalent to GET /api/v1/consent/{userId} but with the same paginated shape.
- name: policy_version
in: query
required: false
schema:
type: string
description: Filter by the `policy_version` stamp recorded with each consent.
- name: policy_id
in: query
required: false
schema:
type: string
format: uuid
description: Filter to consents for a specific policy. Set on banner consents (when the banner is linked to a cookie policy), hosted-policy 'I Agree' clicks, and API-recorded consents that included a policy_id.
- name: banner_config_id
in: query
required: false
schema:
type: string
format: uuid
description: Filter to consents recorded via a specific consent banner.
- name: source
in: query
required: false
schema:
type: string
enum:
- banner
- api
description: Filter by source. `banner` = recorded via the embeddable cookie banner. `api` = recorded via POST /api/v1/consent (e.g. ToS-at-checkout).
- name: limit
in: query
required: false
schema:
type: integer
minimum: 1
maximum: 200
default: 50
description: Page size. Max 200.
- name: cursor
in: query
required: false
schema:
type: string
description: Opaque cursor returned as `next_cursor` in the previous page. Pass it back to fetch the next page. Stable across same-timestamp rows.
responses:
'200':
description: Paginated list of consent records
content:
application/json:
schema:
type: object
properties:
consent_records:
type: array
items:
$ref: '#/components/schemas/ConsentRecord'
page_size:
type: integer
description: Number of records returned in this page.
limit:
type: integer
description: Limit applied to this query.
total_count:
type:
- integer
- 'null'
description: Total matching records across all pages.
next_cursor:
type:
- string
- 'null'
description: Cursor to pass back as `?cursor=` for the next page. `null` when there are no more pages.
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/RateLimited'
/api/v1/consent/{userId}:
get:
operationId: getConsent
summary: Get consent records for a user
description: Retrieve all consent records for a specific website visitor. Use this for compliance audits to prove consent was obtained.
tags:
- Consent
parameters:
- name: userId
in: path
required: true
schema:
type: string
description: The website visitor's identifier (as provided when recording consent)
responses:
'200':
description: Consent records
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentListResponse'
'400':
description: User ID required
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/RateLimited'
delete:
operationId: deleteConsentRecord
summary: Delete a consent record
description: Permanently delete one consent record owned by your account, for example to honour an erasure request. For this method the path segment is the consent record id (UUID) returned when the consent was recorded or listed, not the end user id.
tags:
- Consent
parameters:
- name: userId
in: path
required: true
schema:
type: string
format: uuid
description: The consent record id (UUID)
responses:
'200':
description: Consent record deleted
content:
application/json:
schema:
type: object
properties:
id:
type: string
format: uuid
status:
type: string
example: deleted
'400':
description: Record id missing or not a UUID
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'429':
$ref: '#/components/responses/RateLimited'
/api/v1/consent/policy/{policyId}/record:
post:
operationId: recordHostedPolicyConsent
summary: Record hosted-policy consent (public, no API key)
description: 'Records a consent event for a hosted policy. This is the same endpoint our hosted-policy ''I Agree'' button calls; it is also useful for custom checkout pages that link out to your hosted policy and want to log the consent without minting an API key on the client.
**No authentication required.** The owner is discovered from the policy itself. CORS is fully open. The policy must have hosting enabled.
Records land in the unified `consent_records` table and are retrievable via `GET /api/v1/consent?policy_id=...`.'
tags:
- Consent
security: []
parameters:
- name: policyId
in: path
required: true
schema:
type: string
format: uuid
description: UUID of a published, hosting-enabled policy.
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
end_user_id:
type: string
description: Stable visitor identifier. If omitted, a UUID is generated server-side. Persist this client-side (e.g. localStorage) so re-visits stitch.
consents:
type: object
additionalProperties:
type: boolean
description: 'Defaults to `{ "policy": true }`. Override for finer-grained consent boxes.'
policy_version:
type: string
description: Defaults to a slug derived from `policies.updated_at`, tying the record to the wording in force at click time (GDPR Art. 7(1)).
examples:
default:
summary: Default I Agree click
value:
end_user_id: eu-l8g4q7y2-x9k3p1m
with_granular_consents:
summary: Granular consent (custom checkout flow)
value:
end_user_id: user_47821
consents:
tos: true
marketing: false
responses:
'200':
description: Consent recorded
content:
application/json:
schema:
type: object
properties:
id:
type: string
format: uuid
end_user_id:
type: string
recorded_at:
type: string
format: date-time
policy_version:
type: string
'400':
description: Missing or invalid policy ID
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'403':
description: Policy is not hosted
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Policy not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
responses:
RateLimited:
description: Rate limit exceeded
headers:
X-RateLimit-Limit:
schema:
type: integer
description: Maximum requests per window
X-RateLimit-Remaining:
schema:
type: integer
description: Remaining requests in current window
X-RateLimit-Reset:
schema:
type: integer
description: Unix timestamp when the rate limit resets
content:
application/json:
schema:
$ref: '#/components/schemas/RateLimitError'
Unauthorized:
description: Missing or invalid API key
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Missing or invalid API key
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Policy not found
schemas:
ConsentResponse:
type: object
properties:
id:
type: string
user_id:
type: string
policy_version:
type: string
policy_id:
type:
- string
- 'null'
format: uuid
description: Echoes the policy_id from the request, or null if none was provided.
consents:
type: object
additionalProperties:
type: boolean
recorded_at:
type: string
format: date-time
status:
type: string
example: recorded
ConsentCreateRequest:
type: object
required:
- user_id
- policy_version
- consents
properties:
user_id:
type: string
description: Your website visitor's unique identifier
example: visitor_abc123
policy_version:
type: string
description: Version of the privacy policy the consent applies to
example: v2.1
consents:
type: object
additionalProperties:
type: boolean
description: Map of consent categories to accepted/rejected status
example:
essential: true
analytics: true
marketing: false
ip_address:
type: string
description: Visitor's IP address (for audit trail)
user_agent:
type: string
description: Visitor's browser user agent (for audit trail)
policy_id:
type: string
format: uuid
description: Optional. UUID of a PolicyForge policy this consent ties to. Must be a policy owned by the same account as the API key, or the request returns 404. Setting this lets the consent show up under the policy's analytics card and be filterable via `GET /api/v1/consent?policy_id=...`.
ConsentListResponse:
type: object
properties:
user_id:
type: string
consent_records:
type: array
items:
$ref: '#/components/schemas/ConsentResponse'
total_records:
type: integer
ConsentRecord:
type: object
description: A single consent record as returned by the list endpoint.
properties:
id:
type: string
format: uuid
user_id:
type: string
description: End-user / visitor identifier (this is `end_user_id` in the database).
policy_version:
type: string
description: Policy version stamp captured at consent time.
consents:
type: object
additionalProperties:
type: boolean
ip_address:
type:
- string
- 'null'
user_agent:
type:
- string
- 'null'
source:
type: string
enum:
- banner
- api
description: '`banner` = recorded via the embeddable cookie banner. `api` = recorded via POST /api/v1/consent or a hosted-policy ''I Agree'' click.'
banner_config_id:
type:
- string
- 'null'
format: uuid
description: Set when `source` is `banner`. `null` for API-recorded consents.
policy_id:
type:
- string
- 'null'
format: uuid
description: Set when the consent is tied to a specific PolicyForge policy (cookie banner with a linked policy, hosted-policy 'I Agree', or API consent that included a policy_id).
recorded_at:
type: string
format: date-time
ErrorResponse:
type: object
properties:
error:
type: string
description: Error message
details:
description: Additional error details (string or array of strings)
RateLimitError:
type: object
properties:
error:
type: string
example: Rate limit exceeded
retry_after:
type: integer
description: Seconds until the rate limit resets
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: 'API key from your PolicyForge dashboard. Keys are prefixed with `pf_`. Example: `pf_abc123def456...`'