POST /bank-accounts/:id/link
เชื่อมโยงบัญชีธนาคารเข้ากับ Branch ของคุณเอง (Branch ที่เรียกใช้ ดึงจาก API Key) ใช้สำหรับเชื่อมโยงบัญชีที่คุณเคยยกเลิกการเชื่อมโยง กลับมา — ค้นหาบัญชีนั้นก่อนได้ที่ GET /bank-accounts/all
เป็น idempotent — การเชื่อมโยงบัญชีที่เชื่อมโยงอยู่แล้วจะสำเร็จแบบไม่ทำอะไร (no-op)
Endpoint
http
POST /bank-accounts/:id/linkURL เต็ม: https://api.easyslip.com/v2/bank-accounts/:id/link
Branch จะเป็นของคุณเองเสมอ — ดึงจาก API Key โดยอัตโนมัติ ไม่มี branchId ทั้งใน path และ body
การยืนยันตัวตน
จำเป็น ดูคู่มือการยืนยันตัวตน
http
Authorization: Bearer YOUR_API_KEYRequest
Path Parameters
| พารามิเตอร์ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
id | number | ใช่ | id ของบัญชีธนาคาร — ต้องมีอยู่ใน Service ของคุณ |
ไม่ต้องมี Request Body
Type Definitions
typescript
// Response
interface LinkResponse {
success: true;
data: {
linked: true;
};
}
// Error Response
interface ErrorResponse {
success: false;
error: {
code: string;
message: string;
};
}ตัวอย่าง
bash
curl -X POST https://api.easyslip.com/v2/bank-accounts/12345/link \
-H "Authorization: Bearer YOUR_API_KEY"javascript
const linkBankAccount = async (id) => {
const response = await fetch(`https://api.easyslip.com/v2/bank-accounts/${id}/link`, {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const result = await response.json();
if (!result.success) {
throw new Error(result.error.message);
}
return result.data;
};
// การใช้งาน
await linkBankAccount(12345);php
function linkBankAccount(int $id): array
{
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.easyslip.com/v2/bank-accounts/' . $id . '/link',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY'
]
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if (!$result['success']) {
throw new Exception($result['error']['message']);
}
return $result['data'];
}
// การใช้งาน
linkBankAccount(12345);python
import requests
def link_bank_account(account_id: int) -> dict:
response = requests.post(
f'https://api.easyslip.com/v2/bank-accounts/{account_id}/link',
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
result = response.json()
if not result['success']:
raise Exception(result['error']['message'])
return result['data']
# การใช้งาน
link_bank_account(12345)Response
สำเร็จ (200)
json
{
"success": true,
"data": {
"linked": true
}
}Error Responses
ไม่พบบัญชีธนาคาร (404)
json
{
"success": false,
"error": {
"code": "BANK_ACCOUNT_NOT_FOUND",
"message": "Bank account not found"
}
}หมายเหตุ
- บัญชีจะถูกเชื่อมโยงกับ Branch ของคุณเอง — ไม่มี
branchIdเพราะ Branch มาจาก API Key - บัญชีต้องมีอยู่ใน Service ของคุณ (ใช้
GET /bank-accounts/allเพื่อค้นหา) มิฉะนั้นจะได้รับ404 BANK_ACCOUNT_NOT_FOUND - เป็น idempotent — การเชื่อมโยงบัญชีที่เชื่อมโยงอยู่แล้วจะคืนค่า
linked: trueโดยไม่สร้างรายการซ้ำ และปลอดภัยแม้ส่งซ้ำพร้อมกัน - หลังเชื่อมโยง บัญชีจะปรากฏใน
GET /bank-accounts - หากต้องการย้อนกลับ ให้ยกเลิกการเชื่อมโยงบัญชี