# 寄信

## email_log_search

查寄信紀錄（請款信、催收信、測試信等），新的在前。

給 Agent 的原文：

> Search the email log (bill emails, reminders, test emails…), newest first.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `limit` | integer |  | default: 20 |
| `cursor` | string（可以是 null） |  |  |
| `sent_from` | date（可以是 null） |  |  |
| `sent_to` | date（可以是 null） |  |  |
| `kinds` | BILL \| REMINDER \| TEST \| INVITATION \| APPROVAL_NOTIFICATION \| APPROVAL_OUTCOME_NOTIFICATION \| QUOTE \| ORDER[]（可以是 null） |  |  |
| `statuses` | QUEUED \| SENT \| FAILED[]（可以是 null） |  |  |
| `keyword` | string |  | Recipient, cc, bill number, quote number or order number; an email needs pii:read |

授權項目：`emails:read`；keyword 像 Email 或電話時，另外要 pii:read。

核可：不用

## email_resend

重寄一封寄送失敗（FAILED）的請款信，用請款單和買方 Email 現在的內容；原本那封留在紀錄裡。可以先試算看會寄給誰。寄出前要先試算，把結果給使用者看、問過使用者，再帶試算給的確認碼寄。

給 Agent 的原文：

> Resend a FAILED bill email with the current bill and the buyer's current email; the original stays in the log.
> Use dry_run to see who would get it. Before sending, call with dry_run: true, show the user the bills, amounts and
> recipients, and ask whether to send; then call again with the confirmation_code from the dry run.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `email_log_id` | string | 必填 |  |
| `dry_run` | boolean |  | default: false |
| `confirmation_code` | string（可以是 null） |  | Required unless dry_run is true: the confirmation_code returned by a dry run with the same parameters. |
| `idempotency_key` | string |  | Required for every call that writes (not for dry_run). The same key within 24 hours returns the first result instead of doing it again. |

授權項目：`bills:send`

寫入、可試算、核可：不用、寄出前要先試算帶確認碼
