Quick Start

Integrate SePay SoundBox API in 5 minutes. Pair a speaker device and send your first balance notification.


This guide walks you through integrating SePay SoundBox API: from getting a token, pairing a speaker device, to sending your first balance notification.

Prerequisites

  • Signed partnership agreement with SePay
  • Received client_id and client_secret
  • Have a SePay SoundBox device (e.g., model S5 Plus)
  • Device is powered on and connected to the network

Base URL

Code
1
https://speaker-api.sepay.vn/devices/v1

Step 1: Get Access Token

Call the token API using Basic Auth with client_id as username and client_secret as password.

Bash
1
2
curl -X POST https://speaker-api.sepay.vn/devices/v1/token/create \
-u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"
{
  "code": 201,
  "message": "Resource created",
  "data": "—",
  "access_token": "eyJhbGciOi...",
  "ttl": 6000
}
Note

Token is valid for 6000 seconds (100 minutes). Use it in the Authorization: Bearer {access_token} header for all subsequent APIs.


Step 2: Check Device

Check the device status using the serial number (hardwareId) printed on the device.

Bash
1
2
3
4
curl -X POST https://speaker-api.sepay.vn/devices/v1/speaker/pair/check \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{"hardwareId": "VNS52508000001"}'
{
  "code": 200,
  "message": "Thành công",
  "data": {
    "hardwareId": "VNS52508000001",
    "model": "S5 Plus",
    "isPaired": false,
    "online": false
  }
}

Check isPaired (already linked or not) and online (device is on and connected) before proceeding.


Step 3: Pair Device

3a. Switch Device to Pairing Mode

Hold the button on the device to switch to Pairing Mode.

3b. Send Pairing Request

Bash
1
2
3
4
curl -X POST https://speaker-api.sepay.vn/devices/v1/speaker/pair/request \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{"hardwareId": "VNS52508000001"}'
{
  "code": 200,
  "message": "Thành công",
  "data": {
    "hardwareId": "VNS52508000001",
    "model": "S5 Plus",
    "isPaired": false,
    "session_id": "8b9f6d2a-3c1b-4f7a-a7d4-123456789abc",
    "online": true
  }
}

The device will read a 4-digit OTP code aloud. Save the session_id for the next step.

Expiration

session_id is only valid for approximately 2 minutes. Verify the OTP promptly.

3c. Verify OTP

Send the OTP code that the device just read aloud:

Bash
1
2
3
4
5
6
7
8
curl -X POST https://speaker-api.sepay.vn/devices/v1/speaker/pair/verify \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"hardwareId": "VNS52508000001",
"session_id": "8b9f6d2a-3c1b-4f7a-a7d4-123456789abc",
"otp": "1234"
}'
{
  "code": 200,
  "message": "Liên kết thành công",
  "data": {
    "hardwareId": "VNS52508000001",
    "model": "S5 Plus",
    "isPaired": true,
    "pairedTime": "2025-05-23 16:06:38"
  }
}

The device is now ready to receive notifications.


Step 4: Send Balance Notification

Send an amount for the device to read aloud:

Bash
1
2
3
4
5
6
7
8
curl -X POST https://speaker-api.sepay.vn/devices/v1/speaker/transactions/notify \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"hardwareId": "VNS52508000001",
"amount": 150000,
"requestId": "TXN202510130001"
}'
{
  "code": 200,
  "message": "Đã gửi thông báo thành công",
  "data": {
    "hardwareId": "VNS52508000001",
    "requestId": "TXN202510130001",
    "status": "SENT"
  }
}
Idempotency

requestId must be unique per transaction. Duplicate requestId values will not be reprocessed, preventing duplicate notifications.


Step 5 (Optional): Check Notification Status

Verify whether the notification was successfully delivered to the device:

Bash
1
2
3
4
curl -X POST https://speaker-api.sepay.vn/devices/v1/speaker/transactions/check_notify \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{"requestId": "TXN202510130001"}'
{
  "code": 200,
  "message": "Thành công",
  "data": {
    "requestId": "TXN202510130001",
    "hardwareId": "VNS52508000001",
    "amount": "150000",
    "status": "SUCCESS",
    "message": "Gửi thông báo thành công",
    "retriesCount": "0",
    "lastRetryTime": null,
    "createdAt": "2025-10-14 21:17:32"
  }
}

Possible statuses: PENDING (processing), SUCCESS (delivered), FAILED (failed).


Integration Flow Summary

StepAPIDescription
1POST /token/createGet access token (Basic Auth)
2POST /speaker/pair/checkCheck device status
3POST /speaker/pair/requestSend pairing request, receive OTP
4POST /speaker/pair/verifyVerify OTP, complete pairing
5POST /speaker/transactions/notifySend balance notification
6POST /speaker/transactions/check_notifyCheck notification status

Common Error Codes

CodeMeaningAction
400Missing or invalid parametersCheck request body
401Invalid or expired tokenCreate a new token
404Device not foundVerify hardwareId

Next Steps

See detailed documentation for each API endpoint with full parameters, error codes, and code samples: