> 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/feature/channels/live-chat/ke-hu-shen-fen-yan-zheng.md).

# 客戶身份驗證

### **準備驗證相關參數**

你的網站需先由後端透過 API 請求一組驗證代碼，其他參數需包含一組 secret 與提供的驗證資料(電子郵件、電話號碼等)。

![](/files/-MQp4UYLw0NkpvA5yOTC)

### **呼叫 API 取得驗證代碼**

因應安全性，取得的代碼為一次性，使用後將立即失效，若有新需要時需再次請求。

&#x20;**HTTP request**`GET https://01.firstline.cc/livechat/messenger/9/apply-query-request?secret={secret}`

#### Response

```
 {
    "code": "fl0db2xl-efab-46ce-bd88-c253ab0c7913",
    "criteria": null,
    "created_at": 1608099124,
    "expired_at": 1608102723,
    "livechat_account_id": 3
}
                
```

若出現 404 代碼，表示沒有相對應條件客戶或找到多筆客戶。

&#x20;**範例**`https://dev.dev.firstline.cc/livechat/messenger/9/apply-query-request?secret=5f49b304-89f0-495b-9a5c-5a216b53cdbc&membership_no=FL0092`

### **將一次性代碼組合至網址**

&#x20;當後端收到驗證代碼(code)後，需將其組合至嵌入代碼內 JavaScript 網址，如 `https://dev.dev.firstline.cc/livechat.5c626c29-bd95-4d73-91b6-f58774a5c109.js?t=1610337630&once_code={once_code}`
