sentry

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sentry API

Sentry API

Use the Sentry API via direct
curl
calls to manage error tracking, issues, projects, and releases.
Official docs:
https://docs.sentry.io/api/

通过直接调用
curl
来使用Sentry API,以管理错误追踪、问题、项目和版本发布
官方文档:
https://docs.sentry.io/api/

When to Use

适用场景

Use this skill when you need to:
  • List and search issues - find errors and exceptions
  • Resolve or ignore issues - manage issue status
  • View issue details - get stack traces and event data
  • Manage projects - list and configure projects
  • Track releases - create and monitor releases
  • View events - get detailed error events

当你需要以下操作时,可使用该技能:
  • 查看并搜索问题 - 查找错误和异常
  • 解决或忽略问题 - 管理问题状态
  • 查看问题详情 - 获取堆栈跟踪和事件数据
  • 管理项目 - 查看并配置项目
  • 跟踪版本发布 - 创建并监控版本发布
  • 查看事件 - 获取详细的错误事件

Prerequisites

前置条件

  1. Go to Sentry → Settings (gear icon in sidebar) → Account → API → Personal Tokens
  2. Click Create New Token
  3. Select the required scopes (see below) — scopes cannot be edited after creation
  4. Copy the generated token
bash
export SENTRY_HOST="sentry.io" # Or your self-hosted Sentry domain
export SENTRY_TOKEN="sntrys_..." # Personal Auth Token
export SENTRY_ORG="your-org-slug" # Your organization slug
  1. 进入Sentry → 设置(侧边栏的齿轮图标)→ 账户 → API → 个人令牌
  2. 点击创建新令牌
  3. 选择所需的权限范围(见下文)——权限范围创建后无法编辑
  4. 复制生成的令牌
bash
export SENTRY_HOST="sentry.io" # 或你的自托管Sentry域名
export SENTRY_TOKEN="sntrys_..." # 个人认证令牌
export SENTRY_ORG="your-org-slug" # 你的组织别名

Required Scopes

所需权限范围

  • project:read
    - List and view projects
  • event:read
    - View issues and events
  • event:write
    - Update issues (resolve, ignore, assign)
  • project:releases
    - View and create releases

Important: When using
$VAR
in a command that pipes to another command, wrap the command containing
$VAR
in
bash -c '...'
. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'
  • project:read
    - 查看项目列表和详情
  • event:read
    - 查看问题和事件
  • event:write
    - 更新问题(解决、忽略、分配)
  • project:releases
    - 查看并创建版本发布

重要提示: 当在包含管道的命令中使用
$VAR
时,请将包含
$VAR
的命令用
bash -c '...'
包裹。由于Claude Code的bug,直接使用管道时环境变量会被静默清除。
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'

How to Use

使用方法

All examples below assume
SENTRY_HOST
,
SENTRY_TOKEN
, and
SENTRY_ORG
are set.
Base URL:
https://${SENTRY_HOST}/api/0

以下所有示例均假设已设置
SENTRY_HOST
SENTRY_TOKEN
SENTRY_ORG
环境变量。
基础URL:
https://${SENTRY_HOST}/api/0

1. List Your Projects

1. 查看项目列表

Get all projects you have access to:
bash
bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {slug, name, platform, dateCreated}'

获取你有权限访问的所有项目:
bash
bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {slug, name, platform, dateCreated}'

2. Get Project Details

2. 获取项目详情

Get details for a specific project:
Note: Replace
my-project
with your actual project slug from the "List Your Projects" output above.
bash
PROJECT_SLUG="my-project"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/${SENTRY_ORG}/${PROJECT_SLUG}/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{slug, name, platform, status, dateCreated}'

获取特定项目的详情:
注意:
my-project
替换为你从“查看项目列表”结果中得到的实际项目别名。
bash
PROJECT_SLUG="my-project"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/${SENTRY_ORG}/${PROJECT_SLUG}/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{slug, name, platform, status, dateCreated}'

3. List Organization Issues

3. 查看组织内的问题

Get all issues across the organization:
bash
bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {id, shortId, title, culprit, status, count, userCount, firstSeen, lastSeen}
Query parameters:
  • query=is:unresolved
    - Filter by status
  • query=error.type:TypeError
    - Filter by error type
  • sort=date
    - Sort by last seen (default)
  • sort=new
    - Sort by first seen
  • sort=freq
    - Sort by event count

获取组织内的所有问题:
bash
bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {id, shortId, title, culprit, status, count, userCount, firstSeen, lastSeen}'
查询参数:
  • query=is:unresolved
    - 按状态筛选
  • query=error.type:TypeError
    - 按错误类型筛选
  • sort=date
    - 按最后出现时间排序(默认)
  • sort=new
    - 按首次出现时间排序
  • sort=freq
    - 按事件数量排序

4. List Project Issues

4. 查看项目内的问题

Get issues for a specific project:
Note: Replace
my-project
with your actual project slug from the "List Your Projects" output.
bash
PROJECT_SLUG="my-project"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/${SENTRY_ORG}/${PROJECT_SLUG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {id, shortId, title, status, count, lastSeen}

获取特定项目的问题:
注意:
my-project
替换为你从“查看项目列表”结果中得到的实际项目别名。
bash
PROJECT_SLUG="my-project"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/${SENTRY_ORG}/${PROJECT_SLUG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {id, shortId, title, status, count, lastSeen}'

5. Search Issues

5. 搜索问题

Search issues with query:
Write to
/tmp/sentry_query.txt
:
is:unresolved level:error
bash
bash -c 'curl -s -G "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --data-urlencode "query@/tmp/sentry_query.txt"' | jq '.[] | {shortId, title, level, count}
Common query filters:
  • is:unresolved
    /
    is:resolved
    /
    is:ignored
    - By status
  • level:error
    /
    level:warning
    /
    level:info
    - By level
  • assigned:me
    /
    assigned:none
    - By assignee
  • browser:Chrome
    - By browser
  • os:Windows
    - By OS
  • release:1.0.0
    - By release version

使用查询语句搜索问题:
写入内容到
/tmp/sentry_query.txt
is:unresolved level:error
bash
bash -c 'curl -s -G "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --data-urlencode "query@/tmp/sentry_query.txt"' | jq '.[] | {shortId, title, level, count}'
常用查询筛选条件:
  • is:unresolved
    /
    is:resolved
    /
    is:ignored
    - 按状态
  • level:error
    /
    level:warning
    /
    level:info
    - 按级别
  • assigned:me
    /
    assigned:none
    - 按经办人
  • browser:Chrome
    - 按浏览器
  • os:Windows
    - 按操作系统
  • release:1.0.0
    - 按版本号

6. Get Issue Details

6. 获取问题详情

Get details for a specific issue:
Note: Replace
123456789
with an actual issue ID from the "List Issues" or "List Project Issues" output (use the
id
field, not
shortId
).
bash
ISSUE_ID="123456789"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{id, shortId, title, culprit, status, level, count, userCount, firstSeen, lastSeen, assignedTo}'

获取特定问题的详情:
注意:
123456789
替换为你从“查看问题列表”或“查看项目内的问题”结果中得到的实际问题ID(使用
id
字段,而非
shortId
)。
bash
ISSUE_ID="123456789"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{id, shortId, title, culprit, status, level, count, userCount, firstSeen, lastSeen, assignedTo}'

7. Get Latest Event for Issue

7. 获取问题的最新事件

Get the most recent event for an issue:
Note: Replace
123456789
with an actual issue ID from the "List Issues" output.
bash
ISSUE_ID="123456789"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/events/latest/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{eventID, message, platform, dateCreated, tags, contexts}'

获取某个问题的最近一次事件:
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。
bash
ISSUE_ID="123456789"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/events/latest/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{eventID, message, platform, dateCreated, tags, contexts}'

8. List Issue Events

8. 获取问题的所有事件

Get all events for an issue:
Note: Replace
123456789
with an actual issue ID from the "List Issues" output.
bash
ISSUE_ID="123456789"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/events/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {eventID, message, dateCreated}

获取某个问题的所有事件:
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。
bash
ISSUE_ID="123456789"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/events/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {eventID, message, dateCreated}'

9. Resolve Issue

9. 解决问题

Mark an issue as resolved:
Note: Replace
123456789
with an actual issue ID from the "List Issues" output.
bash
ISSUE_ID="123456789"
Write to
/tmp/sentry_request.json
:
json
{
  "status": "resolved"
}
Then run:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

将问题标记为已解决:
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。
bash
ISSUE_ID="123456789"
写入内容到
/tmp/sentry_request.json
json
{
  "status": "resolved"
}
然后运行:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

10. Resolve in Next Release

10. 标记为下一个版本解决

Mark issue as resolved in next release:
Note: Replace
123456789
with an actual issue ID from the "List Issues" output.
bash
ISSUE_ID="123456789"
Write to
/tmp/sentry_request.json
:
json
{
  "status": "resolvedInNextRelease"
}
Then run:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

将问题标记为在下一个版本发布时自动解决:
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。
bash
ISSUE_ID="123456789"
写入内容到
/tmp/sentry_request.json
json
{
  "status": "resolvedInNextRelease"
}
然后运行:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

11. Ignore Issue

11. 忽略问题

Ignore an issue:
Note: Replace
123456789
with an actual issue ID from the "List Issues" output.
bash
ISSUE_ID="123456789"
Write to
/tmp/sentry_request.json
:
json
{
  "status": "ignored"
}
Then run:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'
Ignore with duration (in minutes):
Write to
/tmp/sentry_request.json
:
json
{
  "status": "ignored",
  "statusDetails": {
    "ignoreDuration": 60
  }
}
Then run:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

忽略某个问题:
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。
bash
ISSUE_ID="123456789"
写入内容到
/tmp/sentry_request.json
json
{
  "status": "ignored"
}
然后运行:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'
设置忽略时长(分钟):
写入内容到
/tmp/sentry_request.json
json
{
  "status": "ignored",
  "statusDetails": {
    "ignoreDuration": 60
  }
}
然后运行:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

12. Unresolve Issue

12. 重新打开问题

Reopen a resolved issue:
Note: Replace
123456789
with an actual issue ID from the "List Issues" output.
bash
ISSUE_ID="123456789"
Write to
/tmp/sentry_request.json
:
json
{
  "status": "unresolved"
}
Then run:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

将已解决的问题重新标记为未解决:
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。
bash
ISSUE_ID="123456789"
写入内容到
/tmp/sentry_request.json
json
{
  "status": "unresolved"
}
然后运行:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, status}'

13. Assign Issue

13. 分配问题

Assign an issue to a user:
Note: Replace
123456789
with an actual issue ID from the "List Issues" output. Replace
<user-email>
with a valid user email from your Sentry organization members.
Write to
/tmp/sentry_request.json
:
json
{
  "assignedTo": "<user-email>"
}
Then run:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, assignedTo}'
Note: Replace
123456789
in the URL with the actual issue ID from the "List Issues" output.

将问题分配给指定用户:
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。将
<user-email>
替换为Sentry组织成员中的有效用户邮箱。
写入内容到
/tmp/sentry_request.json
json
{
  "assignedTo": "<user-email>"
}
然后运行:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{id, shortId, assignedTo}'
注意: 将URL中的
123456789
替换为“查看问题列表”结果中的实际问题ID。

14. Bulk Update Issues

14. 批量更新问题

Update multiple issues at once:
Note: Replace
123456789
and
987654321
with actual issue IDs from the "List Issues" output.
Write to
/tmp/sentry_request.json
:
json
{
  "id": ["123456789", "987654321"],
  "status": "resolved"
}
Then run:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json'

同时更新多个问题:
注意:
123456789
987654321
替换为你从“查看问题列表”结果中得到的实际问题ID。
写入内容到
/tmp/sentry_request.json
json
{
  "id": ["123456789", "987654321"],
  "status": "resolved"
}
然后运行:
bash
bash -c 'curl -s -X PUT "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json'

15. Delete Issue

15. 删除问题

Delete an issue (requires admin permissions):
Note: Replace
123456789
with an actual issue ID from the "List Issues" output.
bash
ISSUE_ID="123456789"

bash -c 'curl -s -X DELETE "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" -w "\nHTTP Status: %{http_code}"'

删除某个问题(需要管理员权限):
注意:
123456789
替换为你从“查看问题列表”结果中得到的实际问题ID。
bash
ISSUE_ID="123456789"

bash -c 'curl -s -X DELETE "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/${ISSUE_ID}/" --header "Authorization: Bearer ${SENTRY_TOKEN}" -w "\nHTTP Status: %{http_code}"'

16. List Releases

16. 查看版本发布列表

Get all releases for the organization:
bash
bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {version, dateCreated, newGroups, projects: [.projects[].slug]}'

获取组织内的所有版本发布:
bash
bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {version, dateCreated, newGroups, projects: [.projects[].slug]}'

17. Get Release Details

17. 获取版本发布详情

Get details for a specific release:
Note: Replace
1.0.0
with an actual release version from the "List Releases" output.
bash
RELEASE_VERSION="1.0.0"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/${RELEASE_VERSION}/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{version, dateCreated, dateReleased, newGroups, lastEvent, projects}'

获取特定版本发布的详情:
注意:
1.0.0
替换为你从“查看版本发布列表”结果中得到的实际版本号。
bash
RELEASE_VERSION="1.0.0"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/${RELEASE_VERSION}/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '{version, dateCreated, dateReleased, newGroups, lastEvent, projects}'

18. Create Release

18. 创建版本发布

Create a new release:
Note: Replace
<your-project-slug>
with your actual project slug from the "List Your Projects" output.
Write to
/tmp/sentry_request.json
:
json
{
  "version": "1.0.1",
  "projects": ["<your-project-slug>"]
}
Then run:
bash
bash -c 'curl -s -X POST "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{version, dateCreated}'

创建一个新的版本发布:
注意:
<your-project-slug>
替换为你从“查看项目列表”结果中得到的实际项目别名。
写入内容到
/tmp/sentry_request.json
json
{
  "version": "1.0.1",
  "projects": ["<your-project-slug>"]
}
然后运行:
bash
bash -c 'curl -s -X POST "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{version, dateCreated}'

19. Create Release with Commits

19. 创建关联提交的版本发布

Create release with associated commits:
Note: Replace
<your-project-slug>
with your actual project slug from the "List Your Projects" output.
Write to
/tmp/sentry_request.json
:
json
{
  "version": "1.0.2",
  "projects": ["<your-project-slug>"],
  "refs": [
    {
      "repository": "owner/repo",
      "commit": "abc123def456"
    }
  ]
}
Then run:
bash
bash -c 'curl -s -X POST "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{version, dateCreated}'

创建包含关联代码提交的版本发布:
注意:
<your-project-slug>
替换为你从“查看项目列表”结果中得到的实际项目别名。
写入内容到
/tmp/sentry_request.json
json
{
  "version": "1.0.2",
  "projects": ["<your-project-slug>"],
  "refs": [
    {
      "repository": "owner/repo",
      "commit": "abc123def456"
    }
  ]
}
然后运行:
bash
bash -c 'curl -s -X POST "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/releases/" --header "Authorization: Bearer ${SENTRY_TOKEN}" --header "Content-Type: application/json" -d @/tmp/sentry_request.json' | jq '{version, dateCreated}'

20. List Project Error Events

20. 查看项目的错误事件

Get recent error events for a project:
Note: Replace
my-project
with your actual project slug from the "List Your Projects" output.
bash
PROJECT_SLUG="my-project"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/${SENTRY_ORG}/${PROJECT_SLUG}/events/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {eventID, title, message, dateCreated}'

获取某个项目的近期错误事件:
注意:
my-project
替换为你从“查看项目列表”结果中得到的实际项目别名。
bash
PROJECT_SLUG="my-project"

bash -c 'curl -s "https://${SENTRY_HOST}/api/0/projects/${SENTRY_ORG}/${PROJECT_SLUG}/events/" --header "Authorization: Bearer ${SENTRY_TOKEN}"' | jq '.[] | {eventID, title, message, dateCreated}'

Issue Status Values

问题状态值

StatusDescription
unresolved
Active issue (default)
resolved
Manually resolved
resolvedInNextRelease
Auto-resolve on next release
ignored
Ignored (won't alert)

状态描述
unresolved
活跃问题(默认)
resolved
手动标记为已解决
resolvedInNextRelease
下一个版本发布时自动解决
ignored
已忽略(不会触发告警)

Guidelines

注意事项

  1. Use organization slug: Most endpoints use org slug, not ID
  2. Pagination: Use
    cursor
    parameter for paginated results
  3. Query syntax: Use Sentry's query language for powerful filtering
  4. Rate limits: Sentry has rate limits; implement backoff for 429 responses
  5. Self-hosted: For self-hosted Sentry, set
    SENTRY_HOST
    to your domain
  6. Scopes matter: Ensure your token has required scopes for each operation
  1. 使用组织别名:大多数接口使用组织别名,而非ID
  2. 分页处理:使用
    cursor
    参数处理分页结果
  3. 查询语法:使用Sentry的查询语言进行强大的筛选
  4. 速率限制:Sentry有请求速率限制;遇到429响应时请实现退避机制
  5. 自托管部署:对于自托管的Sentry,将
    SENTRY_HOST
    设置为你的域名
  6. 权限范围很重要:确保你的令牌拥有每个操作所需的权限范围