> For the complete documentation index, see [llms.txt](https://help.firstline.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.firstline.cc/developer/api/phone.md).

# 電話號碼

## 搜尋電話號碼

```javascript
GET https://{API_DOMAIN}/api/v1/phone-number
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    '{"type": 0, "number": "0928846763"}'
    https://{API_HOST}/api/v1/phone-number
```

### Form Data

下表為可使用的過濾條件

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                          |
| --------------- | -------- | ------- | ------ | ------------------------------------ |
| **contact\_id** | false    | NULL    | Number | 客戶的 **id** (可透過 `搜尋客戶` 取得客戶的 **id**) |
| **type**        | false    | NULL    | Number | 0: 住家, 1: 公司, 2: 手機, 3: 傳真, 4: 其他    |
| **number**      | false    | NULL    | String | 電話號碼                                 |
| **extension**   | false    | NULL    | String | 分機號碼                                 |
| **description** | false    | NULL    | String | 備註                                   |

### Response

| PROPERTY | TYPE             | DESCRIPTION                                                       |
| -------- | ---------------- | ----------------------------------------------------------------- |
| **data** | Array of objects | [電話號碼陣列](/developer/api/response-object.md#dian-hua-phone-number) |
| **meta** | Object           | Pagination meta                                                   |

```javascript

{
    "data": [
        {
            "id": 245621,
            "type": 0,
            "extension": null,
            "number": "0928846763",
            "description": null,
            "profile_id": 1935008,
            "phone_contact": {
                "id": 480,
                "contact_id": 1935038,
                "phone_number_id": 245621,
                "is_visible": true
            }
        }
    ],
    "links": {
        "first": "https://firstline.localhost/api/phone-number?number=0928846763&contact_id=1935038&page=1",
        "last": "https://firstline.localhost/api/phone-number?number=0928846763&contact_id=1935038&page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "https://firstline.localhost/api/phone-number",
        "per_page": 15,
        "to": 2,
        "total": 2
    }
}
```

## 取得電話號碼

```javascript
https://{API_DOMAIN}/api/v1/phone-number/{phone_number}
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    https://{API_HOST}/api/v1/245621
```

### URL Parameters

| PARAMETER         | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                                                         |
| ----------------- | -------- | ------- | ------ | ------------------------------------------------------------------- |
| **phone\_number** | true     | NULL    | Number | <[電話號碼](/developer/api/response-object.md#dian-hua-phone-number)的id |

### Response

請參考[電話號碼](/developer/api/response-object.md#dian-hua-phone-number)的回應格式

| PROPERTY | TYPE   | DESCRIPTION                                                     |
| -------- | ------ | --------------------------------------------------------------- |
| **data** | Object | [電話號碼](/developer/api/response-object.md#dian-hua-phone-number) |

```javascript

{
    "data": {
        "id": 245621,
        "type": 0,
        "extension": null,
        "number": "0928846763",
        "description": null,
        "profile_id": 1935008,
        "phone_contact": {
            "id": 480,
            "contact_id": 1935038,
            "phone_number_id": 245621,
            "is_visible": true
        }
    }
}
```

## 新增電話號碼

```javascript
POST https://{API_DOMAIN}/api/v1/phone-number
```

```javascript
curl -X POST
    -H "Content-Type: application/json"
    '{"type": 0, "number": "23255780374507", "extension": "54 311", "description": "Up-sized mobile focusgroup"}'
    https://{API_HOST}/api/v1/phone-number
```

### Form Data

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                          |
| --------------- | -------- | ------- | ------ | ------------------------------------ |
| **contact\_id** | true     | NULL    | Number | 客戶的 **id** (可透過 `搜尋客戶` 取得客戶的 **id**) |
| **type**        | true     | NULL    | Number | 0: 住家, 1: 公司, 2: 手機, 3: 傳真, 4: 其他    |
| **number**      | true     | NULL    | String | 電話號碼                                 |
| **extension**   | false    | NULL    | String | 分機號碼                                 |
| **description** | false    | NULL    | String | 備註                                   |

> 回傳 json 格式

```javascript
{
    "data": {
        "id": 1,
        "type": 0,
        "extension": "54 311",
        "number": "23255780374507",
        "description": "Up-sized mobile focusgroup",
        "profile_id": 1
    }
}
```

## 更新電話號碼

```javascript
PUT https://{API_DOMAIN}/api/v1/phone-number/{phone_number}
```

```javascript
curl -X PUT
    -H "Content-Type: application/json"
    '{"type": 2, "number": "0939888999", "extension": ""}'
    https://{API_HOST}/api/v1/phone-number/1
```

### URL Parameters

| PARAMETER         | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| ----------------- | -------- | ------- | ------ | ----------- |
| **phone\_number** | true     | NULL    | Number | 電話號碼的id     |

### Form Data

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                       |
| --------------- | -------- | ------- | ------ | --------------------------------- |
| **contact\_id** | true     | NULL    | Number | 客戶的 id                            |
| **type**        | false    | NULL    | Number | 0: 住家, 1: 公司, 2: 手機, 3: 傳真, 4: 其他 |
| **number**      | false    | NULL    | String | 電話號碼                              |
| **extension**   | false    | NULL    | String | 分機號碼                              |
| **description** | false    | NULL    | String | 備註                                |

### Response

請參考[電話號碼](/developer/api/response-object.md#dian-hua-phone-number)的回應格式

```javascript
{
    "data": {
        "id": 1,
        "type": 2,
        "extension": "",
        "number": "0939888999",
        "description": "Up-sized mobile focusgroup",
        "profile_id": 1
    }
}
```

## 刪除電話號碼

Http status 為 204

```javascript
DELETE https://{API_DOMAIN}/api/v1/phone-number/{phone_number}
```

```javascript
curl -X DELETE
    -H "Content-Type: application/json"
    https://{API_HOST}/api/v1/phone-number/1
```

### URL Parameters

| PARAMETER         | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| ----------------- | -------- | ------- | ------ | ----------- |
| **phone\_number** | true     | NULL    | Number | 電話號碼的id     |

> 回傳 json 格式

```javascript
{}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.firstline.cc/developer/api/phone.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
