# 速度限制和配額

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

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

## 回應頭

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

## 退後

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

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