学习
错误
每个错误代码,其原因以及如何修复。
Sendtern uses standard HTTP status codes. Every error response uses the same JSON shape with name, message, and statusCode, so you can handle failures in one place.
1{
2 "name": "validation_error",
3 "message": "Provide at least one recipient",
4 "statusCode": 422
5}
| 现状 | 姓名 | 怎么办 |
|---|---|---|
| 400 | invalid_json | The request body is malformed JSON (mapped to validation_error on /resend) |
| 401 | invalid_api_key | The Bearer API key is invalid, malformed, or revoked |
| 401 | missing_api_key | The Authorization header is missing (returned on /resend compatibility endpoints) |
| 401 / 403 | restricted_api_key | Returned on /resend when a sending-only or domain-scoped key lacks permission for the operation |
| 403 | insufficient_permissions | The key is Sending only (sending_access) and the endpoint requires Full access (full_access) |
| 403 | domain_scope | The key is restricted to a specific verified domain and cannot send for another domain or call project-wide endpoints |
| 403 | domain_not_verified | Verify the exact from sender domain in the dashboard before sending live mail |
| 404 | 未找到 | The resource ID doesn't exist in this workspace |
| 409 | idempotency_conflict | The same Idempotency-Key was reused with a different request body (invalid_idempotent_request on /resend) |
| 413 | body_too_large | The JSON request body exceeds the 1 MB limit |
| 415 | unsupported_media_type | Send requests with Content-Type: application/json |
| 422 | validation_error | Check message for the invalid field, recipient count, or missing template variable |
| 429 | 超出限制 | Workspace exceeded 180 requests per minute. Wait for Retry-After seconds, then retry |
| 429 | daily_limit / monthly_limit | Workspace transactional recipient quota reached for the UTC day or month (daily_quota_exceeded / monthly_quota_exceeded on /resend) |
| 500 | 内部错误 | Retry with exponential backoff and the same Idempotency-Key (application_error on /resend) |
何时重试
Retry 429 (rate_limit_exceeded) and 5xx responses with exponential backoff and the same Idempotency-Key. Never retry other 4xx errors without fixing the request—the response will be the same.