学習

レート制限と割当

送れる金額と制限のやり方を

限界フリープラン
月間のメール3,000
1日当たりのメール100
要求数/秒ワークスペースごとに 10 個
受信者50

応答ヘッダ

ヘッダ意味
X-RateLimit-Limit の値を変更する秒当たり許可された要求数
X-RateLimit-Remaining の実装現在の秒数で残った要求
再試行後待つ秒数、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 を返します。