Tham Khảo API

Tích hợp PrivCards vào ứng dụng của bạn. Phát hành, nạp tiền, đóng băng và quản lý thẻ ảo bằng chương trình thông qua REST API của chúng tôi.

URL Cơ Sởhttps://api.privcards.com/v1
JSON RESTful
Xác Thực Bearer
Môi Trường Sandbox
Webhooks
Xác Thực

Khóa API & Xác Thực

Tất cả yêu cầu API yêu cầu token Bearer. Tạo khóa API từ Bảng điều khiển → Cài đặt → Khóa API.

Bảo Mật Khóa API

Không bao giờ tiết lộ khóa của bạn trong mã phía client. Sử dụng biến môi trường. Khóa có tiền tố sk_live_ là production, sk_test_ là sandbox.

request-headers
Authorization: Bearer sk_live_your_api_key_here
Content-Type: application/json
X-Idempotency-Key: optional-unique-key-for-safe-retries
Giới Hạn Tốc Độ
1.000
Yêu cầu / Phút
50
Thẻ / Phút
10.000
Yêu cầu / Giờ
Mã Lỗi
error-response.json
{
  "error": "insufficient_funds",
  "message": "Your wallet balance is too low to fund this card.",
  "code": 400,
  "request_id": "req_7f8a9b2c3d4e"
}
200
Yêu cầu thành công
201
Tài nguyên đã tạo
400
Tham số không hợp lệ
401
Khóa API thiếu hoặc không hợp lệ
404
Không tìm thấy tài nguyên
429
Vượt quá giới hạn tốc độ
Thẻ

Quản Lý Thẻ

Tạo, quản lý và kiểm soát thẻ ảo Visa & Mastercard. Mỗi thẻ được cô lập với số dư, giới hạn và vòng đời riêng.

Body Yêu Cầu
ParameterTypeDescription
bin_idstringrequiredBIN identifier (e.g. 491653). Use GET /bins to list available BINs.
amountnumberrequiredInitial funding amount in USD. Min: $1.00, Max: $5,000.00
labelstringoptionalCustom label for the card (max 64 chars)
spending_limitnumberoptionalMonthly spending limit in USD. Defaults to BIN maximum.
allowed_categoriesstring[]optionalMCC categories to whitelist (e.g. ["advertising", "software"])
auto_freeze_atnumberoptionalAuto-freeze when balance drops below this amount
metadataobjectoptionalKey-value pairs for your internal tracking (max 20 keys)
Yêu Cầu Ví Dụ
curl
curl -X POST https://api.privcards.com/v1/cards \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "bin_id": "491653",
    "amount": 500,
    "label": "Meta Ads Campaign #12",
    "spending_limit": 2000,
    "allowed_categories": ["advertising"],
    "metadata": {"campaign": "spring_2026"}
  }'
Response 201 Created
response.json
{
  "id": "card_8xK2m9Lp4q",
  "bin_id": "491653",
  "network": "visa",
  "last4": "2039",
  "status": "active",
  "balance": 500.00,
  "spending_limit": 2000.00,
  "label": "Meta Ads Campaign #12",
  "allowed_categories": ["advertising"],
  "auto_freeze_at": null,
  "metadata": { "campaign": "spring_2026" },
  "created_at": "2026-04-15T12:00:00Z",
  "expires_at": "2029-04-15T23:59:59Z"
}
Tham Số Query
ParameterTypeDescription
statusstringoptionalactive, frozen, terminated
bin_idstringoptionalFilter by BIN
pageintegeroptionalPage number. Default: 1
per_pageintegeroptionalItems per page (1-100). Default: 25

apiDocs.cards.getDesc

Endpoint Nhạy Cảm

Trả về PAN, CVV và hết hạn đầy đủ. Nhạy cảm PCI — không bao giờ ghi log hoặc lưu trữ không mã hóa. Giới hạn 30 req/min.

Đình chỉ tất cả giao dịch. Số dư được bảo toàn. Thẻ có thể được mở khóa sau.

Kích hoạt lại giao dịch trên thẻ đã đóng băng. Trả về đối tượng thẻ với status: "active".

Hành Động Không Thể Hoàn Tác

Chấm dứt thẻ là vĩnh viễn. Số dư còn lại được trả về ví của bạn ngay lập tức.

Nạp Tiền

Nạp Tiền Thẻ

Thêm hoặc rút tiền từ thẻ riêng lẻ. Tiền đến từ số dư ví của bạn.

Body Yêu Cầu
ParameterTypeDescription
amountnumberrequiredAmount in USD to add. Min: $1.00, Max: $5,000.00

Trả về số dư đã cập nhật của thẻ và ví.

Giao Dịch

Lịch Sử Giao Dịch

Xem tất cả giao dịch trên thẻ của bạn. Bao gồm phê duyệt, thanh toán, hoàn tiền và từ chối.

Tham Số Query
ParameterTypeDescription
card_idstringoptionalFilter by card
typestringoptionalauthorization, settlement, refund, decline
fromstringoptionalStart date (ISO 8601)
tostringoptionalEnd date (ISO 8601)
pageintegeroptionalPage number. Default: 1

Ví & Nạp Tiền

Quản lý ví tài khoản của bạn. Nạp crypto, kiểm tra số dư và theo dõi các khoản nạp đến.

Response 200 OK
response.json
{
  "balance": 1312.50,
  "currency": "USD",
  "pending_deposits": 500.00,
  "total_deposited": 15000.00,
  "total_spent": 13687.50,
  "cards_active": 8,
  "cards_total_balance": 2450.00
}
Tham Số Query
ParameterTypeDescription
currencystringoptionalbtc, eth, sol, usdt. Omit to get all.
BINs

Lựa Chọn BIN

Liệt kê các phạm vi BIN khả dụng với khả năng, giới hạn và tỷ lệ chấp nhận của chúng.

Response 200 OK
response.json
{
  "data": [
    {
      "id": "491653",
      "network": "visa",
      "type": "advertising",
      "3ds": true,
      "apple_pay": true,
      "google_pay": true,
      "max_transaction": 5000.00,
      "max_monthly": 50000.00,
      "acceptance_rate": 97.2,
      "best_for": ["meta_ads", "google_ads", "tiktok_ads"]
    }
  ]
}
3D Secure

Xác Thực 3D Secure

Truy xuất thử thách 3DS và mã OTP. Tất cả thẻ tự động đăng ký 3DS 2.0.

Response 200 OK
response.json
{
  "data": [
    {
      "id": "3ds_m4n5o6p7",
      "card_id": "card_8xK2m9Lp4q",
      "merchant": "SPOTIFY",
      "amount": 9.99,
      "otp": "847291",
      "status": "pending",
      "expires_at": "2026-04-15T15:05:00Z"
    }
  ]
}
Webhooks

Webhooks & Sự Kiện

Nhận thông báo thời gian thực khi có sự kiện. Payload được ký bằng HMAC-SHA256.

Sự Kiện Khả Dụng
card.createdThẻ mới đã được phát hành
card.frozenThẻ đã bị đóng băng
card.unfrozenThẻ đã được mở khóa
card.terminatedThẻ đã bị chấm dứt
card.fundedTiền đã được thêm vào thẻ
transaction.authorizedGiao dịch được phê duyệt
transaction.settledGiao dịch được thanh toán
transaction.declinedGiao dịch bị từ chối
transaction.refundedHoàn tiền được xử lý
3ds.challengeYêu cầu xác minh 3DS
deposit.pendingPhát hiện nạp crypto
deposit.confirmedNạp crypto được xác nhận
Xác Minh Chữ Ký
verify-webhook.py
import hmac, hashlib

def verify_webhook(payload, signature, secret):
    expected = hmac.new(
        secret.encode(),
        payload.encode(),
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, signature)
Body Yêu Cầu
ParameterTypeDescription
urlstringrequiredHTTPS endpoint URL to receive events
eventsstring[]requiredEvent types to subscribe. Use ["*"] for all.
secretstringoptionalCustom signing secret. Auto-generated if omitted.
SDKs

SDKs & Thư Viện

Thư viện client chính thức cho stack của bạn. Tất cả SDK hỗ trợ môi trường live và sandbox.

Python

Python

pip install privcards

Node.js

Node.js

npm i privcards

Go

Go

go get privcards

Bắt Đầu Nhanh — Python
quickstart.py
from privcards import Client

client = Client("sk_live_your_api_key")

# Create a card
card = client.cards.create(
    bin_id="491653",
    amount=500,
    label="Ad Spend"
)
print(card.id, card.last4)

# Get full card details (PAN, CVV)
details = client.cards.details(card.id)
print(details.pan, details.cvv)

# Fund the card
client.cards.fund(card.id, amount=200)

# List transactions
txns = client.transactions.list(card_id=card.id)
for t in txns.data:
    print(t.merchant.name, t.amount)
Bắt Đầu Nhanh — Node.js
quickstart.js
const { privcards } = require('privcards');

const client = new privcards('sk_live_your_api_key');

// Create a card
const card = await client.cards.create({
  binId: '491653',
  amount: 500,
  label: 'Ad Spend',
});

// Get 3DS OTPs
const challenges = await client.threeds.list({
  cardId: card.id,
  status: 'pending',
});

// Set up webhooks
await client.webhooks.create({
  url: 'https://yourapp.com/hooks',
  events: ['transaction.authorized', '3ds.challenge'],
});
Tài liệu API — PrivCards API Thẻ ảo