---
title: Client-Side Protection
summary: Client-Side Protection (CSP) provides visibility and control over third-party scripts running on your web pages. Monitor script behavior, manage authorization status, and configure security policies to protect against client-side attacks like Magecart and formjacking.
url: https://www.fastly.com/documentation/reference/api/client-side-protection
---

Client-Side Protection (CSP) provides visibility and control over third-party scripts running on your web pages.
Monitor script behavior, manage authorization status, and configure security policies to protect against
client-side attacks like Magecart and formjacking.

## Data model

| Field | Type | Description |
|-------|------|-------------|
| `name` | string | CSP directive name (e.g., script-src, style-src). |
| `values` | array | Directive values. |
| `config` | object | Type-specific configuration. |
| `type` | string | Notification type. |
| `description` | string | Page description. |
| `id` | string | Unique page identifier. |
| `notifications` | array | Notification configurations for this page. |
| `paths` | array | URL paths to monitor. |
| `webhook` | object | Whether the page has a webhook. The URL is write-only and never returned. |
| `webhook_signing_key` | string | Generated HMAC-SHA256 key returned once, only when this create or update first enables a webhook. Omitted from Page reads, lists, and subsequent edits. Store securely; do not log or cache it. (Read-only) |
| `webhook_signing_key_id` | string | Public identifier returned alongside a newly generated webhook_signing_key. Read current key metadata from the signing-key endpoint. (Read-only) |
| `website_id` | string | Parent website ID. |
| `url` | string | HTTPS receiver URL. Must have a host, with no user information or fragment. Localhost and literal private, loopback, link-local, unspecified, and multicast IP addresses are rejected, as are ports outside 1–65535. At delivery, resolved IP addresses must also be public; redirects are not followed. Never returned in responses. |
| `enabled` | boolean | true when the page has a webhook destination. Read-only; ignored in request bodies. (Read-only) |
| `key_id` | string | Public identifier of the new signing key, used to tell keys apart. Lowercase hex encoding of the first 16 bytes of SHA-256 of the UTF-8 signing key. It does not appear on webhook deliveries. |
| `signing_key` | string | Newly generated HMAC-SHA256 signing key, returned only in this rotation response. Store securely; do not log or cache it. |
| `directives` | array |  |
| `authorization_status` | string | Script authorization status. |
| `authorized_hash` | string | Hash of authorized script content. |
| `current_hash` | string | Current script content hash. |
| `justification` | string | Reason for authorization decision. |
| `page_id` | string | Parent page ID. |
| `source` | string | Script source (inline or external URL). |
| `urls` | array | URLs where this script was observed. |
| `domain` | string | Website domain. |
| `page_ids` | array | IDs of pages associated with this website. |

## API endpoints

### List websites

**GET** `/client-side-protection/v1/websites`

List all websites configured for Client-Side Protection.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `limit` | integer | query | No | Limit how many results are returned. |
| `page` | integer | query | No | Page number of the collection to request. |

### Create website

**POST** `/client-side-protection/v1/websites`

Create a new website for Client-Side Protection monitoring.

### Get website

**GET** `/client-side-protection/v1/websites/{website_id}`

Get details for a specific website.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `website_id` | string | path | Yes | Website identifier. |

### Delete website

**DELETE** `/client-side-protection/v1/websites/{website_id}`

Delete a website and all associated pages, scripts, and policies.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `website_id` | string | path | Yes | Website identifier. |

### Update website

**PATCH** `/client-side-protection/v1/websites/{website_id}`

Update a website's configuration.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `website_id` | string | path | Yes | Website identifier. |

### List pages

**GET** `/client-side-protection/v1/pages`

List all pages. Optionally filter by website.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `limit` | integer | query | No | Limit how many results are returned. |
| `page` | integer | query | No | Page number of the collection to request. |
| `website_id` | string | query | No | Filter pages by website ID. |

### Create page

**POST** `/client-side-protection/v1/pages`

Create a new page for monitoring. notifications lists email destinations only and is optional.
To add a webhook, send webhook with a url; omit webhook for a page without one. A page with
neither sends no alerts. A webhook entry inside notifications is rejected; use the webhook field.
notifications and webhook are optional but not nullable: null for either returns 400.
Supplying webhook.url requires an API token with global scope, and a verified Customer Support
Access grant when a Fastly administrator acts on another customer's behalf. When creating a
webhook, the response
returns webhook_signing_key and webhook_signing_key_id once with Cache-Control: no-store.
Store the key securely; subsequent reads do not return it. If creation fails, no page is created
and no signing key or confirmation email is issued.

### Get page

**GET** `/client-side-protection/v1/pages/{page_id}`

Get details for a specific page.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |

### Delete page

**DELETE** `/client-side-protection/v1/pages/{page_id}`

Delete a page and all associated scripts and policies.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |

### Update page

**PATCH** `/client-side-protection/v1/pages/{page_id}`

Update a page's configuration. An omitted or null name or paths keeps the stored value; an
empty name or an empty paths array is rejected. A request that supplies website_id, even as an
empty string, updates the page's details as a whole, so omitting description clears it. A request
without website_id updates only the fields it contains: an omitted description is kept, and an
empty string clears it. The website_id field never moves the page; the page stays on its original
website, and path edits always use that website's domain, even when a different website_id is
supplied.
notifications and webhook change independently, and neither may be null: null for either
returns 400, so omit a field to keep it. notifications lists email destinations only: omit it to
keep them, send an array to replace them, or send an empty array to remove them; it never affects
the webhook. For webhook, an omitted value, {}, or a body with only enabled keeps the webhook as
it is; enabled is read-only and ignored. {"url": "https://..."} adds a webhook or replaces its
URL while keeping its signing key. An update never removes a webhook; use
DELETE /client-side-protection/v1/pages/{page_id}/webhook.
Supplying webhook.url requires an API token with global scope, and a verified Customer Support Access grant when a Fastly
administrator acts on another customer's behalf. First enabling a webhook returns
webhook_signing_key and webhook_signing_key_id once with Cache-Control: no-store. Replacing its
URL or keeping it does not return or change the key. If the update fails, the page is left as it
was. If another request changes the page's webhook at the same time, the update returns 409 with
the detail "The Page's notification destinations changed during this request. Reload the Page and
try again.".

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |

### Remove Page webhook

**DELETE** `/client-side-protection/v1/pages/{page_id}/webhook`

Remove the page's webhook destination and delete its URL and signing key. Email destinations are
unchanged. Adding a webhook again later generates a new signing key. Requires Page management permissions
and an API token with global scope, and a verified Customer Support Access grant when a Fastly
administrator acts on another customer's behalf. Returns 404 if the page does not exist or has
no webhook.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |

### Get Page webhook signing key metadata

**GET** `/client-side-protection/v1/pages/{page_id}/signing-key`

Return only the public key_id for a configured Page webhook. The signing key cannot be retrieved. Requires Page management permissions
and global token scope. Returns 404 if the Page or webhook is not found.
Administrator impersonation requires a verified Customer Support Access grant; requests are
rejected if the grant cannot be verified.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |

### Rotate Page webhook signing key

**POST** `/client-side-protection/v1/pages/{page_id}/signing-key`

Replace the Page webhook signing key and return the new key once. Store it securely; subsequent
reads do not return it. No request body is required. If the response is lost, explicitly rotate
again to obtain a replacement; do not automatically retry.
Requires Page management permissions and global token scope. Rotation applies to newly fetched configurations; queued deliveries
retain their original key. For 72 hours plus five minutes after a rotation, accept a signature that
matches either the current key or the previous key, and install the replacement promptly. Returns 404 if the Page or webhook is not found.
Administrator impersonation requires a verified Customer Support Access grant; requests are
rejected if the grant cannot be verified.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |

### List scripts

**GET** `/client-side-protection/v1/pages/{page_id}/scripts`

List all scripts detected on a page.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `limit` | integer | query | No | Limit how many results are returned. |
| `page_id` | string | path | Yes | Page identifier. |
| `page` | integer | query | No | Page number of the collection to request. |

### Get script

**GET** `/client-side-protection/v1/pages/{page_id}/scripts/{script_id}`

Get details for a specific script.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |
| `script_id` | string | path | Yes | Script identifier. |

### Update script

**PATCH** `/client-side-protection/v1/pages/{page_id}/scripts/{script_id}`

Update a script's authorization status or justification.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |
| `script_id` | string | path | Yes | Script identifier. |

### List policies

**GET** `/client-side-protection/v1/pages/{page_id}/policies`

List all Content Security Policies for a page.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `limit` | integer | query | No | Limit how many results are returned. |
| `page_id` | string | path | Yes | Page identifier. |
| `page` | integer | query | No | Page number of the collection to request. |

### Create policy

**POST** `/client-side-protection/v1/pages/{page_id}/policies`

Create a new Content Security Policy for a page.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |

### Get policy

**GET** `/client-side-protection/v1/pages/{page_id}/policies/{policy_id}`

Get details for a specific policy.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |
| `policy_id` | string | path | Yes | Policy identifier. |

### Update policy

**PATCH** `/client-side-protection/v1/pages/{page_id}/policies/{policy_id}`

Update a policy's configuration.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `page_id` | string | path | Yes | Page identifier. |
| `policy_id` | string | path | Yes | Policy identifier. |

### List policy reports

**GET** `/client-side-protection/v1/pages/{page_id}/policies/{policy_id}/reports`

List CSP violation reports for a policy.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `limit` | integer | query | No | Limit how many results are returned. |
| `page_id` | string | path | Yes | Page identifier. |
| `page` | integer | query | No | Page number of the collection to request. |
| `policy_id` | string | path | Yes | Policy identifier. |

### List security headers

**GET** `/client-side-protection/v1/pages/{page_id}/headers`

List security headers detected on a page.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `limit` | integer | query | No | Limit how many results are returned. |
| `page_id` | string | path | Yes | Page identifier. |
| `page` | integer | query | No | Page number of the collection to request. |

### List header events

**GET** `/client-side-protection/v1/pages/{page_id}/events`

List security header change events for a page.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `limit` | integer | query | No | Limit how many results are returned. |
| `page_id` | string | path | Yes | Page identifier. |
| `page` | integer | query | No | Page number of the collection to request. |

