Terms of Service API Documentation
The Terms of Service (ToS) functionality enables service providers to define Terms of Service for their marketplace offerings and track user consent. If consent enforcement is active, users must accept the Terms of Service before accessing certain resources.
Overview
The Terms of Service system consists of three main components:
- Terms of Service Configurations - Service providers define ToS documents with versioning support
- User Consents - Users grant consent to specific ToS versions for offerings
- Consent Enforcement - System enforces consent requirements for resource access
Key Features
- Versioning: Track different versions of Terms of Service
- Re-consent Requirements: Force users to re-consent when ToS is updated
- Grace Periods: Allow time for users to update consent before access is revoked
- Consent Tracking: Comprehensive tracking of user consents and revocations
- Order Integration: Require ToS acceptance during order creation
Configuration
Enabling ToS Enforcement
ToS consent enforcement is controlled by the ENFORCE_USER_CONSENT_FOR_OFFERINGS setting. When enabled, users must have active consent to access resources from offerings that:
- Have active Terms of Service configured
- Have
service_provider_can_create_offering_userenabled in the offering's plugin options
API Endpoints
Terms of Service Management
Base URL: /api/marketplace-offering-terms-of-service/
List Terms of Service Configurations
Get all Terms of Service configurations visible to the current user.
1 2 | |
Permissions:
- Staff/Support: See all ToS configurations
- Service Providers: See ToS for their own offerings
- Regular Users: See ToS for offerings they've consented to or shared offerings
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
offering |
URL | Filter by offering URL |
offering_uuid |
UUID | Filter by offering UUID |
is_active |
Boolean | Filter by active status |
version |
String | Filter by version |
requires_reconsent |
Boolean | Filter by re-consent requirement |
o |
String | Order by (created, -created, modified, -modified, version, -version) |
Example Request:
1 | |
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Field Descriptions:
| Field | Type | Description |
|---|---|---|
uuid |
UUID | Unique identifier for the ToS configuration |
offering_uuid |
UUID | UUID of the associated offering |
offering_name |
String | Name of the offering |
terms_of_service |
String (HTML) | The Terms of Service content (HTML formatted) |
terms_of_service_link |
URL | Optional external link to Terms of Service |
version |
String | Version identifier (e.g., "1.0", "2.0") |
is_active |
Boolean | Whether this ToS configuration is currently active |
requires_reconsent |
Boolean | Whether users must re-consent when this version is active |
grace_period_days |
Integer | Number of days before outdated consents are revoked (only when requires_reconsent=True) |
user_consent |
Object/null | Current user's consent information (if any) |
has_user_consent |
Boolean | Whether current user has valid consent for this ToS version |
created |
DateTime | When the ToS configuration was created |
modified |
DateTime | When the ToS configuration was last modified |
Retrieve a Terms of Service Configuration
Get details of a specific ToS configuration.
1 2 | |
Response: Same structure as list endpoint, single object.
Create a Terms of Service Configuration
Create a new Terms of Service configuration for an offering.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Permissions Required:
UPDATE_OFFERINGpermission on the offering, its customer, or service provider
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
offering |
URL | Yes | URL to the offering |
terms_of_service |
String (HTML) | No | HTML content of the Terms of Service |
terms_of_service_link |
URL | No | External link to Terms of Service |
version |
String | No | Version identifier |
is_active |
Boolean | No | Whether to activate this ToS (default: false) |
requires_reconsent |
Boolean | No | Whether to require re-consent (default: false) |
grace_period_days |
Integer | No | Grace period in days (default: 60, only used when requires_reconsent=True) |
Validation Rules:
- Only one active ToS configuration is allowed per offering
- If
is_active=true, any existing active ToS for the offering must be deactivated first versionandrequires_reconsentcannot be changed after creation
Response: 201 Created with the created ToS configuration object.
Update a Terms of Service Configuration
Update an existing ToS configuration. This is intended for minor changes, major ToS changes must be done via creating a new ToS and requiring reconsent. Note that version and requires_reconsent are protected and cannot be changed.
1 2 3 4 5 6 7 8 9 10 | |
Permissions Required:
UPDATE_OFFERINGpermission on the offering's customer
Updatable Fields:
terms_of_serviceterms_of_service_linkis_activegrace_period_days
Protected Fields (cannot be changed):
versionrequires_reconsent
Delete a Terms of Service Configuration
Delete a ToS configuration. This is a hard delete.
1 2 | |
Permissions Required:
UPDATE_OFFERINGpermission on the offering's customer
User Consent Management
Base URL: /api/marketplace-user-offering-consents/
List User Consents
Get all consent records for the current user (or all consents for staff/support).
1 2 | |
Permissions:
- Regular Users: See only their own consents
- Staff/Support: See all consents
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
user |
URL | Filter by user URL |
user_uuid |
UUID | Filter by user UUID |
offering |
URL | Filter by offering URL |
offering_uuid |
UUID | Filter by offering UUID |
version |
String | Filter by ToS version |
has_consent |
Boolean | Filter by active consent status (true for active, false for revoked) |
requires_reconsent |
Boolean | Filter by whether re-consent is required |
Example Request:
1 | |
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Field Descriptions:
| Field | Type | Description |
|---|---|---|
uuid |
UUID | Unique identifier for the consent record |
user_uuid |
UUID | UUID of the user who granted consent |
username |
String | Username of the consenting user |
offering_uuid |
UUID | UUID of the offering |
offering_name |
String | Name of the offering |
agreement_date |
DateTime | When the consent was granted |
version |
String | Version of ToS that was consented to |
revocation_date |
DateTime/null | When the consent was revoked (if revoked) |
is_revoked |
Boolean | Whether the consent has been revoked |
created |
DateTime | When the consent record was created |
modified |
DateTime | When the consent record was last modified |
Retrieve a User Consent
Get details of a specific consent record.
1 2 | |
Response: Same structure as list endpoint, single object.
Grant Consent to Terms of Service
Create a consent record for the current user and a specific offering.
1 2 3 4 5 6 7 | |
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
offering |
UUID | Yes | UUID of the offering |
Validation:
- The offering must have active Terms of Service
- If user already has active consent for the current ToS version, returns an error
- If user has revoked consent, it will be reactivated with the current ToS version
Response: 201 Created with the consent record.
Behavior:
- If consent already exists (even if revoked), it will be reactivated and updated with the current ToS version
- The consent version is automatically set to match the active ToS version
Revoke Consent
Revoke a user's consent to Terms of Service.
1 2 | |
Permissions:
- Users can revoke their own consent
- Staff can revoke any consent
Response: 200 OK with updated consent record (now with revocation_date set).
Offering Statistics
Get ToS Consent Statistics
Get comprehensive consent statistics for a specific offering.
1 2 | |
Permissions Required:
UPDATE_OFFERINGpermission on the offering or its customer
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
Field Descriptions:
| Field | Type | Description |
|---|---|---|
active_users_count |
Integer | Number of users with active consent |
total_users_count |
Integer | Total number of users for the offering |
active_users_percentage |
Float | Percentage of users with active consent |
accepted_consents_count |
Integer | Total number of accepted consents |
revoked_consents_count |
Integer | Total number of revoked consents |
total_consents_count |
Integer | Total number of consent records |
revoked_consents_over_time |
Array | Time series of revoked consents |
tos_version_adoption |
Array | Distribution of users across ToS versions |
active_users_over_time |
Array | Time series of active users |
Order Integration
When creating an order for an offering with Terms of Service, you must include the accepting_terms_of_service field.
Create Order with ToS Acceptance
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
accepting_terms_of_service |
Boolean | Conditional | Must be true if offering has ToS |
Validation:
- If the offering has active Terms of Service,
accepting_terms_of_servicemust betrue - If provided as
true, a consent record is automatically created for the user - If the user already has active consent, the order proceeds normally
Workflows
Service Provider: Setting Up Terms of Service
- Create ToS Configuration
1 2 3 4 5 6 7 8 | |
- Update ToS (Requiring Re-consent)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
- Monitor Consent Statistics
1 | |
User: Granting Consent
- Check if Offering Requires ToS
1 | |
Check the has_terms_of_service field in the response.
- View Terms of Service
1 | |
- Grant Consent
1 2 3 4 | |
- Create Order (Consent Included)
1 2 3 4 5 6 | |
User: Re-consenting After ToS Update
- Check Consent Status
1 | |
Check if requires_reconsent filter returns the consent.
- View Updated ToS
1 | |
- Grant New Consent
1 2 3 4 | |
This will update the existing consent with the new version.
Permission Model
Terms of Service Management
- Create/Update/Delete ToS: Requires
UPDATE_OFFERINGpermission on: - The offering itself, OR
- The offering's customer, OR
- The offering's customer's service provider
User Consent
- View Consents:
- Users can see their own consents
- Staff/Support can see all consents
- Grant Consent: Users can grant consent for themselves
- Revoke Consent:
- Users can revoke their own consent
- Staff can revoke any consent
Grace Periods
When requires_reconsent=True is set on a ToS configuration:
- Grace Period: Users have
grace_period_days(default: 60) to update their consent - During Grace Period: Users retain access even with outdated consent
- After Grace Period: Users lose access if consent version doesn't match active ToS version
- Automatic Enforcement: The system checks consent version when accessing resources
Best Practices
For Service Providers
- Version Management
- Use semantic versioning (e.g., "1.0", "2.0", "2.1")
- Document changes between versions
- Set appropriate grace periods for major updates
-
Major ToS revisions require creating a new ToS object
-
Re-consent Strategy
- Use
requires_reconsent=truefor significant changes - Provide adequate grace periods (60+ days recommended)
-
Communicate ToS updates to users proactively
-
Content Guidelines
- Keep Terms of Service clear and concise
- Use HTML formatting for better readability
-
Consider providing both inline content and external link
-
Monitoring
- Regularly check consent statistics
- Monitor grace period expirations
- Follow up with users who haven't re-consented
Related Endpoints
- Offerings:
/api/marketplace-provider-offerings/- Checkhas_terms_of_servicefield - Orders:
/api/marketplace-orders/- Includeaccepting_terms_of_servicewhen creating orders - Resources: Resource access is automatically enforced based on consent status
Configuration Settings
ENFORCE_USER_CONSENT_FOR_OFFERINGS: Global setting to enable/disable ToS consent enforcement- Only applies to offerings with
service_provider_can_create_offering_userenabled in plugin options