网站

网站管理和统计相关操作。

端点

GET /api/websites
POST /api/websites
GET /api/websites/:websiteId
POST /api/websites/:websiteId
DELETE /api/websites/:websiteId
POST /api/websites/:websiteId/reset
GET /api/websites/:websiteId/recorder

GET /api/websites

返回所有用户网站。

参数

ParameterTypeDescription
includeTeamsboolean设置为 true 以包含你作为团队所有者的网站。
searchstring(可选)搜索文本。
pagenumber(可选,默认 1)确定页码。
pageSizenumber(可选)确定返回多少结果。

示例响应

{
  "data": [
    {
      "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": "示例",
      "domain": "example.com",
      "shareId": null,
      "resetAt": null,
      "userId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "teamId": null,
      "createdBy": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "createdAt": "0000-00-00T00:00:00.000Z",
      "updatedAt": "0000-00-00T00:00:00.000Z",
      "deletedAt": null,
      "user": {
        "username": "bob@aol.com",
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      }
    }
  ],
  "count": 1,
  "page": 1,
  "pageSize": 10
}

POST /api/websites

Create a website.

Parameters

ParameterTypeDescription
namestringThe name of the website in Umami.
domainstringThe full domain name of the website being tracked.
shareIdstring(Optional) A unique string used to enable a share URL. Set to null to disable sharing.
teamIdstring(Optional) The ID of the team the website will be created under.
idstring(Optional) Force a UUID to be assigned to the website.

Request Body

{
  "name": "Test",
  "domain": "example.com"
}

Example Response

{
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "Test",
  "domain": "example.com",
  "shareId": null,
  "resetAt": null,
  "userId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "teamId": null,
  "createdBy": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "createdAt": "0000-00-00T00:00:00.000Z",
  "updatedAt": "0000-00-00T00:00:00.000Z",
  "deletedAt": null
}

GET /api/websites/:websiteId

Get website by ID.

Example response

{
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "Example",
  "domain": "example.com",
  "shareId": null,
  "resetAt": null,
  "userId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "teamId": null,
  "createdBy": "133660ed-e51c-4ed9-84aa-c86654460cae",
  "createdAt": "2025-10-10T22:01:06.201Z",
  "updatedAt": "2025-10-10T22:02:02.220Z",
  "deletedAt": null
}

POST /api/websites/:websiteId

更新网站。

参数

ParameterTypeDescription
namestringUmami 中网站的名称。
domainstring被跟踪网站的完整域名。
shareIdstring(可选)用于启用分享 URL 的唯一字符串。设置为 null 可取消分享。
replayConfigobject(可选)会话录制和热图配置。

replayConfig 字段

FieldTypeDescription
replayEnabledboolean启用或禁用会话回放录制。
heatmapEnabledboolean启用或禁用热图数据收集。
sampleRatenumber需要录制为回放的会话比例(0–1)。
heatmapSampleRatenumber需要录制为热图的会话比例(0–1)。
maskLevelstringPII 脱敏级别:strictmoderate
maxDurationnumber录制的最长时长(秒)。
blockSelectorstring用于排除录制元素的 CSS 选择器。

请求体

{
  "name": "Test",
  "domain": "domain.com",
  "replayConfig": {
    "replayEnabled": true,
    "sampleRate": 0.5
  }
}

示例响应

{
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "Example",
  "domain": "example.com",
  "shareId": null,
  "resetAt": null,
  "userId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "teamId": null,
  "recorderEnabled": true,
  "replayConfig": {
    "replayEnabled": true,
    "heatmapEnabled": false,
    "sampleRate": 0.5,
    "heatmapSampleRate": 0,
    "maskLevel": "moderate",
    "maxDuration": 3600,
    "blockSelector": ""
  },
  "createdBy": "133660ed-e51c-4ed9-84aa-c86654460cae",
  "createdAt": "2025-10-10T22:01:06.201Z",
  "updatedAt": "2025-10-10T22:02:02.220Z",
  "deletedAt": null
}

DELETE /api/websites/:websiteId

删除网站。

示例响应

{
  "ok": true
}

POST /api/websites/:websiteId/reset

重置网站,删除与该网站相关的所有数据。

示例响应

{
  "ok": true
}

GET /api/websites/:websiteId/recorder

返回某个网站的录制器配置。供 tracker 用于初始化会话回放和热力图采集。此端点不需要身份验证,可公开访问。

如果网站不存在或录制已禁用,则返回 { "enabled": false }

示例响应

{
  "enabled": true,
  "replayEnabled": true,
  "heatmapEnabled": false,
  "sampleRate": 0.15,
  "heatmapSampleRate": 0.15,
  "maskLevel": "moderate",
  "maxDuration": 300000,
  "blockSelector": ""
}