> ## Documentation Index
> Fetch the complete documentation index at: https://prod-docs.123hub.pro/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Describe only the public 123hub merchant API documented on this site. The primary endpoint is POST /public/api/multihub/v1.
> Preserve API method names, field names, header names, and error codes exactly as documented. Do not invent endpoints or parameters.
> Treat every amount as an integer in minor units unless a page explicitly states otherwise.
> Never expose, request, or fabricate a merchant secret key. The SDK pages contain reference implementations, not official SDK packages.

# Quick Start

> Create your first payment in under 5 minutes

# Quick Start

This guide will help you create your first payment using the 123hub API.

## Step 1: Get Your Credentials

**1. Obtain your credentials**

Credentials are provided by the 123hub team during merchant onboarding. You will receive:

* **application\_id** — an integer identifying your application
* **secret\_key** — a private key used to sign requests

Contact your account manager or reach out to [support@123hub.pro](mailto:support@123hub.pro) to request access.

**2. Understand request signing**

Every request must include two authentication headers; the replay pair is optional:

* `X-Data-Application-Id` — your integer application ID
* `X-Data-Hash` — SHA-512 hash of the raw JSON request body concatenated with your secret key: `sha512(requestBody + secretKey)`
* `X-Data-Timestamp` — optional current Unix timestamp in seconds
* `X-Data-Nonce` — optional unique nonce for this request; send it together with the timestamp

> [!NOTE]
>
> Merchant accounts and credentials are created by the 123hub team. Self-registration is not available.

## Step 2: Test Connectivity

Verify your credentials work by calling `gateway.ping`:

```bash cURL theme={null}
BODY='{"method":"gateway.ping","params":{}}'
HASH=$(printf '%s%s' "$BODY" "YOUR_SECRET_KEY" | sha512sum | awk '{print $1}')
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')

curl -X POST "https://api.bafanglaicai88.com/public/api/multihub/v1" \
  -H "Content-Type: application/json" \
  -H "X-Data-Application-Id: 1" \
  -H "X-Data-Hash: ${HASH}" \
  -H "X-Data-Timestamp: ${TIMESTAMP}" \
  -H "X-Data-Nonce: ${NONCE}" \
  --data-binary "${BODY}"
```

```python Python theme={null}
import requests
import hashlib
import json
import time
import uuid

APPLICATION_ID = 1
SECRET_KEY = "your_secret_key_here"
URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

payload = {
    "method": "gateway.ping",
    "params": {}
}

body = json.dumps(payload, separators=(",", ":"))
signature = hashlib.sha512((body + SECRET_KEY).encode()).hexdigest()

headers = {
    "Content-Type": "application/json",
    "X-Data-Application-Id": str(APPLICATION_ID),
    "X-Data-Hash": signature,
    "X-Data-Timestamp": str(int(time.time())),
    "X-Data-Nonce": str(uuid.uuid4())
}

response = requests.post(URL, data=body, headers=headers, timeout=(3.05, 30))
print(response.json())
```

```javascript Node.js theme={null}
const crypto = require('crypto');
const axios = require('axios');

const APPLICATION_ID = 1;
const SECRET_KEY = 'your_secret_key_here';
const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

const payload = {
  method: 'gateway.ping',
  params: {}
};

const body = JSON.stringify(payload);
const signature = crypto.createHash('sha512').update(body + SECRET_KEY).digest('hex');
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = crypto.randomUUID();

const response = await axios.post(URL, body, {
  headers: {
    'Content-Type': 'application/json',
    'X-Data-Application-Id': String(APPLICATION_ID),
    'X-Data-Hash': signature,
    'X-Data-Timestamp': timestamp,
    'X-Data-Nonce': nonce
  },
  timeout: 30000
});

console.log(response.data);
```

**Response:**

```json theme={null}
{
  "success": true,
  "result": {
    "message": "pong"
  },
  "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "processing_time": 5
}
```

## Step 3: Create a Deposit

Create a deposit payment (customer pays to you) using the `payment.in` method.

> [!NOTE]
>
> The `service_id` value is assigned per merchant during onboarding. It determines the provider, payment method, and currency for the payment. Use the value provided by your account manager. The examples below use placeholder `service_id` values for illustration.

The example below is an India UPI deposit. For your market, open its page under
[Countries](https://prod-docs.123hub.pro/countries/overview.md) — it has the same request with that country's values and fields.

```bash cURL theme={null}
BODY='{"method":"payment.in","service_id":14701,"params":{"payment":{"description":"Order #12345","identifiers":{"c_id":"12345"},"amount":{"value":10000,"currency":"INR"},"payer":{"email":"customer@example.com","phone":"9876543210","person":{"first_name":"John","last_name":"Doe"}},"client":{"language":"EN","country":"IN"}}}}'
HASH=$(printf '%s%s' "$BODY" "YOUR_SECRET_KEY" | sha512sum | awk '{print $1}')
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')

curl -X POST "https://api.bafanglaicai88.com/public/api/multihub/v1" \
  -H "Content-Type: application/json" \
  -H "X-Data-Application-Id: 1" \
  -H "X-Data-Hash: ${HASH}" \
  -H "X-Data-Timestamp: ${TIMESTAMP}" \
  -H "X-Data-Nonce: ${NONCE}" \
  --data-binary "${BODY}"
```

```python Python theme={null}
import requests
import hashlib
import json
import time
import uuid

APPLICATION_ID = 1
SECRET_KEY = "your_secret_key_here"
URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

payload = {
"method": "payment.in",
"service_id": 14701,
"params": {
    "payment": {
        "description": "Order #12345",
        "identifiers": {"c_id": "12345"},
        "amount": {"value": 10000, "currency": "INR"},
        "payer": {
            "email": "customer@example.com",
            "phone": "9876543210",
            "person": {"first_name": "John", "last_name": "Doe"}
        },
        "client": {"language": "EN", "country": "IN"}
    }
}
}

body = json.dumps(payload, separators=(",", ":"))
signature = hashlib.sha512((body + SECRET_KEY).encode()).hexdigest()

headers = {
"Content-Type": "application/json",
"X-Data-Application-Id": str(APPLICATION_ID),
"X-Data-Hash": signature,
"X-Data-Timestamp": str(int(time.time())),
"X-Data-Nonce": str(uuid.uuid4())
}

response = requests.post(URL, data=body, headers=headers, timeout=(3.05, 30))
print(response.json())
```

```javascript Node.js theme={null}
const crypto = require('crypto');
const axios = require('axios');

const APPLICATION_ID = 1;
const SECRET_KEY = 'your_secret_key_here';
const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

const payload = {
  method: 'payment.in',
  service_id: 14701,
  params: {
payment: {
  description: 'Order #12345',
  identifiers: { c_id: '12345' },
  amount: { value: 10000, currency: 'INR' },
  payer: {
    email: 'customer@example.com',
    phone: '9876543210',
    person: { first_name: 'John', last_name: 'Doe' }
  },
  client: { language: 'EN', country: 'IN' }
}
  }
};

const body = JSON.stringify(payload);
const signature = crypto.createHash('sha512').update(body + SECRET_KEY).digest('hex');
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = crypto.randomUUID();

const response = await axios.post(URL, body, {
  headers: {
'Content-Type': 'application/json',
'X-Data-Application-Id': String(APPLICATION_ID),
'X-Data-Hash': signature,
'X-Data-Timestamp': timestamp,
'X-Data-Nonce': nonce
  },
  timeout: 30000
});

console.log(response.data);
```

### Response

```json theme={null}
{
  "success": true,
  "result": {
    "payment": {
      "amount": { "value": 10000, "currency": "INR" },
      "description": "Order #12345",
      "identifiers": { "c_id": "12345", "h_id": "1001", "p_id": "txn_abc123" },
      "status": { "status": "created", "final": false, "success": null },
      "timestamps": { "created": "2026-01-15T10:30:00Z" },
      "destination": "in",
      "service_id": 14701
    }
  },
  "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "processing_time": 125
}
```

## Step 4: Check Payment Status

Use `payment.status` with the `h_id` returned from the deposit to check its current status:

```bash cURL theme={null}
BODY='{"method":"payment.status","params":{"payment":{"identifiers":{"h_id":"1001"}}}}'
HASH=$(printf '%s%s' "$BODY" "YOUR_SECRET_KEY" | sha512sum | awk '{print $1}')
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')

curl -X POST "https://api.bafanglaicai88.com/public/api/multihub/v1" \
  -H "Content-Type: application/json" \
  -H "X-Data-Application-Id: 1" \
  -H "X-Data-Hash: ${HASH}" \
  -H "X-Data-Timestamp: ${TIMESTAMP}" \
  -H "X-Data-Nonce: ${NONCE}" \
  --data-binary "${BODY}"
```

```python Python theme={null}
import requests
import hashlib
import json
import time
import uuid

APPLICATION_ID = 1
SECRET_KEY = "your_secret_key_here"
URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

payload = {
    "method": "payment.status",
    "params": {
        "payment": {
            "identifiers": {"h_id": "1001"}
        }
    }
}

body = json.dumps(payload, separators=(",", ":"))
signature = hashlib.sha512((body + SECRET_KEY).encode()).hexdigest()

headers = {
    "Content-Type": "application/json",
    "X-Data-Application-Id": str(APPLICATION_ID),
    "X-Data-Hash": signature,
    "X-Data-Timestamp": str(int(time.time())),
    "X-Data-Nonce": str(uuid.uuid4())
}

response = requests.post(URL, data=body, headers=headers, timeout=(3.05, 30))
print(response.json())
```

```javascript Node.js theme={null}
const crypto = require('crypto');
const axios = require('axios');

const APPLICATION_ID = 1;
const SECRET_KEY = 'your_secret_key_here';
const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

const payload = {
  method: 'payment.status',
  params: {
    payment: {
      identifiers: { h_id: '1001' }
    }
  }
};

const body = JSON.stringify(payload);
const signature = crypto.createHash('sha512').update(body + SECRET_KEY).digest('hex');
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = crypto.randomUUID();

const response = await axios.post(URL, body, {
  headers: {
    'Content-Type': 'application/json',
    'X-Data-Application-Id': String(APPLICATION_ID),
    'X-Data-Hash': signature,
    'X-Data-Timestamp': timestamp,
    'X-Data-Nonce': nonce
  },
  timeout: 30000
});

console.log(response.data);
```

**Response:**

```json theme={null}
{
  "success": true,
  "result": {
    "payment": {
      "payer": {
        "email": "customer@example.com",
        "phone": "9876543210",
        "person": { "first_name": "John", "last_name": "Doe" }
      },
      "amount": { "value": 10000, "currency": "INR" },
      "description": "Order #12345",
      "identifiers": { "c_id": "12345", "h_id": "1001", "p_id": "txn_abc123" },
      "status": {
        "status": "processing",
        "final": false,
        "success": null,
        "history": [
          { "status": "created", "final": false, "success": null, "created": "2026-01-15T10:30:00Z", "reason": null, "amount": 10000 },
          { "status": "processing", "final": false, "success": null, "created": "2026-01-15T10:30:05Z", "reason": null, "amount": 10000 }
        ]
      },
      "timestamps": {
        "created": "2026-01-15T10:30:00Z",
        "updated": "2026-01-15T10:30:05Z"
      },
      "destination": "in",
      "service_id": 14701
    }
  },
  "request_id": "d4e5f6a7-b8c9-0123-defa-234567890123",
  "processing_time": 42
}
```

## Step 5: Check Balance

Use `balance.get` to retrieve your current account balance:

```bash cURL theme={null}
BODY='{"method":"balance.get","params":{}}'
HASH=$(printf '%s%s' "$BODY" "YOUR_SECRET_KEY" | sha512sum | awk '{print $1}')
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')

curl -X POST "https://api.bafanglaicai88.com/public/api/multihub/v1" \
  -H "Content-Type: application/json" \
  -H "X-Data-Application-Id: 1" \
  -H "X-Data-Hash: ${HASH}" \
  -H "X-Data-Timestamp: ${TIMESTAMP}" \
  -H "X-Data-Nonce: ${NONCE}" \
  --data-binary "${BODY}"
```

```python Python theme={null}
import requests
import hashlib
import json
import time
import uuid

APPLICATION_ID = 1
SECRET_KEY = "your_secret_key_here"
URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

payload = {
    "method": "balance.get",
    "params": {}
}

body = json.dumps(payload, separators=(",", ":"))
signature = hashlib.sha512((body + SECRET_KEY).encode()).hexdigest()

headers = {
    "Content-Type": "application/json",
    "X-Data-Application-Id": str(APPLICATION_ID),
    "X-Data-Hash": signature,
    "X-Data-Timestamp": str(int(time.time())),
    "X-Data-Nonce": str(uuid.uuid4())
}

response = requests.post(URL, data=body, headers=headers, timeout=(3.05, 30))
print(response.json())
```

```javascript Node.js theme={null}
const crypto = require('crypto');
const axios = require('axios');

const APPLICATION_ID = 1;
const SECRET_KEY = 'your_secret_key_here';
const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

const payload = {
  method: 'balance.get',
  params: {}
};

const body = JSON.stringify(payload);
const signature = crypto.createHash('sha512').update(body + SECRET_KEY).digest('hex');
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = crypto.randomUUID();

const response = await axios.post(URL, body, {
  headers: {
    'Content-Type': 'application/json',
    'X-Data-Application-Id': String(APPLICATION_ID),
    'X-Data-Hash': signature,
    'X-Data-Timestamp': timestamp,
    'X-Data-Nonce': nonce
  },
  timeout: 30000
});

console.log(response.data);
```

**Response:**

```json theme={null}
{
  "success": true,
  "result": {
    "balance": {
      "id": 0,
      "amounts": [
        { "value": 500000, "value_freezing": 10000, "value_blocking": 0, "currency": "INR", "enabled": true },
        { "value": 250000, "value_freezing": 5000, "value_blocking": 0, "currency": "MXN", "enabled": true },
        { "value": 1000000, "value_freezing": 0, "value_blocking": 0, "currency": "ARS", "enabled": true },
        { "value": 75000, "value_freezing": 0, "value_blocking": 0, "currency": "TRY", "enabled": true }
      ],
      "enabled": true
    }
  },
  "request_id": "e5f6a7b8-c9d0-1234-efab-345678901234",
  "processing_time": 18
}
```

## Understanding the Response

All API responses follow the same envelope format:

| Field | Description |
| - | - |
| `success` | `true` if the request succeeded, `false` if an error occurred |
| `result` | The response payload (structure varies by method) |
| `error` | Present only on failure. Contains `code` (integer), `message` (string), `details`, and `context` |
| `request_id` | Unique identifier for this request (useful for debugging) |
| `processing_time` | Server processing time in milliseconds |

### Payment identifiers

| Identifier | Description |
| - | - |
| `c_id` | Your client-side string identifier (the value you send) |
| `h_id` | Hub-assigned payment identifier. You can use it for status queries. |
| `p_id` | Provider-assigned transaction identifier. It is returned for reconciliation and is not accepted as a status lookup key. |

### Payment statuses

| Status | `final` | `success` | Description |
| - | :-: | :-: | - |
| `created` | `false` | `null` | Payment created, awaiting processing |
| `processing` | `false` | `null` | Payment is being processed |
| `success` | `true` | `true` | Payment completed successfully |
| `error` | `true` | `false` | Payment failed |
| `canceled` | `true` | `false` | Payment was cancelled |
| `declined` | `true` | `false` | Payment expired or was declined |
| `refunded` | `true` | `true` | Payment was refunded |
| `partially_refunded` | `true` | `true` | Partial refund processed |

## What's Next?

> [card] [Set up Webhooks](https://prod-docs.123hub.pro/guides/webhooks.md)
>
> Receive real-time notifications when the payment completes

> [card] [Payment Types](https://prod-docs.123hub.pro/guides/payments.md)
>
> Learn about deposits, withdrawals, and payment pages

> [card] [Test Your Integration](https://prod-docs.123hub.pro/guides/testing.md)
>
> Validate signing, payments, balances, and webhooks before production traffic

> [card] [Balance Management](https://prod-docs.123hub.pro/guides/balance.md)
>
> Monitor and manage your merchant balances

> [card] [Go Live](https://prod-docs.123hub.pro/go-live.md)
>
> Switch to production when you're ready

## Common Issues

> [accordion] Error 3000: Authentication Error
>
> Verify that `X-Data-Hash` is computed as `sha512(requestBody + secretKey)` where `requestBody` is the exact JSON string sent in the request body. Ensure there is no extra whitespace or encoding difference between what you hash and what you send.

> [accordion] Error 3003: Application Not Found
>
> Check that the `X-Data-Application-Id` header contains your correct integer application ID.

> [accordion] Error 1005: Invalid Request Format
>
> Ensure all required fields are present in your request. For `payment.in`, you must include `service_id` and the `params.payment` object with `amount` (`value` and `currency`), `identifiers.c_id`, and `payer`; for `payment.out`, `receiver.bank.account.id` instead of `payer`. Send `c_id` as a string. Check the `details` field in the error response for specifics. A missing or misspelled `method`, unknown fields and wrong types return `9000` instead.

> [accordion] Error 2002: No Route Available
>
> The `service_id` does not exist, or it belongs to the other direction — for example a withdrawal `service_id` sent with `payment.in`. Check the value and direction your account manager issued.

> [accordion] Error 1002: Payment Method Not Available (HTTP 404)
>
> The route behind your `service_id` is not enabled for your account, or is outside its availability hours. Contact your account manager to verify your service configuration.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.