Skip to content

Verify by Image

Verify a bank slip by uploading an image file.

Endpoint

http
POST /verify/bank

Full URL: https://api.easyslip.com/v2/verify/bank

Authentication

Required. See Authentication Guide.

http
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-data

Request

Parameters

ParameterTypeRequiredDescription
imageFileYesSlip image file
remarkstringNoCustom remark (1-255 characters)
matchAccountbooleanNoMatch receiver with registered accounts
matchAmountnumberNoExpected amount to validate
checkDuplicatebooleanNoCheck for duplicate slip

Image Requirements

RequirementValue
Maximum size4 MB (4,194,304 bytes)
Supported formatsJPEG, PNG, GIF, WebP
QR code visibilityMust be clear and readable

Type Definitions

typescript
// Request (multipart/form-data)
interface VerifyByImageRequest {
  image: File;              // Image file
  remark?: string;          // 1-255 chars
  matchAccount?: boolean;
  matchAmount?: number;
  checkDuplicate?: boolean;
}

// Response
interface VerifyBankResponse {
  success: true;
  data: VerifyBankData;
  message: string;
}

interface VerifyBankData {
  remark?: string;
  isDuplicate: boolean;
  matchedAccount: MatchedAccount | null;
  amountInOrder?: number;
  amountInSlip: number;
  isAmountMatched?: boolean;
  rawSlip: RawSlip;
}

// See POST /verify/bank for full type definitions

Examples

bash
curl -X POST https://api.easyslip.com/v2/verify/bank \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "image=@/path/to/slip.jpg" \
  -F "checkDuplicate=true"
javascript
const verifyByImage = async (file, options = {}) => {
  const formData = new FormData();
  formData.append('image', file);

  Object.entries(options).forEach(([key, value]) => {
    formData.append(key, String(value));
  });

  const response = await fetch('https://api.easyslip.com/v2/verify/bank', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: formData
  });

  const result = await response.json();

  if (!result.success) {
    throw new Error(result.error.message);
  }

  return result.data;
};

// Usage with file input
const fileInput = document.getElementById('slipImage');
fileInput.addEventListener('change', async (e) => {
  const file = e.target.files[0];

  try {
    const slip = await verifyByImage(file, { checkDuplicate: true });
    console.log('Amount:', slip.rawSlip.amount.amount);
  } catch (error) {
    console.error('Error:', error.message);
  }
});
javascript
import fs from 'fs';
import FormData from 'form-data';

const verifyByImage = async (filePath, options = {}) => {
  const formData = new FormData();
  formData.append('image', fs.createReadStream(filePath));

  Object.entries(options).forEach(([key, value]) => {
    formData.append(key, String(value));
  });

  const response = await fetch('https://api.easyslip.com/v2/verify/bank', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.EASYSLIP_API_KEY}`,
      ...formData.getHeaders()
    },
    body: formData
  });

  const result = await response.json();

  if (!result.success) {
    throw new Error(result.error.message);
  }

  return result.data;
};

// Usage
const slip = await verifyByImage('./slip.jpg', { checkDuplicate: true });
console.log('Amount:', slip.rawSlip.amount.amount);
php
function verifyByImage(string $filePath, array $options = []): array
{
    $apiKey = getenv('EASYSLIP_API_KEY');

    $postFields = ['image' => new CURLFile($filePath)];

    foreach ($options as $key => $value) {
        $postFields[$key] = is_bool($value) ? ($value ? 'true' : 'false') : $value;
    }

    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => 'https://api.easyslip.com/v2/verify/bank',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
        CURLOPT_POSTFIELDS => $postFields
    ]);

    $response = curl_exec($ch);
    curl_close($ch);

    $result = json_decode($response, true);

    if (!$result['success']) {
        throw new Exception($result['error']['message']);
    }

    return $result['data'];
}

// Usage
$slip = verifyByImage('/path/to/slip.jpg', ['checkDuplicate' => true]);
echo "Amount: " . $slip['rawSlip']['amount']['amount'];
python
import requests
import os

def verify_by_image(file_path: str, **options) -> dict:
    with open(file_path, 'rb') as f:
        files = {'image': f}
        data = {k: str(v).lower() if isinstance(v, bool) else v for k, v in options.items()}

        response = requests.post(
            'https://api.easyslip.com/v2/verify/bank',
            headers={'Authorization': f'Bearer {os.environ["EASYSLIP_API_KEY"]}'},
            files=files,
            data=data
        )

    result = response.json()

    if not result['success']:
        raise Exception(result['error']['message'])

    return result['data']

# Usage
slip = verify_by_image('./slip.jpg', checkDuplicate=True)
print(f"Amount: {slip['rawSlip']['amount']['amount']}")

Response

Success (200)

json
{
  "success": true,
  "data": {
    "isDuplicate": false,
    "rawSlip": {
      "payload": "00000000000000000000000000000000000000000000000",
      "transRef": "68370160657749I376388B35",
      "date": "2024-01-15T14:30:00+07:00",
      "amount": {
        "amount": 1500.00
      },
      "sender": {
        "bank": { "id": "004", "name": "กสิกรไทย", "short": "KBANK" },
        "account": { "name": { "th": "นาย ผู้โอน ทดสอบ" } }
      },
      "receiver": {
        "bank": { "id": "014", "name": "ไทยพาณิชย์", "short": "SCB" },
        "account": { "name": { "th": "นาย รับเงิน ทดสอบ" } }
      }
    }
  },
  "message": "Bank slip verified successfully"
}

Error Responses

Image Size Too Large (400)

json
{
  "success": false,
  "error": {
    "code": "IMAGE_SIZE_TOO_LARGE",
    "message": "Image size exceeds 4MB limit"
  }
}

Invalid Image Format (400)

json
{
  "success": false,
  "error": {
    "code": "INVALID_IMAGE_FORMAT",
    "message": "The file is not a valid image"
  }
}

QR Code Not Found (404)

json
{
  "success": false,
  "error": {
    "code": "SLIP_NOT_FOUND",
    "message": "No QR code found in the image"
  }
}

Notes

  • Ensure the QR code is clearly visible and not blurry
  • Crop the image to focus on the QR code area for faster processing
  • Compress large images before uploading
  • The API handles image rotation automatically

Bank Slip Verification API for Thai Banking