# List the custom domains attached to a project.

GET https://services.leadconnectorhq.com/ai-builder-api/projects/{projectId}/custom-domains

Lists the app's custom domains with their setup status and the DNS records to add. A domain is attached with `changes` kind `domain`; once it is `active` it serves the live site.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `clientportal-ai.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | The API version. |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectId` | string | Yes | The project. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ai-builder-api/projects/{projectId}/custom-domains": {
      "get": {
        "summary": "List the custom domains attached to a project.",
        "operationId": "listTheCustomDomainsAttachedToAProject",
        "description": "Lists the app's custom domains with their setup status and the DNS records to add. A domain is attached with `changes` kind `domain`; once it is `active` it serves the live site.",
        "parameters": [
          {
            "in": "path",
            "name": "projectId",
            "required": true,
            "description": "The project.",
            "example": "prj_5f0c2a3e",
            "schema": {
              "type": "string",
              "pattern": "^prj_[A-Za-z0-9_-]+$"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "required": true,
            "description": "The API version.",
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The project's custom domains.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomDomainList"
                }
              }
            }
          },
          "404": {
            "description": "Project not found for this tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "clientportal-ai.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A sub-account access token: a Marketplace app's OAuth token or a Private Integration Token."
      }
    },
    "schemas": {
      "CustomDomainList": {
        "type": "object",
        "required": [
          "domains"
        ],
        "properties": {
          "domains": {
            "type": "array",
            "description": "The custom domains attached to the project, with their setup status.",
            "example": [
              {
                "hostname": "portal.acmefitness.com",
                "tier": "production",
                "status": "awaiting_dns",
                "trafficType": "subdomain"
              }
            ],
            "items": {
              "type": "object",
              "required": [
                "hostname",
                "tier",
                "status",
                "trafficType"
              ],
              "properties": {
                "hostname": {
                  "type": "string",
                  "description": "The customer-owned hostname, normalised to lowercase.",
                  "example": "portal.acmefitness.com"
                },
                "tier": {
                  "type": "string",
                  "enum": [
                    "production",
                    "preview",
                    "sandbox"
                  ],
                  "description": "Which of the app's sites the hostname serves; `production` is the live site.",
                  "example": "production"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "awaiting_dns",
                    "issuing",
                    "active",
                    "failed"
                  ],
                  "description": "`active` means both the certificate and exact shared-edge route are ready. `failed` means issuance did not complete within the retry budget; re-attach to retry. `lastError` is returned only when failed.",
                  "example": "awaiting_dns"
                },
                "trafficType": {
                  "type": "string",
                  "enum": [
                    "apex",
                    "subdomain"
                  ],
                  "description": "The persisted DNS routing shape for this hostname.",
                  "example": "subdomain"
                },
                "lastError": {
                  "type": "string",
                  "description": "Present only when status is failed.",
                  "example": "The certificate was not issued within the retry budget."
                },
                "validationRecord": {
                  "allOf": [
                    {
                      "type": "object",
                      "required": [
                        "name",
                        "type",
                        "value"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "The DNS record's name, to add at the domain's DNS provider.",
                          "example": "portal.acmefitness.com"
                        },
                        "type": {
                          "type": "string",
                          "description": "The DNS record's type.",
                          "example": "CNAME"
                        },
                        "value": {
                          "type": "string",
                          "description": "The DNS record's value.",
                          "example": "clientportal.ludicrous.cloud"
                        }
                      },
                      "title": "DnsValidationRecord"
                    }
                  ],
                  "description": "Persisted ownership-verification instruction. Present after the hostname has been attached so clients can safely restore setup guidance without repeating the attach mutation."
                },
                "trafficRecord": {
                  "allOf": [
                    {
                      "type": "object",
                      "required": [
                        "name",
                        "type",
                        "value"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "The DNS record's name, to add at the domain's DNS provider.",
                          "example": "portal.acmefitness.com"
                        },
                        "type": {
                          "type": "string",
                          "description": "The DNS record's type.",
                          "example": "CNAME"
                        },
                        "value": {
                          "type": "string",
                          "description": "The DNS record's value.",
                          "example": "clientportal.ludicrous.cloud"
                        }
                      },
                      "title": "DnsValidationRecord"
                    }
                  ],
                  "description": "Persisted traffic-routing instruction. It can be added alongside the ownership record so DNS and HTTPS setup converge in parallel."
                }
              },
              "title": "CustomDomain"
            }
          }
        },
        "title": "CustomDomainList"
      },
      "ApiError": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "requestId"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "example": "about:blank",
            "description": "A URI identifying the kind of error."
          },
          "title": {
            "type": "string",
            "example": "Request validation failed",
            "description": "Short summary of the kind of error."
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599,
            "example": 422,
            "description": "The HTTP status code."
          },
          "detail": {
            "type": "string",
            "example": "One or more fields are invalid.",
            "description": "What went wrong with this request."
          },
          "instance": {
            "type": "string",
            "example": "/api/v1/runs",
            "description": "The request path that failed."
          },
          "code": {
            "type": "string",
            "example": "validation_error",
            "description": "Stable, machine-readable error code."
          },
          "requestId": {
            "type": "string",
            "example": "req_01HXQ8Z6J9K2",
            "description": "The request's id, for support."
          },
          "fieldErrors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "code",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string",
                  "example": "prompt",
                  "description": "The invalid field, as a dotted path."
                },
                "code": {
                  "type": "string",
                  "example": "required",
                  "description": "Machine-readable reason."
                },
                "message": {
                  "type": "string",
                  "example": "Prompt is required.",
                  "description": "Human-readable reason."
                }
              },
              "title": "FieldError"
            },
            "description": "One entry per invalid field, when the request body was invalid.",
            "example": [
              {
                "field": "name",
                "code": "too_long",
                "message": "name must be at most 120 characters"
              }
            ]
          }
        },
        "title": "ApiError"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/custom-domains' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/custom-domains', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/ai-builder-api/projects/{projectId}/custom-domains"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

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

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/custom-domains',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/custom-domains")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/custom-domains"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/custom-domains")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/custom-domains' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
