2020-06-16 23:08:38 -04:00
---
stage: Release
group: Release Management
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
2017-08-21 19:56:47 -04:00
# Pages domains API
2020-03-22 23:09:21 -04:00
Endpoints for connecting custom domain(s) and TLS certificates in [GitLab Pages ](https://about.gitlab.com/stages-devops-lifecycle/pages/ ).
2017-08-21 19:56:47 -04:00
The GitLab Pages feature must be enabled to use these endpoints. Find out more about [administering ](../administration/pages/index.md ) and [using ](../user/project/pages/index.md ) the feature.
2017-11-13 11:05:44 -05:00
## List all pages domains
Get a list of all pages domains. The user must have admin permissions.
2020-05-19 23:08:04 -04:00
```plaintext
2017-11-13 11:05:44 -05:00
GET /pages/domains
```
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/pages/domains"
2017-11-13 11:05:44 -05:00
```
```json
[
{
"domain": "ssl.domain.example",
"url": "https://ssl.domain.example",
2018-01-03 11:32:34 -05:00
"project_id": 1337,
2019-11-15 13:06:24 -05:00
"auto_ssl_enabled": false,
2017-11-13 11:05:44 -05:00
"certificate": {
"expired": false,
"expiration": "2020-04-12T14:32:00.000Z"
}
}
]
```
2017-08-21 19:56:47 -04:00
## List pages domains
Get a list of project pages domains. The user must have permissions to view pages domains.
2020-05-19 23:08:04 -04:00
```plaintext
2017-08-21 19:56:47 -04:00
GET /projects/:id/pages/domains
```
| Attribute | Type | Required | Description |
| --------- | -------------- | -------- | ---------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/5/pages/domains"
2017-08-21 19:56:47 -04:00
```
```json
[
{
"domain": "www.domain.example",
"url": "http://www.domain.example"
},
{
"domain": "ssl.domain.example",
"url": "https://ssl.domain.example",
2019-11-15 13:06:24 -05:00
"auto_ssl_enabled": false,
2017-08-21 19:56:47 -04:00
"certificate": {
"subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
"expired": false,
"certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",
"certificate_text": "Certificate:\n … \n"
}
}
]
```
## Single pages domain
Get a single project pages domain. The user must have permissions to view pages domains.
2020-05-19 23:08:04 -04:00
```plaintext
2017-08-21 19:56:47 -04:00
GET /projects/:id/pages/domains/:domain
```
| Attribute | Type | Required | Description |
| --------- | -------------- | -------- | ---------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2019-11-15 13:06:24 -05:00
| `domain` | string | yes | The custom domain indicated by the user |
2017-08-21 19:56:47 -04:00
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/5/pages/domains/www.domain.example"
2017-08-21 19:56:47 -04:00
```
```json
{
"domain": "www.domain.example",
"url": "http://www.domain.example"
}
```
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
2017-08-21 19:56:47 -04:00
```
```json
{
"domain": "ssl.domain.example",
"url": "https://ssl.domain.example",
2019-11-15 13:06:24 -05:00
"auto_ssl_enabled": false,
2017-08-21 19:56:47 -04:00
"certificate": {
"subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
"expired": false,
"certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",
"certificate_text": "Certificate:\n … \n"
}
}
```
## Create new pages domain
Creates a new pages domain. The user must have permissions to create new pages domains.
2020-05-19 23:08:04 -04:00
```plaintext
2017-08-21 19:56:47 -04:00
POST /projects/:id/pages/domains
```
2019-11-15 13:06:24 -05:00
| Attribute | Type | Required | Description |
| -------------------| -------------- | -------- | ---------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `domain` | string | yes | The custom domain indicated by the user |
| `auto_ssl_enabled` | boolean | no | Enables [automatic generation ](../user/project/pages/custom_domains_ssl_tls_certification/lets_encrypt_integration.md ) of SSL certificates issued by Let's Encrypt for custom domains. |
| `certificate` | file/string | no | The certificate in PEM format with intermediates following in most specific to least specific order.|
| `key` | file/string | no | The certificate key in PEM format. |
2017-08-21 19:56:47 -04:00
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " --form "domain=ssl.domain.example" --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
2017-08-21 19:56:47 -04:00
```
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " --form "domain=ssl.domain.example" --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
2017-08-21 19:56:47 -04:00
```
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " --form "domain=ssl.domain.example" --form "auto_ssl_enabled=true" "https://gitlab.example.com/api/v4/projects/5/pages/domains"
2019-11-15 13:06:24 -05:00
```
2017-08-21 19:56:47 -04:00
```json
{
"domain": "ssl.domain.example",
"url": "https://ssl.domain.example",
2019-11-15 13:06:24 -05:00
"auto_ssl_enabled": true,
2017-08-21 19:56:47 -04:00
"certificate": {
"subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
"expired": false,
"certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",
"certificate_text": "Certificate:\n … \n"
}
}
```
## Update pages domain
Updates an existing project pages domain. The user must have permissions to change an existing pages domains.
2020-05-19 23:08:04 -04:00
```plaintext
2017-08-21 19:56:47 -04:00
PUT /projects/:id/pages/domains/:domain
```
2019-11-15 13:06:24 -05:00
| Attribute | Type | Required | Description |
| ------------------ | -------------- | -------- | ---------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `domain` | string | yes | The custom domain indicated by the user |
| `auto_ssl_enabled` | boolean | no | Enables [automatic generation ](../user/project/pages/custom_domains_ssl_tls_certification/lets_encrypt_integration.md ) of SSL certificates issued by Let's Encrypt for custom domains. |
| `certificate` | file/string | no | The certificate in PEM format with intermediates following in most specific to least specific order.|
| `key` | file/string | no | The certificate key in PEM format. |
### Adding certificate
2017-08-21 19:56:47 -04:00
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
2017-08-21 19:56:47 -04:00
```
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
2017-08-21 19:56:47 -04:00
```
```json
{
"domain": "ssl.domain.example",
"url": "https://ssl.domain.example",
2019-11-15 13:06:24 -05:00
"auto_ssl_enabled": false,
2017-08-21 19:56:47 -04:00
"certificate": {
"subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",
"expired": false,
"certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",
"certificate_text": "Certificate:\n … \n"
}
}
```
2019-11-15 13:06:24 -05:00
### Enabling Let's Encrypt integration for Pages custom domains
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " --form "auto_ssl_enabled=true" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
2019-11-15 13:06:24 -05:00
```
```json
{
"domain": "ssl.domain.example",
"url": "https://ssl.domain.example",
"auto_ssl_enabled": true
}
```
### Removing certificate
To remove the SSL certificate attached to the Pages domain, run:
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " --form "certificate=" --form "key=" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
2019-11-15 13:06:24 -05:00
```
```json
{
"domain": "ssl.domain.example",
"url": "https://ssl.domain.example",
"auto_ssl_enabled": false
}
```
2017-08-21 19:56:47 -04:00
## Delete pages domain
Deletes an existing project pages domain.
2020-05-19 23:08:04 -04:00
```plaintext
2017-08-21 19:56:47 -04:00
DELETE /projects/:id/pages/domains/:domain
```
| Attribute | Type | Required | Description |
| --------- | -------------- | -------- | ---------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2019-11-15 13:06:24 -05:00
| `domain` | string | yes | The custom domain indicated by the user |
2017-08-21 19:56:47 -04:00
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example"
2017-08-21 19:56:47 -04:00
```