# 客戶

## customer_create

新增客戶；客戶編號相同的訂單和報價單會連到這位客戶。

給 Agent 的原文：

> Create a customer. Orders and quotes whose customer number matches are linked to it. A taken number returns CUSTOMER_NUMBER_TAKEN.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `number` | string | 必填 | Unique in the workspace (case-sensitive); usually the id in your own CRM |
| `name` | string | 必填 |  |
| `title` | string |  | Legal name used on bills and e-invoices |
| `tax_id` | string |  | 8 digits, or empty |
| `address` | string |  |  |
| `primary_email` | string |  |  |
| `cc_emails` | string[] |  |  |
| `phone` | string |  |  |
| `note` | string |  |  |
| `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. |

授權項目：`customers:manage`

寫入、核可：不用

## customer_get

用編號或 id 查一位客戶，附 version（customer_update 要用）。

給 Agent 的原文：

> Get one customer by number or id, with its version (needed by customer_update).

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `customer` | string | 必填 | Customer number (exact match) or id |

授權項目：`customers:read`

核可：不用

## customer_search

用編號、名稱、抬頭或統一編號找客戶，照編號排序；回摘要，要一位的完整資料用 customer_get。

給 Agent 的原文：

> Search customers by number, name, title or tax ID, ordered by number. Returns summaries; use customer_get for one customer.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `keyword` | string |  | Part of the customer number, name, title or tax ID; an email or phone needs pii:read |
| `limit` | integer |  | default: 20 |
| `cursor` | string（可以是 null） |  |  |

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

核可：不用

## customer_update

整份換掉客戶的資料；已經成立的訂單和請款單維持當時的資料。

給 Agent 的原文：

> Replace a customer's fields. Orders and bills already created keep the details they were created with.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `number` | string | 必填 | Unique in the workspace (case-sensitive); usually the id in your own CRM |
| `name` | string | 必填 |  |
| `title` | string |  | Legal name used on bills and e-invoices |
| `tax_id` | string |  | 8 digits, or empty |
| `address` | string |  |  |
| `primary_email` | string |  |  |
| `cc_emails` | string[] |  |  |
| `phone` | string |  |  |
| `note` | string |  |  |
| `customer` | string | 必填 | Customer number (exact match) or id |
| `version` | integer | 必填 | The version from customer_get; a different one returns CONCURRENT_MODIFICATION |
| `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. |

授權項目：`customers:manage`、`pii:read`

寫入、核可：不用
