# Custom Pages quickstart

This guide instructs you through replacing the `404` your origin returns with your first page from [Custom Pages](/en/documentation/platform/custom-pages/).

- Create a custom page set with one page for status code `404`.
- Assign the set in the deployment of your [Workload](/en/documentation/platform/workloads/).
- Request a path your origin does not have and get your own page in its place.

Four elements take part, and each one leads to the next:

1. Your error page is at a path on the **Connector**. The Connector already exists. For more information, refer to [Connectors](/en/documentation/platform/connectors/).
2. The **custom page set** holds a page that replaces status code `404` with the content at that path on the Connector.
3. The **deployment** of the Workload sets the custom page set, next to the Application it already sets.
4. The **request** reaches a path that the Connector your Application uses answers with `404`, and the custom page set replaces that response.

A Workload uses a custom page set only once that Workload's deployment sets that custom page set. Then, when the Connector your Application uses answers `404`, the client receives the content of your page in place of that response. The response carries no redirect, and its status code is the one the page sets.

This guide covers Azion Console and the API, and you assign the set in Azion Console. The Azion CLI has no command that updates a deployment, and the published API v4 reference has no endpoint for one.

---

## Prerequisites

### Console

- A Workload with a deployment that sets an Application. To create one, refer to [Workloads quickstart](/en/documentation/platform/workloads/quickstart/).
- A path that the Connector your Application uses answers with `404`, such as a page that does not exist on your origin.
- A Connector with your error page at a path. To create one, refer to [Connectors](/en/documentation/platform/connectors/).
- Access to Azion Console. To sign in, refer to [How to access Azion Console](/en/documentation/guides/platform/account-and-billing/how-to-access-azion-console/).

### API

- A Workload with a deployment that sets an Application. To create one, refer to [Workloads quickstart](/en/documentation/platform/workloads/quickstart/).
- A path that the Connector your Application uses answers with `404`, such as a page that does not exist on your origin.
- A Connector with your error page at a path. To create one, refer to [Connectors](/en/documentation/platform/connectors/).
- A personal token and `curl`. To create a token, refer to [Personal tokens](/en/documentation/fundamentals/personal-tokens/).
- The ID of the Connector with your error page.

---

## Create the custom page set

A custom page set is a named list of pages, and it needs at least one page. Each page replaces one status code with the content at a path on a Connector, and it can answer with a status code of its own. The page in this stage stays in cache for `0` seconds, its time to live (TTL), and answers with `404`.

### Console

To create the set in Azion Console:

1. **Open the Custom Pages page**

   Access [Azion Console](https://console.azion.com/) > **Custom Pages**.

2. **Start a new set**

   Select **Create Custom Page**. The **Create Custom Page** page opens.

3. **Name the set**

   In **Name**, enter a name for the set, such as `my-custom-pages`.

4. **Add a page code**

   Select **+ Custom Page Code**.

5. **Select the status code**

   In **Page Code**, select `404`.

6. **Keep the Page Connector type**

   In **Type**, keep *Page Connector*.

7. **Select your Connector**

   In **Connector**, select the Connector with your error page.

8. **Enter the path of the page**

   In **Page Path (URI)**, enter the path of your page on the Connector, such as `/html`.

9. **Set the cache time**

   In **Response TTL**, enter `0`.

10. **Set the response status**

    In **Response Custom Status Code**, enter `404`.

11. **Select Apply**

12. **Select Create**

The set exists with one page for code `404`. It serves nothing until you assign it to your Workload. A set with no page code is refused with the message "You must have at least one custom page code".

### API

To create the set with the API, send a `POST` request to the custom pages endpoint. Replace `[TOKEN VALUE]` with your personal token and `<connector-id>` with the ID of your Connector. Replace `/html` with the path of your page on the Connector:

```bash
curl --request POST \
--url https://api.azion.com/v4/workspace/custom_pages \
--header 'Accept: application/json' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{"name": "my-custom-pages", "active": true, "pages": [
{"code": "404", "page": {"type": "page_connector", "attributes": {"connector": <connector-id>, "ttl": 0, "uri": "/html", "custom_status_code": 404}}}
]}'
```

The API answers with `202`, `"state": "pending"`, and the new set in `data`, its `id` included. A request with an empty `pages` list is refused with `Ensure this field has at least 1 elements.` Record the `id` of the new set to assign it to your Workload. The set exists with one page for code `404`, and it serves nothing until you assign it.

---

## Assign the set to your Workload

A Workload's deployment sets the Application that answers its requests, and it can also set a Firewall and a custom page set. A Workload holds at most one deployment, so you assign the custom page set by editing that deployment. The Application that the deployment already sets stays in place.

### Console

To assign the set in Azion Console:

1. **Open the Workloads page**

   Access [Azion Console](https://console.azion.com/) > **Workloads**.

2. **Open your Workload**

   Select your Workload. The **Edit Workload** page opens.

3. **Select the set**

   In **Deployment Settings**, select your set in **Custom Page**. Keep **Application** as it is.

4. **Select Save**

Azion Console shows the message "Your workload has been updated". The Workload's deployment sets your custom page set.

### API

The published Azion API v4 reference has no endpoint for the deployment of a Workload. To assign the set, follow the Console panel.

---

## Request a page your origin answers with 404

The check is the same whichever interface assigned the set. In the command, replace `<your-workload-domain>` with the workload domain of your Workload, of the form `<id>.map.azionedge.net`. Replace `<missing-path>` with the path that the Connector your Application uses answers with `404`.

An assigned set does not serve at once. The change to the deployment spreads across Azion's distributed infrastructure, and that takes several minutes, with no guaranteed duration. While it spreads, a request can receive either your origin's `404` or your page. Repeat the request until your page answers, as [Propagation](/en/documentation/platform/workloads/how-it-works/#propagation) explains.

Send a request to the missing path and print the response headers with the body:

```bash
curl -s -D - https://<your-workload-domain>/<missing-path>
```

The response keeps status `404`, from the page's `custom_status_code`. Its body is the document at the page's path on your Connector. When that document is an HTML page, the response starts like this example, with your document as the body:

```text
HTTP/2 404 
content-type: text/html; charset=utf-8

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
      <h1>Page not found</h1>
```

The response carries no `Location` header, so the client is not redirected. Your Workload answers a missing path with your own page.

---

## Next steps

- [Custom page settings](/en/documentation/platform/custom-pages/settings.md): Every field of a set and its pages, and the 22 status codes a page can replace.
- [Customize an error page](/en/documentation/guides/application-development/getting-started/customizing-error-response-page.md): Replace the error responses of several status codes at once, each page with its own cache time.
- [Workload settings](/en/documentation/platform/workloads/settings.md#deployment): The deployment fields that set the Application, the Firewall, and the custom page set.
- [Troubleshoot Custom Pages](/en/documentation/platform/custom-pages/troubleshooting.md): Find the cause when a custom page set is refused or your page does not replace the error.
