Poomi

身份验证

如何验证 Poomi API 请求的身份

所有 Poomi API 请求都需要通过在 Authorization 请求头中传递 API Key 进行身份验证。

验证方式

Authorization 请求头中使用 Bearer 方案传入你的 API Key:

curl https://www.poomi.pet/api/v1/{endpoint} \
  -H "Authorization: Bearer pk_your_api_key_here"

API Key 格式

pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Key 使用 pk_ 前缀,后跟 32 位 NanoID。

验证错误

HTTP 状态码错误代码描述
401UNAUTHORIZED缺少或无效的 Authorization 请求头
401INVALID_KEYAPI Key 不存在
403KEY_DISABLEDAPI Key 已被禁用
403KEY_REVOKEDAPI Key 已被撤销
403KEY_EXPIREDAPI Key 已过期

错误响应示例

{
  "success": false,
  "error": {
    "code": "INVALID_KEY",
    "message": "Invalid API key"
  }
}

安全建议

  • 使用环境变量 — 切勿在源代码中硬编码 API Key
  • 仅限服务端 — 从后端发起 API 调用,切勿在客户端代码中暴露 Key
  • 区分环境 — 开发和生产环境使用不同的 Key
  • 撤销泄露的 Key — 如果 Key 被暴露,立即在开发者控制台中撤销

On this page