Sites API
Use the Sites API to list the sites available to the current account and manage individual site records.
🌐 Endpoints
GET
/api/sitesList all sites available to the current signed-in user.
🔑 Authentication required: Yes, via session cookie.
Example Request
Bash
curl --request GET \
--url https://analytics.ghostid.ai/api/sites \
--cookie "session=YOUR_SESSION_COOKIE"Response Example
JSON
{
"sites": [
{
"siteId": 4,
"name": "Ghost ID",
"domain": "ghostid.ai",
"trackingMode": "third-party",
"firstPartyDomain": "go.ghostid.ai"
}
]
}POST
/api/sitesAdd a new site to your Ghost ID account.
🔑 Authentication required: Yes, via session cookie.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| domain | string | Yes | Primary domain to track. |
| name | string | No | Display name shown in the dashboard. |
Request Body
JSON
{
"domain": "example.com",
"name": "My Site"
}Example Request
Bash
curl --request POST \
--url https://analytics.ghostid.ai/api/sites \
--cookie "session=YOUR_SESSION_COOKIE" \
--header "Content-Type: application/json" \
--data '{
"domain": "example.com",
"name": "My Site"
}'Response Example
JSON
{
"site": {
"siteId": 12,
"name": "My Site",
"domain": "example.com"
}
}PUT
/api/sites/:idUpdate an existing site record.
🔑 Authentication required: Yes, via session cookie.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | path | Yes | Site ID returned by Ghost ID. |
| name | string | No | Updated site name. |
| domain | string | No | Updated tracked domain. |
Request Body
JSON
{
"name": "New Name",
"domain": "new.example.com"
}Example Request
Bash
curl --request PUT \
--url https://analytics.ghostid.ai/api/sites/12 \
--cookie "session=YOUR_SESSION_COOKIE" \
--header "Content-Type: application/json" \
--data '{
"name": "New Name",
"domain": "new.example.com"
}'Response Example
JSON
{
"site": {
"siteId": 12,
"name": "New Name",
"domain": "new.example.com"
}
}DELETE
/api/sites/:idDelete a site and remove it from your account.
🔑 Authentication required: Yes, via session cookie.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | path | Yes | Site ID to delete. |
Example Request
Bash
curl --request DELETE \
--url https://analytics.ghostid.ai/api/sites/12 \
--cookie "session=YOUR_SESSION_COOKIE"Response Example
JSON
{
"success": true
}