跳到正文
Won.dev

错误码

API 返回的所有错误码,以及它们的含义和处理办法。

所有错误响应的 JSON 结构都相同。请根据 code 做分支判断,不要依赖 message:code 保持稳定,message 可能调整。

hint 给出下一步的处理建议。如果稍后重试能解决问题,响应会带上 retry_after,Retry-After 响应头中也是同一个秒数。联系支持时请附上 request_id(同 X-Request-Id 响应头)。

没有结果不算错误:返回 200 和空列表,并且不收费。失败的请求一律不收费。

{
  "error": {
    "code": "insufficient_balance",
    "message": "The balance cannot cover this request.",
    "hint": "Top up in the console. The message says how much is missing.",
    "docs_url": "https://won.dev/docs/errors#insufficient_balance",
    "retry_after": null,
    "request_id": "req_6f1c0d3a9b8e4f2a8c7d5e4b3a2f1e0d"
  }
}
错误码状态码含义
invalid_input400A parameter is missing, malformed or out of range.
unauthorized401The API key is missing, invalid or revoked.
insufficient_balance402The balance cannot cover this request.
budget_exceeded402This request would cost more than max_cost or the key's remaining budget.
forbidden403This key is not allowed to perform this action.
sending_suspended403Sending is suspended for this account.
not_found404The resource or endpoint does not exist.
idempotency_conflict409This Idempotency-Key was already used with a different request body.
request_in_progress409An identical request is still running.
invalid_state409The resource is in a state that does not allow this action.
sender_not_ready409We stopped the sender: it cannot send.
content_rejected422The content of an email did not pass the checks.
rate_limited429Too many requests.
internal_error500Something went wrong on our side.
upstream_unavailable503A data source behind this capability is temporarily unavailable.

invalid_input

HTTP 400

错误信息(API 原文): A parameter is missing, malformed or out of range.

处理建议(API 原文): Check the parameters against the API reference. The message names the field.

unauthorized

HTTP 401

错误信息(API 原文): The API key is missing, invalid or revoked.

处理建议(API 原文): Send Authorization: Bearer won_live_... with a key from the console.

insufficient_balance

HTTP 402

错误信息(API 原文): The balance cannot cover this request.

处理建议(API 原文): Top up in the console. The message says how much is missing.

budget_exceeded

HTTP 402

错误信息(API 原文): This request would cost more than max_cost or the key's remaining budget.

处理建议(API 原文): Raise max_cost, raise the key's budget in the console, or narrow the request.

forbidden

HTTP 403

错误信息(API 原文): This key is not allowed to perform this action.

处理建议(API 原文): Check the key's permissions in the console.

sending_suspended

HTTP 403

错误信息(API 原文): Sending is suspended for this account.

处理建议(API 原文): Too many bounces or complaints, or we stopped it. The message says which. Write to support to have it looked at.

not_found

HTTP 404

错误信息(API 原文): The resource or endpoint does not exist.

处理建议(API 原文): Check the ID and the path. An ID starts with its type, such as co_ for a company or cmp_ for a campaign, and only works with the endpoints of that type.

idempotency_conflict

HTTP 409

错误信息(API 原文): This Idempotency-Key was already used with a different request body.

处理建议(API 原文): Use a new Idempotency-Key for a different request.

request_in_progress

HTTP 409

错误信息(API 原文): An identical request is still running.

处理建议(API 原文): Wait retry_after seconds, then send it again. Results you already paid for are not charged twice.

invalid_state

HTTP 409

错误信息(API 原文): The resource is in a state that does not allow this action.

处理建议(API 原文): The message names the current state and what is possible from it.

sender_not_ready

HTTP 409

错误信息(API 原文): We stopped the sender: it cannot send.

处理建议(API 原文): review_note in GET /email/senders/{id} says why. Write to support to have it looked at.

content_rejected

HTTP 422

错误信息(API 原文): The content of an email did not pass the checks.

处理建议(API 原文): issues lists every problem and the step it is in. Fix them and send the request again.

rate_limited

HTTP 429

错误信息(API 原文): Too many requests.

处理建议(API 原文): Wait retry_after seconds, then retry with the same Idempotency-Key.

internal_error

HTTP 500

错误信息(API 原文): Something went wrong on our side.

处理建议(API 原文): Retry with the same Idempotency-Key. You are not charged for failed requests.

upstream_unavailable

HTTP 503

错误信息(API 原文): A data source behind this capability is temporarily unavailable.

处理建议(API 原文): Wait retry_after seconds, then retry with the same Idempotency-Key. You are not charged.

本页内容