學習

速度限制和配額

能寄多少錢 , 如何在限制內。

限制免費計畫
每個月的電子郵件數量3,000
每天的電子郵件100
每秒的請求數每個工作空間有10個
收件人50

回應頭

標題意義
X-速度限制-限制每秒允許的請求數
保留X速率限制目前秒數內剩下的請求
重試後等待的秒數 , 每429秒發送一次

退後

1async function send(body, attempt = 0) {
2  const res = await fetch("https://sendtern.com/emails", { method: "POST", headers, body });
3  if (res.status === 429 && attempt < 5) {
4    const wait = Number(res.headers.get("Retry-After") || 2 ** attempt);
5    await new Promise((r) => setTimeout(r, wait * 1000));
6    return send(body, attempt + 1);
7  }
8  return res.json();
9}

每日和每月的配額在 UTC 00: 00 重置。當配額用完時,會返回 429 與 daily_quota_exceeded 或 monthly_quota_exceeded。