API 身份验证
在本指南中,你可以了解如何获取 API 密钥,以及 Tracksuite API 身份验证的工作方式。
获取 API 密钥的步骤
Section titled “获取 API 密钥的步骤”- 登录 Tracksuite 管理门户。
- 转到“设置”部分的“API 与 Webhook”。
- 复制 API 密钥。
验证 API 请求
Section titled “验证 API 请求”每个 Tracksuite API 密钥都是一串唯一字符,用于识别用户。
把密钥放在 Authorization 请求头中。下面这个请求标出了它的位置:
curl --location --request POST 'https://api.tracksuite.net/api/v1/routers/create' \ --header 'Authorization: your_api_key' \ --header 'Content-Type: application/json' \ --data-raw '{ "data": [ { "referId": "order-10001", "rawTrackingNumber": "9400111899223857461234", "metadata": { "carrierCode": "usps" } } ] }'密钥的访问范围
Section titled “密钥的访问范围”您的 API 密钥只能访问该账户创建的跟踪。查询其他账户的运单号时,接口会返回 not found。
身份验证失败
Section titled “身份验证失败”未通过身份验证时,Tracksuite 会返回以下错误:
| 状态码 | 描述 |
|---|---|
401 |
未传或密钥无效。{ "message": "Unauthorized" } |
401 |
密钥已过期。{ "message": "Token expired" } |
403 |
账户已禁用。{ "message": "User disabled" } |
