> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chamelio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Clickwrap

> Retrieve the active clickwrap content, with optional template variables to personalize the text presented to an end user

> [!TIP]
>
> Adding Clickwrap to your website or app? [Embed a clickwrap in your website or app](https://docs.chamelio.ai/guides/integrations/embed-clickwrap.md) walks through it step by step with the browser SDK. Use this endpoint from your server.

## Endpoint

```
GET /v2/server/clickwrap/{slug}
```

## Authentication

This endpoint requires an OAuth access token. Send it as a bearer token:

```bash theme={null}
Authorization: Bearer your_access_token
```

**Required scope:** `clickwrap:read`

> [!NOTE]
>
> Clickwrap is the one `/v2` surface with no acting user. The subject of a clickwrap event is
> `user_identifier`, an opaque string you supply for your own end user, which is never resolved
> against Chamelio's users. These endpoints are authorized by organization and scope alone, so
> `client_credentials` tokens work here without restriction.

## Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `slug` | string | Yes | Unique identifier for the clickwrap |

## Query Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `variables` | string | No | A JSON-encoded object mapping placeholder names to plain-text string values, for example `{"company_name":"Acme"}`. URL-encode the JSON string when adding it to the query |

For a template containing `{{company_name}}`, the examples below return content with `Acme` in
that position. Omit `variables` to retrieve the template without substitutions.

## Request Example

```bash cURL theme={null}
curl --get "https://platform.chamelio.ai/v2/server/clickwrap/privacy-policy" \
  -H "Authorization: Bearer your_access_token" \
  --data-urlencode 'variables={"company_name":"Acme"}'
```

```python Python theme={null}
import json
import requests

slug = "privacy-policy"

url = f"https://platform.chamelio.ai/v2/server/clickwrap/{slug}"
headers = {
    "Authorization": "Bearer your_access_token"
}

params = {"variables": json.dumps({"company_name": "Acme"})}

response = requests.get(url, headers=headers, params=params)
print(response.json())
```

```javascript JavaScript theme={null}
const slug = "privacy-policy";
const params = new URLSearchParams({
  variables: JSON.stringify({ company_name: 'Acme' })
});

const response = await fetch(
  `https://platform.chamelio.ai/v2/server/clickwrap/${slug}?${params}`,
  {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer your_access_token'
    }
  }
);

const data = await response.json();
console.log(data);
```

## Response

### Success Response

**Status Code:** `200 OK`

```json theme={null}
{
  "slug": "privacy-policy",
  "title": "Privacy Policy",
  "clickwrap_type": "click_to_accept",
  "content": "Acme agrees to our Privacy Policy by clicking Accept.",
  "content_html": "<p>Acme agrees to our Privacy Policy by clicking Accept.</p>",
  "clickwrap_version_id": 42,
  "version_number": 3
}
```

### Response Fields

| Field | Type | Description |
| - | - | - |
| `slug` | string | Unique clickwrap identifier |
| `title` | string | Human-readable title of the clickwrap |
| `clickwrap_type` | string | Presentation type: `click_to_accept` or `scroll_and_accept` |
| `content` | string | Content of the active version with the supplied variables rendered as escaped text |
| `content_html` | string or null | Sanitized HTML content of the active version with the supplied variables rendered in text nodes |
| `clickwrap_version_id` | integer | Internal identifier for the active version |
| `version_number` | integer | Sequential version number of the active version |

## Error Responses

### 401 Unauthorized

Returned when the access token is missing, unknown, revoked, or expired, or when an `X-API-Key` was
sent instead of a bearer token. See [OAuth error responses](https://docs.chamelio.ai/api-reference/oauth-apps.md#error-responses).

```json theme={null}
{
  "detail": "Invalid access token"
}
```

### 403 Forbidden

Returned when the token does not carry the required scope.

```json theme={null}
{
  "detail": "Insufficient scope; this endpoint requires: clickwrap:read"
}
```

### 404 Not Found

Returned when no active clickwrap exists for the given slug.

```json theme={null}
{
  "detail": "Not found"
}
```

### 422 Unprocessable Entity

Returned when `variables` is malformed JSON, is not a JSON object, or contains a value that is
not a string. For example, use `{"company_name":"Acme"}`, not `{"company_name":123}`.

### 429 Too Many Requests

Returned when your organization exceeds its per-minute request limit.

```json theme={null}
{
  "detail": "Rate limit exceeded"
}
```

### 500 Internal Server Error

Returned when the request fails due to a server error.

```json theme={null}
{
  "detail": "Failed to fetch clickwrap"
}
```

## Notes

> [!NOTE]
>
> This endpoint only returns the **active** (published) version. Draft versions are never exposed on
> externally authenticated endpoints.

> [!NOTE]
>
> The active template and version are organization-global. Requests with the same variables return
> the same content for every token issued for that organization. The token's user is used only to
> authenticate and scope-check the request.

### Template Variables

Placeholders use double braces with no spaces, such as `{{company_name}}`. Names are case-sensitive,
start with a letter or underscore, and contain only letters, numbers, or underscores
(`[A-Za-z_][A-Za-z0-9_]*`). A placeholder without a supplied value stays unchanged.

Values are plain text, escaped for the returned content. HTML values do not create markup.
In `content_html`, substitutions apply to text nodes, leaving HTML tags and attributes unchanged.
In `content`, Markdown link destinations, raw HTML tags, and URLs are left unchanged.
Rendering changes the response only, leaving the stored template and its version unchanged.

> [!TIP]
>
> This GET request does not save the variables. Send the same values in the `variables` body field
> when you [capture acceptance](https://docs.chamelio.ai/api-reference/endpoint/v2/clickwrap/capture.md). The acceptance PDF
> combines those values with the version recorded by capture. Capture targets the active version
> at capture time, which can differ from the version fetched here. If a new version becomes active,
> fetch and present it and record its required interaction events before capturing acceptance.

> [!TIP]
>
> Use the returned `clickwrap_version_id` and `version_number` to correlate displayed content with
> [Check Clickwrap Status](https://docs.chamelio.ai/api-reference/endpoint/v2/clickwrap/status.md). The
> [capture endpoint](https://docs.chamelio.ai/api-reference/endpoint/v2/clickwrap/capture.md) always targets the active version
> at capture time and does not accept a version parameter.

## Use Cases

This endpoint is useful for:

* **Headless consent flows** - Fetch clickwrap content server-side and render it in your own UI before capturing acceptance
* **Version awareness** - Read the current `version_number` to decide whether a returning user needs to re-accept
* **Content display** - Render `content_html` in embedded forms or modal dialogs
