Appearance
Sites
Create, retrieve, update, and delete analytics sites. Each site represents a domain you want to track.
Base URL: https://app.krafter.dev/api/v1/analytics
Site Object
json
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"domain": "example.com",
"name": "My Website",
"site_key": "sk_abc123def456",
"public_stats": false,
"created_at": "2025-01-15T10:00:00Z"
}| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (UUID). |
domain | string | The domain being tracked. |
name | string | Display name for the site. |
site_key | string | Public site key used in the tracker script. Starts with sk_. |
public_stats | boolean | Whether the stats dashboard is publicly accessible. |
created_at | string | ISO 8601 timestamp of when the site was created. |
List Sites
Retrieve all analytics sites for your team.
GET /analytics/sitesRequired scope: analytics:read
Example Request
bash
curl https://app.krafter.dev/api/v1/analytics/sites \
-H "Authorization: Bearer YOUR_API_TOKEN"Example Response
json
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"domain": "example.com",
"name": "My Website",
"site_key": "sk_abc123def456",
"public_stats": false,
"created_at": "2025-01-15T10:00:00Z"
},
{
"id": "660f9511-f39c-52e5-b827-557766551111",
"domain": "blog.example.com",
"name": "Company Blog",
"site_key": "sk_def456ghi789",
"public_stats": true,
"created_at": "2025-02-01T14:30:00Z"
}
]
}Create Site
Create a new analytics site. A site_key is auto-generated and returned in the response.
POST /analytics/sitesRequired scope: analytics:write
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
domain | string | Yes | Domain to track. Must be alphanumeric with dots (e.g., example.com). |
name | string | Yes | Display name for the site. |
Example Request
bash
curl -X POST https://app.krafter.dev/api/v1/analytics/sites \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"domain": "example.com",
"name": "My Website"
}'Example Response
json
// 201 Created
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"domain": "example.com",
"name": "My Website",
"site_key": "sk_abc123def456",
"public_stats": false,
"created_at": "2025-01-15T10:00:00Z"
}
}WARNING
The site_key is generated automatically and cannot be changed. Store it securely -- you will need it for the tracker script and API queries.
Validation Errors
json
// 422 Unprocessable Entity
{
"error": {
"message": "Validation failed",
"details": {
"domain": ["must contain only alphanumeric characters and dots"]
}
}
}Get Site
Retrieve a single site by its site key.
GET /analytics/sites/:keyRequired scope: analytics:read
Example Request
bash
curl https://app.krafter.dev/api/v1/analytics/sites/sk_abc123def456 \
-H "Authorization: Bearer YOUR_API_TOKEN"Example Response
json
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"domain": "example.com",
"name": "My Website",
"site_key": "sk_abc123def456",
"public_stats": false,
"created_at": "2025-01-15T10:00:00Z"
}
}Update Site
Update a site's name or domain.
PATCH /analytics/sites/:keyRequired scope: analytics:write
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | New display name. |
domain | string | No | New domain. Must be alphanumeric with dots. |
Example Request
bash
curl -X PATCH https://app.krafter.dev/api/v1/analytics/sites/sk_abc123def456 \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Main Website"
}'Example Response
json
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"domain": "example.com",
"name": "Main Website",
"site_key": "sk_abc123def456",
"public_stats": false,
"created_at": "2025-01-15T10:00:00Z"
}
}Delete Site
Delete a site and all associated analytics data. This action is irreversible.
DELETE /analytics/sites/:keyRequired scope: analytics:write
Example Request
bash
curl -X DELETE https://app.krafter.dev/api/v1/analytics/sites/sk_abc123def456 \
-H "Authorization: Bearer YOUR_API_TOKEN"Example Response
json
// 200 OK
{
"data": {
"deleted": true
}
}WARNING
Deleting a site permanently removes all analytics data, including page views, events, goals, and statistics. This cannot be undone.
Scopes
| Scope | Endpoints |
|---|---|
analytics:read | GET /analytics/sites, GET /analytics/sites/:key |
analytics:write | POST /analytics/sites, PATCH /analytics/sites/:key, DELETE /analytics/sites/:key |