Introduction
Welcome
Getting Started
You can use our REST API to create invoices and wallets on the SmartPay platform. You can also view information regarding your account, invoice statuses, conduct trades and request withdrawals.
You can view SmartPay API endpoints using Swagger
A JavaScript or Typescript developer can use the SmartPay SDK
Environments
Type | URL | Description |
---|---|---|
UAT | https://uat-smartpay-api.coinsmart.com | All crypto addresses will be from TEST NET |
Production | https://smartpay-api.coinsmart.com |
Signing a Request
API calls must be authenticated.
const { SmartPaySDK } = require("@coinsmart/smartpay-sdk");
const smartpay = new SmartPaySDK(apiKey, secretKey);
// or typescript
import { SmartPaySDK } from "@coinsmart/smartpay-sdk";
const smartpay = new SmartPaySDK(apiKey, secretKey);
Every request must contain the following headers:
Authorization - Its value should be set to HMAC-SHA256
Token should be {apiKey}:{signature}:{timestamp}
Signature: HMAC-SHA256 from string
- HTTP Method UpperCase (GET, POST, PUT, DELETE)
- URL Path eg.: (/v1/invoices)
- Body JSON-serialized if applied
- Timestamp in milliseconds
eg.: hash_hmac('sha256', 'GET/v1/invoices1646678881050', $secretKey)
Headers Example
{
"Content-Type": "application/json; charset=utf-8",
"Accept": "application/json; charset=utf-8",
"Authorization": "HMAC-SHA256 {apiKey}:{signature}:{ts}"
}
IP Whitelisting
SmartPay supports restriction of API calls to be accepted only from a specific IP address per API key. You can manage whitelisted IPs from account settings.
API-Endpoints
General
Account Balances
GET /v1/accounts/balances
const balances = await smartpay.getBalances();
200 Response Example
[
{
"productSymbol": "BTC",
"balance": 0.05,
"holdAmount": 0
},
{
"productSymbol": "USD",
"balance": 120,
"holdAmount": 0
}
]
Get products
GET /v1/products
const products = await smartpay.getProducts();
200 Response Example
[
{
"productSymbol": "BTC",
"decimals": 8,
"isCrypto": true,
"minWithdrawAmount": 0.001
},
{
"productSymbol": "USD",
"decimals": 2,
"isCrypto": false,
"minWithdrawAmount": 100
}
]
Get instruments
GET /v1/instruments
const instruments = await smartpay.getInstruments();
200 Response Example
[
{
"instrumentSymbol": "BTCCAD",
"product1Symbol": "BTC",
"product2Symbol": "CAD",
"minTradeAmount": 0.5
}
]
Invoices
List invoices
GET /v1/invoices
const invoices = await smartpay.getInvoices();
200 Response Example
[
{
"invoiceId": 20546,
"invoiceUrl": "...",
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 0,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"paid": false,
"paidAt": "2022-02-03T10:20:30.426Z",
"sent": false,
"sentAt": "2022-02-03T10:20:30.426Z",
"cancelled": false,
"createdAt": "2022-02-03T10:20:30.426Z"
}
]
Query Parameters
Parameter | Type | Required (Default) | Description |
---|---|---|---|
productSymbol | string | optional | CAD, USD, EUR, AUD, GBP |
customId | string | optional | your internal unique id |
dateFrom | string (date) | optional | ISO 8601 |
dateTo | string (date) | optional | ISO 8601 |
limit | number | optional (100) | max: 1000 |
offset | number | optional (0) |
Responses
Status | Description | Schema |
---|---|---|
200 | Successful | [Invoices-Response] |
Get invoice
GET /v1/invoices/{invoiceId}
const invoice = await smartpay.getInvoice(invoiceId);
Responses
Status | Description | Schema |
---|---|---|
200 | Successful | [Invoices-Response] |
200 Response Example
{
"invoiceId": 20546,
"invoiceUrl": "...",
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 0,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"paid": false,
"paidAt": "2022-02-03T10:20:30.426Z",
"sent": false,
"sentAt": "2022-02-03T10:20:30.426Z",
"cancelled": false,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Get invoice payments
GET /v1/invoices/{invoiceId}/payments
200 Response Example
[
{
"address":"2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"txHash":"edecfb7de1b88f46cd7eb669f717cb6f27d22e7b34fef971784f4930efd232c5",
"confirmations":1,
"productSymbol":"BTC",
"amountDeposited":"0.00070000",
"amountProcessed":"0.00070000",
"amountOverPaid":"0.00000000",
"quotePrice":"23199.68750000",
"value":"16.24",
"createdAt":"2022-08-18T15:10:02.601Z"
}
]
Create invoice
POST /v1/invoices
const invoice = await smartpay.createInvoice({
productSymbol: "USD",
amount: 100,
email: "test@example.com",
details: {
description: "for 3D printer",
address: "101 Main street",
city: "Toronto",
state: "Ontario",
country: "Canada",
postal: "M5T 1G4"
},
sendEmail: false,
customId: "my-unique-custom-id-1"
});
Parameters
Name | Type | Default | Description |
---|---|---|---|
productSymbol | string | Only FIAT | |
amount | number | ||
string | |||
details | InvoicesDetails or null | null | |
sendEmail | boolean | false | |
customId | string | null |
Responses
Status | Description | Schema |
---|---|---|
200 | Successful | [Invoices-Response] |
200 Response Example
{
"invoiceId": 20546,
"invoiceUrl": "...",
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 0,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"paid": false,
"paidAt": "2022-02-03T10:20:30.426Z",
"sent": false,
"sentAt": "2022-02-03T10:20:30.426Z",
"cancelled": false,
"createdAt": "2022-02-03T10:20:30.426Z",
"customId": "my-unique-custom-id-1"
}
Update invoice
Note: Invoice can be updated only if is not quoted
PUT /v1/invoices/{invoiceId}
const invoice = await smartpay.updateInvoice(invoiceId, payload);
Name | Type | Default | Description |
---|---|---|---|
invoiceId | number | ||
productSymbol | string | ||
amount | number | ||
string or null | null | ||
details | InvoicesDetails or null | null | |
customId | string | null |
200 Response Example
{
"invoiceId": 20546,
"invoiceUrl": "...",
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 0,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"paid": false,
"paidAt": "2022-02-03T10:20:30.426Z",
"sent": false,
"sentAt": "2022-02-03T10:20:30.426Z",
"cancelled": false,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Responses
Status | Description | Schema |
---|---|---|
200 | Successful | [Invoices-Response] |
Invoice. Accept Underpayment
Note: Will adjust the invoice to already paid amount and mark it as paid
PUT /invoices/{invoiceId}/accept_underpayment
Invoice. Mark Paid
Note: Mark invoice as paid amount and amountReceived will be not be changed
PUT /invoices/{invoiceId}/mark_paid
Invoice. Accept Overpayment
Note: Will sell overpaid crypto amount, adjust invoice amount and mark invoice as paid
PUT /invoices/{invoiceId}/accept_overpayment
Resend or Send invoice
POST /v1/invoices/{invoiceId}/resend
const invoice = await smartpay.resendInvoice(invoiceId);
200 Response Example
{
"invoiceId": 20546,
"invoiceUrl": "...",
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 0,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"paid": false,
"paidAt": "2022-02-03T10:20:30.426Z",
"sent": false,
"sentAt": "2022-02-03T10:20:30.426Z",
"cancelled": false,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Cancel invoice
DELETE /v1/invoice/{invoiceId}
const invoice = await smartpay.cancelInvoice(invoiceId);
200 Response Example
{
"success": true
}
Responses
Status | Description | Schema |
---|---|---|
200 | Successful |
Invoice
Get invoice by uniqueId (public)
GET /v1/invoice/{uniqueId}
const invoice = await smartpay.getInvoicePublic(uniqueId);
200 Response Example
{
"invoiceId": 20546,
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 0,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"billDetails": {
"firstName": "Joe",
"lastName": "Doe",
"company": "MyCompany",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada"
},
"paid": false,
"paidAt": "2022-02-03T10:20:30.426Z",
"cancelled": false,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Get invoice quote (public)
POST /v1/invoice/{uniqueId}
const invoice = await smartpay.getInvoicePublicQuote(uniqueId, quoteProductSymbol);
200 Response Example
{
"invoiceId": 20546,
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 0,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"billDetails": {
"firstName": "Joe",
"lastName": "Doe",
"company": "MyCompany",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada"
},
"paid": false,
"paidAt": "2022-02-03T10:20:30.426Z",
"cancelled": false,
"createdAt": "2022-02-03T10:20:30.426Z",
"quote": {
"quoteProductSymbol": "BTC",
"quoteAddress": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"quotePrice": 43500.5,
"quoteExpiresAt": "2022-02-03T10:20:30.426Z"
}
}
Wallets
List wallets
GET /v1/wallets
const wallets = await smartpay.getWallets();
200 Response Example
[
{
"walletId": 1056,
"name": "My wallet",
"productSymbol": "BTC",
"network": "Bitcoin",
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"autoSell": true,
"autoSellToProductSymbol": "USD",
"used": true,
"totalReceived": 0.005,
"createdAt": "2022-02-03T10:20:30.426Z"
}
]
Query Parameters
Parameter | Type | Required (Default) | Description |
---|---|---|---|
productSymbol | string | optional | BTC, ETH, USDC, USDT, LTC, DOGE, ADA, BCH, AVAX, MATIC, DOT |
dateFrom | string (date) | optional | ISO 8601 |
dateTo | string (date) | optional | ISO 8601 |
limit | number | optional (100) | max: 1000 |
offset | number | optional (0) |
Get wallet
GET /v1/wallets/{walletId}
const wallet = await smartpay.getWallet(1056);
200 Response Example
{
"walletId": 1056,
"name": "My wallet",
"productSymbol": "BTC",
"network": "Bitcoin",
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"autoSell": true,
"autoSellToProductSymbol": "USD",
"used": true,
"totalReceived": 0.005,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Get wallet deposits
GET /v1/wallets/{walletId}/deposits
const wallet = await smartpay.getWalletDeposits(walletId);
200 Response Example
[
{
"walletId": 1056,
"txId": "edecfb7de1b88f46cd7eb669f717cb6f27d22e7b34fef971784f4930efd232c5",
"amount": 0.005,
"createdAt": "2022-02-03T10:20:30.426Z",
"instrumentSymbol": "BTCUSD",
"soldAmount": 0.005,
"soldPrice": 43500.5,
"code": "R3Q4QBU9RF"
}
]
Create wallet
POST /v1/wallets
const wallet = await smartpay.createWallet(productSymbol, name, autoSell, autoSellToProductSymbol);
200 Response Example
{
"walletId": 1056,
"name": "My wallet",
"productSymbol": "BTC",
"network": "Bitcoin",
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"autoSell": true,
"autoSellToProductSymbol": "USD",
"used": false,
"totalReceived": 0,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Update wallet
PUT /v1/wallets/{walletId}
const wallet = await smartpay.updateWallet(walletId, name, autoSell, autoSellToProductSymbol);
200 Response Example
{
"walletId": 1056,
"name": "My wallet",
"productSymbol": "BTC",
"network": "Bitcoin",
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"autoSell": true,
"autoSellToProductSymbol": "USD",
"used": true,
"totalReceived": 0.005,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Delete wallet
DELETE /v1/wallets/{walletId}
const wallet = await smartpay.deleteWallet(walletId);
200 Response Example
{
"success": true
}
Trades
Get trades
GET /v1/trades
const trades = await smartpay.getTrades();
200 Response Example
[
{
"tradeId": 123,
"instrumentSymbol": "BTCCAD",
"side": "sell",
"amount": 0.005,
"price": 43500.5,
"createdAt": "2022-02-03T10:20:30.426Z"
}
]
Query Parameters
Parameter | Type | Required (Default) | Description |
---|---|---|---|
dateFrom | string (date) | optional | ISO 8601 |
dateTo | string (date) | optional | ISO 8601 |
limit | number | optional (100) | max: 1000 |
offset | number | optional (0) |
Request for quote
POST /v1/trades/rfq
const tradeQuote = await smartpay.requestForQuote(instrumentSymbol, side, amount);
200 Response Example
{
"rfqId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"instrumentSymbol": "BTCCAD",
"side": "sell",
"amount": 0.01,
"price": 43500,
"value": 435,
"expireAt": "2022-02-03T10:20:30.426Z"
}
Request for quote Execute
POST /v1/trades/rfq_trade
const trade = await smartpay.requestForQuoteExecute(rfqId);
200 Response Example
{
"tradeId": 123,
"instrumentSymbol": "BTCCAD",
"side": "sell",
"amount": 0.005,
"price": 43500.5,
"createdAt": "2022-02-03T10:20:30.426Z"
}
Bank Accounts
List bank accounts
GET /v1/bank_accounts
const bankAccounts = await smartpay.getBankAccounts();
200 Response Example
[
{
"bankAccountId": 123,
"productSymbol": "USD",
"description": "My Bank account for USD",
"details": {
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "48021",
"institutionCode": "670",
"intermediaryBankName": "string",
"intermediaryBankAddress": "string",
"intermediarySwift": "string",
"reference": "string"
}
}
]
Get bank account
GET /v1/bank_accounts/{bankAddressId}
const bankAccounts = await smartpay.getBankAccounts(123);
200 Response Example
{
"bankAccountId": 123,
"productSymbol": "USD",
"description": "My Bank account for USD",
"details": {
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "48021",
"institutionCode": "670",
"intermediaryBankName": "string",
"intermediaryBankAddress": "string",
"intermediarySwift": "string",
"reference": "string"
}
}
Create bank account
POST /v1/bank_accounts
const bankAccount = await smartpay.createBankAccount(
"USD",
"My Bank account for USD",
{
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "48021",
"institutionCode": "670",
"intermediaryBankName": "string",
"intermediaryBankAddress": "string",
"intermediarySwift": "string",
"reference": "string"
}
);
200 Response Example
{
"bankAccountId": 123,
"productSymbol": "USD",
"description": "My Bank account for USD",
"details": {
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "48021",
"institutionCode": "670",
"intermediaryBankName": "string",
"intermediaryBankAddress": "string",
"intermediarySwift": "string",
"reference": "string"
}
}
Update bank account
PUT /v1/bank_accounts/{bankAccountId}
const bankAccount = await smartpay.updateBankAccount(
123,
"USD",
"My Bank account for USD",
{
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "48021",
"institutionCode": "670",
"intermediaryBankName": "string",
"intermediaryBankAddress": "string",
"intermediarySwift": "string",
"reference": "string"
}
);
200 Response Example
{
"bankAccountId": 123,
"productSymbol": "USD",
"description": "My Bank account for USD",
"details": {
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "48021",
"institutionCode": "670",
"intermediaryBankName": "string",
"intermediaryBankAddress": "string",
"intermediarySwift": "string",
"reference": "string"
}
}
Delete bank account
DELETE /v1/bank_accounts/{bankAccountId}
const wallet = await smartpay.deleteWallet(bankAccountId);
200 Response Example
{
"success": true
}
Withdraws
List withdraws
GET /v1/withdraws
const withdraws = await smartpay.getWithdraws();
200 Response Example
[
{
"withdrawId": 4,
"productSymbol": "CAD",
"amount": "100.00",
"fee": 0,
"destination": {
"bankAccountId":1,
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "07007",
"institutionCode": "447"
},
"status": "PENDING",
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
},
{
"withdrawId": 5,
"productSymbol": "BTC",
"amount": "0.001",
"fee": "0.00001",
"destination": {
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"network": "Bitcoin"
},
"status": "PENDING",
"tradeId": null,
"customId": null,
"description": null,
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
]
Query Parameters
Parameter | Type | Required (Default) | Description |
---|---|---|---|
productSymbol | string | optional | CAD, USD, EUR, AUD, GBP, BTC, ETH, USDC, USDT, SOL, LTC, DOGE, ADA, BCH, AVAX, MATIC, DOT |
status | string | optional | PENDING, SUBMITTED, FAILED, PROCESSED |
customId | string | optional | your internal unique id |
dateFrom | string (date) | optional | ISO 8601 |
dateTo | string (date) | optional | ISO 8601 |
limit | number | optional (100) | max: 500 |
offset | number | optional (0) |
Get withdraw
GET /v1/withdraws/{withdrawId}
const withdraw = await smartpay.getWithdraw(withdrawId);
200 Response Example
{
"withdrawId": 4,
"productSymbol": "CAD",
"amount": "100.00",
"fee": 0,
"destination": {
"bankAccountId":1,
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "07007",
"institutionCode": "447"
},
"status": "PENDING",
"transactionDetails": null,
"tradeId": null,
"customId": null,
"description": null,
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
Create withdraw request
POST /v1/withdraws
// FIAT example
const withdraw = await smartpay.createWithdraw('CAD', 100, {
bankAccountId: 4
});
// Crypto example
const withdraw = await smartpay.createWithdraw('BTC', 0.001, {
address: '2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm',
network: 'Bitcoin'
});
200 Response Example (FIAT)
{
"withdrawId": 4,
"productSymbol": "CAD",
"amount": "100.00",
"fee": 0,
"destination": {
"bankAccountId":1,
"beneficiary": "Joe Doe",
"bankName": "Bank of America",
"bankAddress": "Main 101",
"bankSwift": "BOFAUS3N",
"bankAccountNumber": "A123456789B",
"transitNumber": "07007",
"institutionCode": "447"
},
"status": "PENDING",
"transactionDetails": null,
"tradeId": null,
"customId": null,
"description": null,
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
200 Response Example (Crypto)
{
"withdrawId": 5,
"productSymbol": "BTC",
"amount": "0.001",
"fee": "0.0002",
"destination": {
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"network": "Bitcoin"
},
"status": "PENDING",
"transactionDetails": null,
"tradeId": null,
"customId": null,
"description": null,
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
Smart
Smart Withdraw
POST /v1/smart/withdraw
const withdraw = await smartpay.smartWithdraw({
fiatProductSymbol: 'USD',
fiatAmount: 100,
cryptoProductSymbol: 'BTC',
destination: {
address: '2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm',
network: 'Bitcoin'
},
useCryptoBalance: false,
subtractFee: true,
customId: 'my-custom-id-101'
});
200 Response Example
{
"withdrawId": 6,
"productSymbol": "BTC",
"amount": "0.001",
"fee": "0.0002",
"destination": {
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm",
"network": "Bitcoin"
},
"status": "PENDING",
"transactionDetails": null,
"tradeId": null,
"customId": "my-custom-id-101",
"description": "my-description",
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
200 Response Example (if estimationOnly: true)
{
"instrumentSymbol": "BTCUSD",
"price": 10000,
"fiatAmount": 100,
"cryptoAmount": 0.0998,
"withdrawFee": 0.0002
}
Body Parameters
Parameter | Type | Required (Default) | Description |
---|---|---|---|
fiatProductSymbol | string | required | CAD, USD, EUR, AUD, GBP |
fiatAmount | number | required | min 20, precision 2 |
cryptoProductSymbol | string | required | BTC, ETH, USDC, USDT, LTC, DOGE, ADA, BCH, AVAX, MATIC, DOT |
destination | Object | required | {address: 'xxx'} |
useCryptoBalance | boolean | optional (false) | |
subtractFee | boolean | optional (true) | |
customId | string | optional | your internal unique id |
estimateOnly | boolean | optional (false) | Will provide only estimation. Trade and Withdraw will not be executed |
Response
Name | Type | Description |
---|---|---|
withdrawId | number | SmartPay withdraw unique id |
productSymbol | string | |
amount | number | |
fee | number | |
destination | Object | crypto address or bank account |
status | string | PENDING -> SUBMITTED -> PROCESSED |
customId | string or null | your custom id if defined |
createdAt | timestamp | |
updatedAt | timestamp |
CASE #1: useCryptoBalance[false]; subtractFee[true]
(default)
StartBalance: USD: 101.5; BTC: 0.102
-calculateTotalWdAmount: 100 / 1000 = 0.1BTC
-buyCrypto: 0.1BTC
-withdrawBTC 0.099 + 0.001(fee)
EndBalance: USD: 1.5; BTC: 0.102
CASE #2: useCryptoBalance[false]; subtractFee[false]
StartBalance: USD: 101.5; BTC: 0.102
-calculateTotalWdAmount: (100 / 1000 + 0.001fee) = 0.101BTC
-buyCrypto: 0.101BTC
-withdrawBTC 0.1 + 0.001(fee)
EndBalance: USD: 0.5; BTC: 0.102
CASE #3: useCryptoBalance[true]; subtractFee[true]
StartBalance: USD: 101.5; BTC: 0.102
- calculateTotalWdAmount: 100 / 1000 = 0.1BTC
- withdrawBTC 0.099 + 0.001(fee)
EndBalance: USD: 101.5; BTC: 0.002
CASE #4: useCryptoBalance[true]; subtractFee[false]
StartBalance: USD: 101.5; BTC: 0.102
- calculateTotalWdAmount: (100 / 1000 + 0.001fee) = 0.101BTC
- withdrawBTC 0.1 + 0.001(fee)
EndBalance: USD: 101.5; BTC: 0.001
Payouts
List payouts
GET /v1/payouts
const payouts = await smartpay.getPayouts({productSymbol: "CAD"});
200 Response Example
[
{
"payoutId": 123,
"productSymbol": "CAD",
"amount": "100.00",
"description": "my-description",
"customId": "my-custom-id",
"status": "PENDING",
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
]
Query Parameters
Parameter | Type | Required (Default) | Description |
---|---|---|---|
productSymbol | string | optional | CAD, USD, EUR, AUD, GBP |
status | string | optional | PENDING, CANCELLED, REJECTED, LOCKED, SUBMITTED, PROCESSED |
customId | string | optional | your internal unique id |
dateFrom | string (date) | optional | ISO 8601 |
dateTo | string (date) | optional | ISO 8601 |
limit | number | optional (100) | max: 500 |
offset | number | optional (0) |
Get payout
GET /v1/payouts/{payoutId}
const payout = await smartpay.getPayout(payoutId);
200 Response Example
{
"payoutId": 123,
"productSymbol": "CAD",
"amount": "100.00",
"description": "my-description",
"customId": "my-custom-id",
"status": "PENDING",
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
Create payout
POST /v1/payouts
const payout = await smartpay.createPayout({
productSymbol: "CAD",
amount: 100,
email: "test@example.com",
securityQA: [
{question: "Security Question?", answer: "Security Answer"}
],
description: "my-description",
customId: "my-custom-id"
});
200 Response Example
{
"payoutId": 123,
"productSymbol": "CAD",
"amount": "100.00",
"description": "my-description",
"customId": "my-custom-id",
"status": "PENDING",
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
Payload
Parameter | Type | Required (Default) | Description |
---|---|---|---|
productSymbol | string | required | CAD, USD, EUR, AUD, GBP |
amount | string | required | |
string | required | your internal unique id | |
phone | string | optional | E.164 format (eg: +14155552671) ! If added end-user will be verified with SMS |
securityQA | Array | required | Minimum one QA object |
description | string | optional | |
customId | string | optional |
Cancel payout
DELETE /v1/payout/{payoutId}
const payout = await smartpay.cancelPayout(payoutId);
200 Response Example
{
"payoutId": 123,
"productSymbol": "CAD",
"amount": "100.00",
"description": "my-description",
"customId": "my-custom-id",
"status": "CANCELLED",
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
OBJECTS
Invoice-Response
Properties
Name | Type | Description |
---|---|---|
invoiceId | number | |
invoiceUrl | string | url to invoice page for quote and pay |
uniqueId | string | uuid |
productSymbol | string | FIAT products |
amount | number | Min 50 |
amountReceived | number | amount received in FIAT |
amountPending | number | |
string or null | ||
details | InvoiceDetails | |
paid | boolean | true when invoice is paid in full |
paidAt | string(date-time) | |
sent | boolean | if email with invoice link is sent |
sentAt | string(date-time) | |
cancelled | boolean | |
cancelledAt | string(date-time) | |
createdAt | string(date-time) |
InvoiceDetails
Properties
Name | Type | Description |
---|---|---|
description | string | |
address | string | |
city | string | |
state | string | |
country | string | |
postal | string |
HTTP Status Code
Status Code | Status | Meaning |
---|---|---|
400 | Bad Request | Your request is invalid. |
401 | Unauthorized | Your API key is wrong. |
403 | Forbidden | The API key's permissions do not match the needed permission. |
404 | Not Found | The requested resource doesn't exist. |
405 | Method Not Allowed | You tried to access an invalid method. |
406 | Not Acceptable | You requested a format that isn't json. |
429 | Too Many Requests | You're requesting too many kittens! Slow down! |
500 | Internal Server Error | We had a problem with our server. Try again later. |
503 | Service Unavailable | We're temporarily offline for maintenance. Please try again later. |
Webhook
Overview
Setting a webhook will allow you to get notifications for events that happen on your SmartPay account. You can receive notifications on events such as invoice status update, wallet deposits and more.
In order to connect a Webhook to your SmartPay account please configure targets on settings page. Once your Webhook is connected to your SmartPay account, you will start receiving notification on events.
All events will be sent with header
- SmartPay-Signature = hex encoded SHA256 HMAC signature of the request body string, computed using your webhook secret key.
Example verify signature with SDK
const { verifyWebhookSignature } = require("@coinsmart/smartpay-sdk");
verifyWebhookSignature('YourWebhookSecretKey', req.payload, req.headers("SmartPay-Signature"))
SmartPay will send a POST request and expect a 200 response.
If no response is received, SmartPay will resend the request several more times with an increasing delay between each attempt
Events
InvoicePaidFull
When invoice is paid in full
Example
{
"type": "InvoicePaidFull",
"data": {
"invoiceId": 20546,
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 100,
"amountPending": 0,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"paid": true,
"paidAt": "2022-02-03T10:20:30.426Z",
"sent": false,
"sentAt": null,
"cancelled": false,
"customId": "my-id-2",
"createdAt": "2022-02-03T10:20:30.426Z"
}
}
InvoicePaidPartial
When partial payment is received
Example
{
"type": "InvoicePaidPartial",
"data": {
"invoiceId": 20546,
"uniqueId": "589b3486-f114-4fe7-8346-04e2bbac44dc",
"productSymbol": "USD",
"amount": 100,
"amountReceived": 60,
"amountPending": 40,
"email": "test@example.com",
"details": {
"description": "for 3D printer",
"address": "101 Main street",
"city": "Toronto",
"state": "Ontario",
"country": "Canada",
"postal": "M5T 1G4"
},
"paid": false,
"paidAt": null,
"sent": false,
"sentAt": null,
"cancelled": false,
"customId": "my-id-2",
"createdAt": "2022-02-03T10:20:30.426Z"
}
}
WalletDeposit
When a new deposit is received
Example
{
"type": "WalletDeposit",
"data": {
"walletId": 20546,
"txId": "edecfb7de1b88f46cd7eb669f717cb6f27d22e7b34fef971784f4930efd232c5",
"amount": 0.005,
"createdAt": "2022-02-03T10:20:30.426Z",
"instrumentSymbol": null,
"soldAmount": null,
"soldPrice": null,
"code": null
}
}
WalletAutoSell
When deposit is received and sold automatically because AutoSell is enabled
Example
{
"type": "WalletAutoSell",
"timestamp": "2022-02-03T10:20:30.426Z",
"data": {
"walletId": 20546,
"txId": "edecfb7de1b88f46cd7eb669f717cb6f27d22e7b34fef971784f4930efd232c5",
"amount": 0.005,
"createdAt": "2022-02-03T10:20:30.426Z",
"instrumentSymbol": "BTCUSD",
"soldAmount": 0.005,
"soldPrice": 43500.5,
"code": "R3Q4QBU9RF"
}
}
WithdrawProcessed
When crypto withdraw is fully processed
Example
{
"type": "WithdrawProcessed",
"timestamp": "2022-02-03T10:20:30.426Z",
"data": {
"withdrawId": 5,
"customId": "my-id-2",
"productSymbol": "BTC",
"amount": "0.001",
"destination": {
"address": "2N3oefVeg6stiTb5Kh3ozCSkaqmx91FDbsm"
},
"status": "PROCESSED",
"createdAt": "2022-05-17T10:45:56.245Z",
"updatedAt": "2022-05-17T10:45:56.245Z"
}
}
Supported Products
FIAT
Type | Name |
---|---|
USD | US Dollar |
CAD | Canadian Dollar |
EUR | EURO |
AUD | Australian Dollar |
GBP | Pound |
Crypto
Symbol | Production Network | UAT Network |
---|---|---|
BTC | Bitcoin | Bitcoin Testnet |
ETH | Ethereum | Ethereum Testnet (Goerli) ERC20 |
USDC | Ethereum, Tron, Binance | Ethereum Testnet (Goerli) ERC20 |
USDT | Ethereum, Tron, Binance | Ethereum Testnet (Goerli) ERC20 |
SOL | Solana | Solana Devnet |
LTC | Litecoin | Litecoin Testnet |
DOGE | Dogecoin | Dogecoin Testnet |
ADA | Cardano | Cardano Testnet |
BCH | BitcoinCash | BitcoinCash Testnet |
AVAX | Avalanche | Avalanche Testnet |
MATIC | Ethereum, Polygon, Binance | Ethereum Testnet(Goerli), Polygon Testnet |
DOT | Polkadot |