Skip to content

จัดการสาขา

จัดการสาขาสำหรับบริการ EasySlip ของคุณ สาขาช่วยให้คุณแบ่งการใช้งาน API ตามแผนก สถานที่ หรือแอปพลิเคชันต่างๆ

ดูรายการสาขาทั้งหมด

http
GET /b2b/branches

Full URL: https://api.easyslip.com/b2b/branches

Permission: branch:read

Request

ไม่ต้องส่ง request body

ตัวอย่าง

bash
curl -X GET https://api.easyslip.com/b2b/branches \
  -H "X-API-Key: ${API_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Nonce: ${NONCE}" \
  -H "X-Signature: ${SIGNATURE}"
javascript
const headers = signRequest({
    method: 'GET',
    path: '/b2b/branches',
    body: null,
    apiKey: 'your_api_key',
    secretKey: 'your_secret_key',
})

const response = await fetch('https://api.easyslip.com/b2b/branches', { headers })
const result = await response.json()

Success Response (200)

json
{
    "success": true,
    "data": [
        {
            "id": "cm1a2b3c4d5e6f7g8h9i0",
            "name": "สำนักงานใหญ่",
            "isActive": true,
            "ipAddress": null,
            "limitQuota": 10000,
            "usedQuota": 1500,
            "totalUsedQuota": 45000,
            "bankAccounts": [
                {
                    "id": "cm9z8y7x6w5v4u3t2s1r0",
                    "bankCode": "004",
                    "bankNumber": "123-4-56789-0",
                    "nameTh": "บริษัท อีซี่สลิป จำกัด",
                    "nameEn": "EasySlip Co., Ltd."
                }
            ],
            "createdAt": "2024-06-15T10:30:00+07:00",
            "updatedAt": "2024-12-01T14:00:00+07:00"
        },
        {
            "id": "cm2b3c4d5e6f7g8h9i0j1",
            "name": "สาขาเชียงใหม่",
            "isActive": true,
            "ipAddress": "203.150.100.50",
            "limitQuota": 5000,
            "usedQuota": 800,
            "totalUsedQuota": 12000,
            "bankAccounts": [],
            "createdAt": "2024-08-20T09:00:00+07:00",
            "updatedAt": "2024-11-15T16:30:00+07:00"
        }
    ]
}

ฟิลด์ใน Response

ฟิลด์ชนิดคำอธิบาย
idstringID สาขา
namestringชื่อสาขา
isActivebooleanสถานะการใช้งานสาขา
ipAddressstring | nullIP address ที่อนุญาต (null = อนุญาตทุก IP)
limitQuotanumber | nullโควตาสูงสุดของสาขา (null = ใช้โควตาระดับบริการ)
usedQuotanumberโควตาที่ใช้ไปในรอบนี้
totalUsedQuotanumberโควตาที่ใช้ไปทั้งหมดตลอดการใช้งาน
bankAccountsarrayบัญชีธนาคารที่เชื่อมต่อ
createdAtstringเวลาที่สร้าง (ISO 8601)
updatedAtstringเวลาที่อัปเดตล่าสุด (ISO 8601)

ดูข้อมูลสาขา

http
GET /b2b/branches/:branchId

Full URL: https://api.easyslip.com/b2b/branches/:branchId

Permission: branch:read

ตัวอย่าง

bash
curl -X GET https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0 \
  -H "X-API-Key: ${API_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Nonce: ${NONCE}" \
  -H "X-Signature: ${SIGNATURE}"
javascript
const headers = signRequest({
    method: 'GET',
    path: '/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
    body: null,
    apiKey: 'your_api_key',
    secretKey: 'your_secret_key',
})

const response = await fetch(
    'https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
    { headers }
)
const result = await response.json()

Success Response (200)

json
{
    "success": true,
    "data": {
        "id": "cm1a2b3c4d5e6f7g8h9i0",
        "name": "สำนักงานใหญ่",
        "isActive": true,
        "ipAddress": null,
        "limitQuota": 10000,
        "usedQuota": 1500,
        "totalUsedQuota": 45000,
        "bankAccounts": [
            {
                "id": "cm9z8y7x6w5v4u3t2s1r0",
                "bankCode": "004",
                "bankNumber": "123-4-56789-0",
                "nameTh": "บริษัท อีซี่สลิป จำกัด",
                "nameEn": "EasySlip Co., Ltd."
            }
        ],
        "createdAt": "2024-06-15T10:30:00+07:00",
        "updatedAt": "2024-12-01T14:00:00+07:00"
    }
}

Error Response (404)

json
{
    "success": false,
    "error": {
        "code": "BRANCH_NOT_FOUND",
        "message": "Branch not found"
    }
}

สร้างสาขาใหม่

http
POST /b2b/branches

Full URL: https://api.easyslip.com/b2b/branches

Permission: branch:write

Request Body

ฟิลด์ชนิดจำเป็นคำอธิบาย
namestringใช่ชื่อสาขา
limitQuotanumber | nullไม่โควตาสูงสุด (null หรือไม่ส่งเพื่อใช้โควตาระดับบริการ)
bankAccountIdsstring[]ไม่ID บัญชีธนาคารที่ต้องการเชื่อมต่อ

ตัวอย่าง

bash
curl -X POST https://api.easyslip.com/b2b/branches \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${API_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Nonce: ${NONCE}" \
  -H "X-Signature: ${SIGNATURE}" \
  -d '{
    "name": "สาขาขอนแก่น",
    "limitQuota": 3000,
    "bankAccountIds": ["cm9z8y7x6w5v4u3t2s1r0"]
  }'
javascript
const body = {
    name: 'สาขาขอนแก่น',
    limitQuota: 3000,
    bankAccountIds: ['cm9z8y7x6w5v4u3t2s1r0'],
}

const headers = signRequest({
    method: 'POST',
    path: '/b2b/branches',
    body,
    apiKey: 'your_api_key',
    secretKey: 'your_secret_key',
})

const response = await fetch('https://api.easyslip.com/b2b/branches', {
    method: 'POST',
    headers,
    body: JSON.stringify(body),
})
const result = await response.json()

Success Response (201)

json
{
    "success": true,
    "data": {
        "id": "cm3c4d5e6f7g8h9i0j1k2",
        "name": "สาขาขอนแก่น",
        "isActive": true,
        "ipAddress": null,
        "limitQuota": 3000,
        "usedQuota": 0,
        "totalUsedQuota": 0,
        "bankAccounts": [
            {
                "id": "cm9z8y7x6w5v4u3t2s1r0",
                "bankCode": "004",
                "bankNumber": "123-4-56789-0",
                "nameTh": "บริษัท อีซี่สลิป จำกัด",
                "nameEn": "EasySlip Co., Ltd."
            }
        ],
        "createdAt": "2025-01-10T11:00:00+07:00",
        "updatedAt": "2025-01-10T11:00:00+07:00"
    }
}

แก้ไขสาขา

http
PATCH /b2b/branches/:branchId

Full URL: https://api.easyslip.com/b2b/branches/:branchId

Permission: branch:write

Request Body

ทุกฟิลด์เป็น optional ส่งเฉพาะฟิลด์ที่ต้องการแก้ไข

ฟิลด์ชนิดคำอธิบาย
namestringชื่อสาขา
isActivebooleanสถานะการใช้งาน
ipAddressstring | nullIP address ที่อนุญาต (null เพื่ออนุญาตทุก IP)
bankAccountIdsstring[]แทนที่บัญชีธนาคารที่เชื่อมต่อด้วยรายการนี้

ตัวอย่าง

bash
curl -X PATCH https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0 \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${API_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Nonce: ${NONCE}" \
  -H "X-Signature: ${SIGNATURE}" \
  -d '{
    "name": "สำนักงานใหญ่ กรุงเทพฯ",
    "ipAddress": "203.150.100.10"
  }'
javascript
const body = {
    name: 'สำนักงานใหญ่ กรุงเทพฯ',
    ipAddress: '203.150.100.10',
}

const headers = signRequest({
    method: 'PATCH',
    path: '/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
    body,
    apiKey: 'your_api_key',
    secretKey: 'your_secret_key',
})

const response = await fetch(
    'https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
    {
        method: 'PATCH',
        headers,
        body: JSON.stringify(body),
    }
)
const result = await response.json()

Success Response (200)

json
{
    "success": true,
    "data": {
        "id": "cm1a2b3c4d5e6f7g8h9i0",
        "name": "สำนักงานใหญ่ กรุงเทพฯ",
        "isActive": true,
        "ipAddress": "203.150.100.10",
        "limitQuota": 10000,
        "usedQuota": 1500,
        "totalUsedQuota": 45000,
        "bankAccounts": [
            {
                "id": "cm9z8y7x6w5v4u3t2s1r0",
                "bankCode": "004",
                "bankNumber": "123-4-56789-0",
                "nameTh": "บริษัท อีซี่สลิป จำกัด",
                "nameEn": "EasySlip Co., Ltd."
            }
        ],
        "createdAt": "2024-06-15T10:30:00+07:00",
        "updatedAt": "2025-01-10T15:00:00+07:00"
    }
}

ลบสาขา

http
DELETE /b2b/branches/:branchId

Full URL: https://api.easyslip.com/b2b/branches/:branchId

Permission: branch:write

WARNING

การลบเป็นแบบ soft delete สาขาจะถูกปิดใช้งานและทำเครื่องหมายว่าถูกลบ แต่ข้อมูลยังคงถูกเก็บไว้

ตัวอย่าง

bash
curl -X DELETE https://api.easyslip.com/b2b/branches/cm2b3c4d5e6f7g8h9i0j1 \
  -H "X-API-Key: ${API_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Nonce: ${NONCE}" \
  -H "X-Signature: ${SIGNATURE}"
javascript
const headers = signRequest({
    method: 'DELETE',
    path: '/b2b/branches/cm2b3c4d5e6f7g8h9i0j1',
    body: null,
    apiKey: 'your_api_key',
    secretKey: 'your_secret_key',
})

const response = await fetch(
    'https://api.easyslip.com/b2b/branches/cm2b3c4d5e6f7g8h9i0j1',
    { method: 'DELETE', headers }
)
const result = await response.json()

Success Response (200)

json
{
    "success": true,
    "data": {
        "id": "cm2b3c4d5e6f7g8h9i0j1",
        "name": "สาขาเชียงใหม่",
        "isActive": false,
        "deletedAt": "2025-01-10T16:00:00+07:00"
    }
}

Error Responses

ไม่พบสาขา (404)

json
{
    "success": false,
    "error": {
        "code": "BRANCH_NOT_FOUND",
        "message": "Branch not found"
    }
}

ข้อมูลไม่ถูกต้อง (400)

json
{
    "success": false,
    "error": {
        "code": "VALIDATION_ERROR",
        "message": "Branch name is required"
    }
}

Bank Slip Verification API for Thai Banking