CoinPayments API Documentation

Download OpenAPI specification:Download

License: Apache 2.0

Welcome to CoinPayments API documentation!

markdown file changed

CoinPayments API is a RESTful JSON API for interacting with blockchains, accessed over HTTP or HTTPS from the domain https://api.coinpayments.com/api/v1/

Overview

Coinpayments API docs defines a standard, language-agnostic interface to CoinPayments API. The platform allows merchants to integrate the payment system into their own websites or applications, allowing their customers to pay for goods or services with cryptocurrency. The API documentation provides the necessary information for developers to integrate the payment system into their own platforms, including details on how to authenticate requests, what parameters to include in requests and responses, and how to handle errors. Overall, the API is designed to provide a simple and secure way for merchants to accept cryptocurrency payments from their customers. In these docs you'll find everything you need to leverage CoinPayments for your applications.

Also, while studying documentation, you can test it in Postman. For this, you can download API collection here. For information on authentication with the Postman collection, please, visit this section.

Features

CoinPayments provides a multi-currency wallet that enables businesses and individuals to store, send, and receive a wide range of digital currencies and tokens. The free-to-set-up wallet is available on web and mobile, enabling account management online and on the go.

Some of the key features of the website include:

  1. Support for multiple popular cryptocurrencies, allowing customers to pay with the digital currency of their choice.
  2. Generate invoices and manually share them with buyers through a link or via email.
  3. Callback Addresses feature allows merchant to receive payment without specifying the amount or time in advance.
  4. Real-time updates using Webhooks, The API provides updates on the status of transactions, allowing merchants and customers to track the progress of their payments.
  5. Advanced security measures to ensure that all transactions are safe and secure.

Common API Errors

This section provides an overview of the common errors that you may encounter when utilizing CoinPayment API. By familiarizing yourself with these errors, you will be better equipped to handle potential issues and troubleshoot effectively. Understanding these errors will contribute to a smoother integration process and ensure a more seamless payment experience for your users.

Unauthorized

This error occurs when an invalid clientId or clientSecret is used to generate API signature to authenticate requests. It may also occur if a clientId is valid but the integration is either deleted or the user's account does not exist. or an invalid or incorrect client secret is provided. In such cases, the API returns an "Unauthorized" error.

Insufficient Funds

This error can occur in different scenarios, such as during withdrawal to an external address or when converting a coin to another, whether to an internal or external address. It arises when the user's wallet does not have enough balance to cover the requested transaction amount.

Invalid Address

When sending a request to create a withdrawal or a conversion, if the provided address is not valid or formatted incorrectly, this error is triggered. Users should double-check the address they provided and ensure it follows the required format. here are examples of Valid addresses

Valid UTXO-Based Coin Addresses:

  • Bitcoin (BTC): 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2
  • Bitcoin Cash (BCH): bitcoincash:qr7uq7uvujmzhcv29tw92q0hs7fwpht4fvl4a4kj9a
  • Litecoin (LTC): LZx9pzGfH6mKSzVsJZnryeVrRzt6X8uZ9r

Valid Token Coin Addresses:

  • Ethereum (ETH): 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf
  • ERC-20 Tokens (e.g., DAI, USDT): 0x6B175474E89094C44Da98b954EedeAC495271d0F

Invalid or Unsupported Currency:

This error occurs when the requested invoice, withdrawal, conversion involves an invalid or unsupported currency. It could be due to the currency not being listed or supported on the platform. Users can utilize the currencies API included in the documentation to list all supported currencies and verify if their intended currency is supported before initiating the transaction.

Bad request ( Input validation errors ):

This error occurs when there are issues with the validation of fields in the request's payload. For example, if a required field is not sent, or if the fields have invalid values or incorrect types. The API response for a validation error includes a description of the error and may provide details about the missing fields or the specific issues with the payload.

Rate limits

The API provides access to our platform's data and functionality, but in order to maintain the stability and performance of our services, rate limits have been implemented. Rate limits are set to prevent excessive use of the API and to ensure fair usage among all integrations. Currently, the rate limit is capped at a maximum of 70 requests per second.

Authentication

CoinPayments API uses SHA-256 which is a way of authenticating an API request to ensure that it comes from a trusted source. In this scheme, the API server generates a unique signature for each request using the SHA-256 hashing algorithm.

Prerequisites

To Integrate Coin Payments API you need to obtain CLIENT ID and CLIENT SECRET. If you have already created your credentials, you may skip to next section.

Create Credentials

First, you need to create an account.

Then log into your account.

Once you're logged into your account, click on Integrations 👇

markdown file changed

API integrations 🏗

markdown file changed

Add integration ➕

markdown file changed

Give a name and a URL to your integration - more on the URL later.

markdown file changed

Warning It is strongly recommended that you save your credentials after they are shown to you. Your credentials will only be displayed once, and if you lose them, you will not be able to access the API. Please take the time to save your credentials in a secure location so that you can use them in the future.


Generate API Signature

In order to properly sign an authenticated request for the CoinPayments v2 API, the following headers must be included:

  • X-CoinPayments-Client
  • X-CoinPayments-Timestamp
  • X-CoinPayments-Signature

The following sections are instructions for properly populating these headers.


X-CoinPayments-Client

Populate this header with your clientId.

Example value cc7caaa431d54ad6accfd28b20170ee4


X-CoinPayments-Timestamp

Before we Populate this header with the current time as a UNIX timestamp, exclude the milliseconds epoch, example:

const date = new Date().toISOString().split(".")[0];

Example value: 2022-12-19T19:27:04


Construct the request queryString

To create an API signature, you first need to construct the query string which is made of the following attributes concatenated together

  • method
  • url
  • clientId
  • date

Example ( Javascript )

const queryString = `\ufeff${method}${url}${clientId}${date}${JSON.stringify(requestPayload)}`;

For requests with no request body, replace last attribute by an empty string: Example ( Javascript )

const queryString = `\ufeff${method}${url}${clientId}${''}`;

X-CoinPayments-Signature

Next step is to use your clientSecret to generate the signature using SHA-256 encryption algorithm as follows:

const hash = CryptoJS.HmacSHA256(queryString, CryptoJS.enc.Utf8.parse(clientSecret));
const signature = CryptoJS.enc.Base64.stringify(hash);

Example value: oW7d1ktvK7R6741oACgVR3bysGTPY8tqren0WTmmEk0=


Here is a complete example of how to generate an API signature for making a call to the create wallet API:

const clientId = 'd0ccc52b8204460783d375e278082de2';
const clientSecret = 'WYEB+hN+89waO76QeO9T7IIqhdo/60GHrdYu2vEa7Tg=';
const url = `https://api.coinpayments.com/api/v1/merchant/wallets`;
const method = 'POST';
const date = new Date().toISOString().split('.')[0];

const createWalletDto = {
  currencyId: 2,
  label: 'Online Shop Wallet',
  webhookUrl: 'https://mysite.com/api/v1/payment/notification',
};

const queryString = `\ufeff${method}${url}${clientId}${date}${JSON.stringify(createWalletDto)}`;


const hash = CryptoJS.HmacSHA256(queryString, CryptoJS.enc.Utf8.parse(clientSecret));
const signature = CryptoJS.enc.Base64.stringify(hash);

const headers = {
  'X-CoinPayments-Client': clientId,
  'X-CoinPayments-Timestamp': date,
  'X-CoinPayments-Signature': signature,
};


/** Make API call using axios ( you may choose any http client ) */
const axiosoptions = {
  url,
  headers,
  method,
  data: createWalletDto,
};

const response = await this.httpsService.request(options).toPromise();
console.log(response);

Authentication for Postman

When setting up authentication with Postman to test out our API collection, follow these steps:

  1. Set up environment variables:

markdown file changed

  1. Provide the following script in the collection Pre-request Script section:

const clientId = pm.environment.get('clientId');
const clientSecret = pm.environment.get('clientSecret');

const date = new Date().toISOString().split('.')[0];

const queryString = `\ufeff${pm.request.method}${pm.variables.replaceIn(pm.request.url.toString())}${clientId}${date}${pm.request.body}`;
const hash = CryptoJS.HmacSHA256(queryString, CryptoJS.enc.Utf8.parse(clientSecret));
const signature = CryptoJS.enc.Base64.stringify(hash);

pm.request.headers.add({
    key: 'X-CoinPayments-Client',
    value: clientId
})

pm.request.headers.add({
    key: 'X-CoinPayments-Timestamp',
    value: date
})

pm.request.headers.add({
    key: 'X-CoinPayments-Signature',
    value: signature
})

markdown file changed

Currencies API

In order to perform most API requests regarding payment/wallet management, the merchant has to provide a currency ID in the request. CoinPayments exposes currencies API endpoints allowing merchants to view the list of available cryptocurrencies in the system and learn about their details and capabilities.

Each currency supported by CoinPayments has a specific ID assigned to it. Besides, CoinPayments supports both native coins and tokens. In order to allow managing tokens of the same blockchain, CoinPayments API contains information on both - ID of the coin blockchain, where token belongs, and the smart contract address of the token. This information is returned in the format 'coinID:smartContract'. For example, if ID of ETH is "35", then for ERC20 USDT it would be "35:0x55d398326f99059ff775485246999027b3197955".

Currency IDs are used for creating and listing merchant wallets. When creating a wallet, if only native currency ID is specified, the wallet is created for the same native currency. In case a wallet for the token is required, merchant must additionally indicate the token contract address when creating a wallet. See Create Wallet.

Also, currency IDs and contract addresses are used when creating transactions from a merchant wallet. For example, the body of the spend request specifically indicates the "toCurrency" ID and "from" and "to" contract addresses. This allows CoinPayments to indicate whether the said transaction is a regular withdrawal of funds or a transaction that additionally requires conversion. See Spend Request.

Below, you will find the detailed information on currency-related endpoints and their field values.

List currencies and their capabilities

Returns a page of the supported currencies on the CoinPayments.com platform, by default ordered by their rank on CoinPayments.com.

Request
query Parameters
q
string

search query to find currencies by name or symbol

Example: q=BTC
types
Array of arrays

comma separated list of the types of currencies to return (e.g. 'coin', 'token', 'fiat', etc.). By default currencies of all types are returned

Example: types=crypto, token, fiat
Responses
200

Ok

400

Bad Request

get/currencies
Request samples
Response samples
application/json
[
  • {
    }
]

Get currency by Id

Get currency information by currency Id in the CoinPayments system

Request
path Parameters
id
required
string
Example: 2
Responses
200

Success status code ( 200 )

404

currency not found

get/currencies/{id}
Request samples
Response samples
application/json
{
  • "id": "1",
  • "type": "crypto",
  • "symbol": "BTC",
  • "name": "Bitcoin",
  • "logo": {
    },
  • "decimalPlaces": 0,
  • "rank": 0,
  • "status": "active",
  • "urls": {},
  • "requiredConfirmations": 0
}

Get latest block number by currency

Get the latest blockchain block number by currency Id

Request
path Parameters
id
required
string
Example: 1
Responses
200

Success status code ( 200 )

404

Block number not found

get/currencies/blockchain-nodes/{id}/latest-block-number
Request samples
Response samples
application/json
{
  • "currencyId": "1",
  • "latestBlockNumber": 773862
}

Gets a list of all possible currency conversions

Get a list of all possible currency conversions

Responses
200

Success status code ( 200 )

400

Bad request

get/currencies/conversions
Request samples
Response samples
application/json
[
  • {
    }
]

Get the required confirmations for each currency

Get required confirmations for each currency. Note: The endpoint does not require authorization.

Responses
200

Success status code ( 200 )

400

Bad request

get/currencies/required-confirmations
Request samples
Response samples
application/json
[
  • {
    }
]

Rates API

API for rates supported by CoinPayments.

Conversion rates between currencies

Returns the currency conversion rates for the specified from currencies converted to the specified to currencies. Note: The endpoint does not require authorization.

Request
query Parameters
from
required
integer

comma separated list of currency ids to use as the source for rate calculations

Example: from=1
to
integer

comma separated list of currency ids for which to retrieve conversion rates for (from the from currencies)

Responses
200

Success status code ( 200 )

400

Bad request

get/rates
Request samples
Response samples
application/json
{
  • "items": [
    ]
}

Invoices API

CoinPayments exposes invoices API endpoints allowing merchants to implement a payment gateway on their platform, and let buyers pay for goods and services in a wide selection of cryptocurrencies.

With CoinPayments invoices API you may:

  1. Create invoice links for payment collection.
  2. Build custom white label checkout solutions for your business.
  3. Create buy-now buttons for quick buyers' checkout. CoinPayment’s invoices API is built around “invoice” entity. In other words, under the hood it generates an invoice with all the buyer’s and merchant’s data plus information on the product/service. Thus, merchants will be flexible in managing payments with the help of this data via a set of available endpoints.

Below you will find information on how payment flow is organized for each of the above-mentioned approaches.

Payment Flow for Invoice Links

Let us consider a subscription use case, where you have a platform that provides services with a subscription payment model. Every month you need to send out invoices to your users with the reminder to pay for the subscription and ability to collect this payment in crypto. In order to automate this flow, you may want to use CoinPayments API. Here are the steps that should take place in order for a payment to occur:

  1. Merchant adds details on services for which invoice is issued, indicates user’s details like name, payment address and email, if provided.
  2. With the help of createInvoice endpoint merchant generates an invoice entity with the data from step 1.
  3. As a response to the createInvoice endpoint, merchant receives:
  • an invoice Id to further check invoice status
  • a link to the invoice document with the active payment button that would lead user to payment checkout.

Note: In order this request could work properly, merchant must make sure to eliminate the following attribute from the request:

   "payment": {
     "paymentCurrency": "1004:somecontractaddress"
     "refundEmail": "user@example.com"
   }

Providing the 'refundEmail' and 'paymentCurrency' will initiate the White Labeling flow disclosed below. Leaving 'payment' attribute empty will cause an error.

  1. Invoice is added to merchant's account transaction history where merchant will be able to track payment status.
  2. Merchant sends out the link to the invoice to the buyer.
  3. Buyer enters their email for potential refunds, selects the currency for payment.
  4. The buyer is presented with a payment address, total amount of cryptocurrency to-be-deposited, and a timer within which the transaction has to be completed.
  5. At the same time currency of payment is reflected in the transaction details of the payment in the merhant's transaction history.
  6. Additionally, if the merchant has webhooks set-up, CoinPayments will be sending invoice payment notifications for each status change thereof (e.g. invoiceCreated, invoicePending, invoicePaid, invoiceCompleted, invoiceCancelled, invoiceTimedOut).

Payment Flow for Integrated Checkout with White Labeling

Let us consider a case where you have an online shop and you want to accept payment for goods in cryptocurrency. With CoinPayments API you will be able to allow buyers to request goods and pay with the cryptocurrency all at your website and under your own branding. Here are the steps that should take place in order payment could occur:

  1. Buyer selects product/service on the merchant’s site and adds them to the shopping cart. At the checkout, buyer indicates their details like name, payment address and email and clicks "Pay".
  2. By clicking "Pay", buyer launches the payment flow. In this flow, buyer's email provided when creating the order, is recorded as the 'RefundEmail' in the 'creteInvoice' request for possible refunds in case of over- and underpayment.
    {
      ...
      "Payment": {
     "RefundEmail": "norefunds@in.crypto"
      }
    }
    

At the same time, the 'createInvoice' endpoint generates an invoice entity including:

  • 'invoiceId' to get payment address and check payment status
  • list of available currencies for payment with currency description, payment amount and fees
  • payment expiration timestamp.
  1. If merchant wants to allow buyer to select currency at checkout, payment address is obtained with the help of 'getPaymentAddressByCurrency' endpoint, once buyer chooses the currency for payment. If merchant's website has preset currency for all goods and services, the same endpoint must be triggered at step 2., once buyer clicks "Pay". As a result, buyer is presented with the following data:
  • a currency id
  • a payment address
  • total amount of the selected cryptocurrency to be deposited
  • timer for completing the transaction.

3.a. A merchant can combine steps 2 and 3 into one, i.e. create an invoice for the shopping cart content already with the payment in the specific cryptocurrency. For this, when creating invoice, merchant should provide id of the 'PaymentCurrency' in the 'Payment' entity of the 'CreateInvoice' request:

{
  ...
  "Payment": {
    "RefundEmail": "test@gmail.com",
    "PaymentCurrency": "1004:somecontractaddress"
    }
  }

The indication of the cryptocurrency id will trigger creation of the invoice together with payment and HotWallet (address for buyer).

  1. After that merchant can check the status of the payment with the help of getPaymentStatus endpoint that includes:
  • status of payment
  • how much was detected and confirmed on blockchain
  • how much was detected but not confirmed yet.
  1. Additionally, if the merchant has webhooks set-up, CoinPayments will be sending payment notifications for each status change (e.g. invoiceCreated, invoicePending, invoicePaid, invoiceCompleted, invoiceCancelled, invoiceTimedOut).

A merchant can simplify the payment process for the buyer by incorporating payment details like payment amount, currency and payment address into a QR code. Below is an example of a script to create a QR code:



<div id="canvas"></div>
<script type="text/javascript" src="https://unpkg.com/qr-code-styling@1.5.0/lib/qr-code-styling.js"></script>
<script type="text/javascript">
  const generateQRData = (currency, address, tag, amount) => {
    switch (currency.name) {
      case 'Bitcurrency SV':
        return `bitcurrency:${address}?sv&amount=${amount}`;
      case 'Tether USD (Omni)':
        return `bitcurrency:${address}?amount=${amount}&req-asset=${currency.id}`;
      case 'BinanceCoin':
        return `bnb:${address}?sv&amount=${amount}&req-asset=${currency.id}`;
      case 'Tether USD (ERC20)':
        return `ethereum:${address}?value=${amount}&req-asset=${currency.id.slice(currency.id.indexOf(':') + 1)}`;
      case 'Tether USD (TRC20)':
        return `tron:${address}?value=${amount}&req-asset=${currency.id.slice(currency.id.indexOf(':') + 1)}`;
      default:
        return `${currency?.name?.toLowerCase().replace(/ /g, '')}:${address}?amount=${amount}${tag ? `&tag=${tag}` : ''}`;
    }
  };

  const color = "#2A5ED5";
  const corner = "#000000";
  const margin = 5;

  const qrCode = new QRCodeStyling({
    width: 200,
    height: 200,
    dotsOptions: {
      color: color,
      type: "square"
    },
    backgroundOptions: {
      color: "transparent",
      gradient: null
    },
    cornersSquareOptions: {
      type: "square",
      color: corner
    },
    cornersDotOptions: {
      type: "square",
      color: corner
    },
    imageOptions: {
      crossOrigin: "anonymous",
      imageSize: 0.5,
      margin: margin
    }
  });

  qrCode.append(document.querySelector('#canvas'));
  qrCode.update({
    data: generateQRData(currency, address, tag, amount)
  });
  </script>

Payment Flow for Integrated Checkout with Buy-Now Button

Let us consider another case for an online shop where you want to accept payment for goods in cryptocurrency and want to allow your buyers to make quick purchases by clicking on the Buy-Now button next to the good or service you offer. With CoinPayments API you will be able to allow buyers to request goods and pay with the cryptocurrency in a matter of a few clicks. Here are the steps that should take place in order payment could occur:

  1. Buyer detects product/service on the merchant’s site and wants to order them immediately, so they click on the "Pay with CoinPayments" button next to the product/service.
  2. By clicking "Pay with CoinPayments", buyer launches the payment flow. As a first step of the flow, buyer is requested to provide their email. The email is recorded as the 'RefundEmail' in the creteInvoice request for possible refunds in case of over- and underpayment. At the same time, the createInvoice endpoint generates an invoice entity including:
  • invoiceId to get payment address and check payment status
  • list of available currencies for payment with currency description, payment amount and fees
  • payment expiration timestamp.
  1. If merchant wants to allow buyer to select currency at checkout, payment address is obtained with the help of getPaymentAddressByCurrency endpoint, once buyer chooses the currency for payment. If merchant's website has preset currency for all goods and services, the same endpoint must be triggered once buyer clicks "Pay". As a result, buyer is presented with a payment address, total amount of the selected cryptocurrency to be deposited, and a timer within which the transaction has to be completed.
  2. After that merchant can check the status of the payment with the help of 'getPaymentStatus' endpoint that includes:
  • status of payment
  • how much was detected and confirmed on blockchain
  • how much was detected but not confirmed yet.
  1. Additionally, if the merchant has webhooks set-up, CoinPayments will be sending payment notifications for each status change (e.g. invoiceCreated, invoicePending, invoicePaid, invoiceCompleted, invoiceCancelled, invoiceTimedOut).

Payment Settings

Funds that merchants receive via payments are primarily deposited to the CoinPayments system balance. From there, Coinpayments conducts payouts to the merchant's balance. CoinPayments UI provides the merchant with a possibility to set up mode and frequency for paying out funds from CoinPayments balance to the merchant's own balance. The settings are set up by currency.

markdown file changed

Below, you will find the detailed information on each of the invoices endpoints and their field values. Endpoints are the same for both described use-cases with the slight difference in utilizing certain fields in schemas. All such differences will be outlined explicitly.

Create Invoice

Request to create an invoice, which is a list of goods or services with a statement of the sum due provided by the merchant, that a buyer intends to purchase

Request
Request Body schema: application/json

Create Invoice

isEmailDelivery
boolean
Default: false

default value to be used for whitelabeling checkout flow. For invoice document delivery indicates if invoice will be email delivered

object

email addresses to be used for invoice delivery

dueDate
string

date until invoice document is due

invoiceDate
string

to be used for invoice doc delivery. Date when invoice is to be mailed out to the user

draft
boolean
Default: false

Default value to be used for whitelabeling checkout flow. Flag indicating whether this is a draft invoice

clientId
required
string

the id of the client (merchant) creating this invoice

invoiceId
string
Default: false

default value to be used for whitelabeling checkout flow. For invoice document delivery invoice number assigned by the merchant

object (buyer)
description
string

the purchase description, can be provided instead of a list of items

required
Array of objects (items)

array of items that a buyer intends to purchase from the merchant

required
object

detailed amount of purchase with the breakdown of all fees

object (shipping)

shipping method info

requireBuyerNameAndEmail
boolean

flag indicating whether a buyer name and email are required, they will be requested at checkout if not provider by the caller.

buyerDataCollectionMessage
string

the message to display when collecting buyer user data

notes
string

notes for the merchant only, these are not visible to the buyers

notesToRecipient
string

any additional information to share with the buyer about the transaction

termsAndConditions
string

any terms and conditions, e.g. a cancellation policy

object (merchantOptions)

merchant's details to be shown on the invoice

object

any custom data merchant wishes to attach to the invoice that may be further used for custom merchant's purposes. Not visible on UI for buyers

object
poNumber
string <InvoiceBuilder>

optional Purchase order number on the integration API.

Array of objects (webhookSchema)

data on webhooks sent for invoices

required
object

the field contains additional data specific for whitelabeled payments, e.g. buyer's email that is used for possible refunds

Responses
200

Success. Invoice in all available currencies. Note, for Invoice Links flow, only "id" and "link" properties are necessary

401

Not Authorized

403

Forbidden

post/merchant/invoices
Request samples
application/json
{
  • "isEmailDelivery": false,
  • "emailDelivery": {
    },
  • "dueDate": "2023-04-26T18:40:41.322Z",
  • "invoiceDate": "2022-11-28T13:59:46+00:00",
  • "draft": false,
  • "clientId": "string",
  • "invoiceId": false,
  • "buyer": {
    },
  • "description": "string",
  • "items": [
    ],
  • "amount": {
    },
  • "shipping": {
    },
  • "requireBuyerNameAndEmail": true,
  • "buyerDataCollectionMessage": "string",
  • "notes": "string",
  • "notesToRecipient": "string",
  • "termsAndConditions": "string",
  • "merchantOptions": {
    },
  • "customData": {
    },
  • "metadata": {
    },
  • "poNumber": "string",
  • "webhooks": [],
  • "payment": {
    }
}
Response samples
application/json
{
  • "invoices": [
    ]
}

Get invoices

Get list of merchant invoices

Request
query Parameters
clientId
string

optional clientId field to allow filtering by integration clientId.

Example: clientId=9c2cbbb936824b9d91a1229321bfd03a
status
string

optional status field to allow filtering by invoice status.

Example: status=draft, paid, pending, cancelled, completed
from
string

optional "from" field to allow filtering by invoice creation date.

Example: from=2023-01-01
to
string

optional "to" field to allow filtering by invoice creation date.

Example: to=2023-01-30
q
string

optional search string to find invoices with these words.

Example: q=9c2cbbb936824b9d91a1229321bfd03a
integration
string

optional integration field to allow filtering by integration.

Example: integration=9c2cbbb936824b9d91a1229321bfd03a
payoutWalletId
string

optional query to filter the invoices by the wallet they were paid out to (for 'paid' and 'completed' invoices).

Example: payoutWalletId=9c2cbbb936824b9d91a1229321bfd03a
limit
integer

used to specify the number of records to return in one page.

Example: limit=10
after
string

used to specify a cursor or marker that indicates the starting point of the next page of data.

Example: after=9c2cbbb936824b9d91a1229321bfd03a
Responses
200

Success

404

Merchant Not Found!

get/merchant/invoices
Request samples
Response samples
application/json
[
  • {
    }
]

Create Buy-Now Button

Request to create a buy-now button, which allows for quick checkout for goods or services with a statement of the sum due, that is offered by the merchant, and that a buyer intends to purchase. The request creates a button script to be inserted into the merchant's website

Request
Request Body schema: application/json

Create Buy-Now Button

successUrl
string

the url to redirect to once an invoice is successfully paid

cancelUrl
string

the url to redirect to, if payment of an invoice fails (e.g. expired) or is cancelled by the user

ipnUrl
string

the url for receiving webhooks on payment

notifications
Array of arrays

comma separated list of strings designating notification types to be sent as webhooks for the payment. Available values are invoiceCreated, invoicePending, invoicePaid, invoiceCompleted, invoiceCancelled, invoiceTimedOut

emailNotifications
boolean

flag indicating whether to send an email notification once payment completes successfully

buttonWidth
string

width of the created button

buttonStyle
string

style of the button

Array of objects (items)

array of items that a buyer intends to purchase from the merchant

required
object

detailed amount of purchase with the breakdown of all fees

Responses
200

Success.

401

Not Authorized

403

Forbidden

post/merchant/invoices/buy-now-button
Request samples
application/json
{
  • "successUrl": "string",
  • "cancelUrl": "string",
  • "ipnUrl": "string",
  • "notifications": [ ],
  • "emailNotifications": true,
  • "buttonWidth": "string",
  • "buttonStyle": "string",
  • "items": [
    ],
  • "amount": {
    }
}

Get payment address by currency id

Once invoice is created and buyer selects currency for payment, by using this endpoint merchant obtains address for payment that is then displayed to buyer in the checkout window and may be used for money transfer.

Request
path Parameters
id
required
string

Id of the invoice

currencyId
required
string

currency Id

Example: 2
Responses
200

Success status code (200) - Address for buyer to make payment with indication of currency, amount, and expiration timer

401

Unauthorized

403

Forbidden

get/invoices/{id}/payment-currencies/{currencyId}
Request samples
Response samples
application/json
{
  • "currency": {
    },
  • "amount": {
    },
  • "addresses": {
    },
  • "expires": "string",
  • "remainingAmount": {
    }
}

Get payment status once payment is made

Although it is usually sufficient to rely on webhooks for up-to-date status of your transactions, merchants are also able to verify the webhook information with this endpoint.

Request
path Parameters
id
required
string

Id of the invoice

currencyId
required
string
Example: 2
Responses
200

Success status code ( 200 ) - Status of the invoice

401

Unauthorized

403

Forbidden

get/invoices/{id}/payment-currencies/{currencyId}/status
Request samples
Response samples
application/json
{
  • "created": "string",
  • "expires": "string",
  • "status": [
    ],
  • "payment": {
    },
  • "partialAcceptAvailable": true
}

Get invoice by Id

Get Invoice by Id

Request
path Parameters
id
required
string (id)
Example: nKCMuD6h3Vsgs4mGDqGeV
Responses
200

Success status code ( 200 )

400

Bad request example!

get/merchant/invoices/{id}
Request samples
Response samples
application/json
{
  • "isEmailDelivery": false,
  • "emailDelivery": {
    },
  • "dueDate": "2023-04-26T18:40:41.322Z",
  • "invoiceDate": "2022-11-28T13:59:46+00:00",
  • "draft": false,
  • "clientId": "string",
  • "invoiceId": false,
  • "buyer": {
    },
  • "description": "string",
  • "items": [
    ],
  • "amount": {
    },
  • "shipping": {
    },
  • "requireBuyerNameAndEmail": true,
  • "buyerDataCollectionMessage": "string",
  • "notes": "string",
  • "notesToRecipient": "string",
  • "termsAndConditions": "string",
  • "merchantOptions": {
    },
  • "customData": {
    },
  • "metadata": {
    },
  • "poNumber": "string",
  • "webhooks": [],
  • "payment": {
    }
}

Get invoices payouts

Get payout details for an invoice, including if invoice has been fully paid out, the exact amount the merchant will receive and in what currency, which address payout will be deposited to, and who (Buyer) performed the payment.

Request
path Parameters
id
required
string

invoice Id

Example: 5xyKTbjTMcbXMUsaprSRaP
Responses
200

Success

404

Merchant Not Found!

get/merchant/invoices/{id}/payouts
Request samples
Response samples
application/json
{
  • "paidTransactions": [
    ],
  • "paidDate": "string",
  • "completedTxId": "string",
  • "externalAddress": "string",
  • "destinationCurrencyId": "string",
  • "expectedDisplayValue": "string",
  • "sourceCurrencyId": "string",
  • "destinationAccountId": "string",
  • "isConversion": false,
  • "conversionProgress": 0,
  • "settlementModeErrorCode": 0,
  • "destinationAmount": {
    },
  • "items": [
    ]
}

Get invoice history

List history events of an invoice by the invoice Id

Request
path Parameters
id
required
string (id)
Example: nKCMuD6h3Vsgs4mGDqGeV
Responses
200

Success

404

Merchant Not Found!

get/merchant/invoices/{id}/history
Request samples
Response samples
application/json
{
  • "items": [
    ],
  • "paging": {
    }
}

Wallets API

CoinPayments provides merchants with the flexibility to create and manage wallets either through the user-friendly UI or via API calls. Due to security reasons, wallets created via UI cannot be managed via API. However, all wallets created via API are available through UI with the full functionality scope. Hence, in case merchant requires their funds from the wallet that was originally created via UI to be accessible via API, they need to sweep funds from the "UI wallet" to the "API wallet".

Since merchants may have several API clients activated, it is important to note that wallets created under one API client cannot be controlled by a different API client.

The Wallets API provides a set of endpoints that enable merchants to create new wallets with the coins supported by the platform, as well as initiate withdrawal requests from their wallets to any external or internal address of their choosing. With this powerful functionality, merchants have extensive control and flexibility in managing their cryptocurrency wallets to cater to their specific business needs.

Addresses created via CoinPayments API are used as commercial addresses for commercial funds, e.g. gambler casino accounts. Hence, merchants require flexibility when accumulating and sweeping funds from such commercial addresses.

UTXO addresses, by their nature, allow for accumulation of funds and, hence, reduction of network fees when withdrawing funds in bulk from such addresses. Thus, it is possible to assign UTXO addresses to the merchant (and merchant can assign specific address to a specific customer) for permanent use without any considerable loss in service fees when managing funds. As a result, CoinPayments refers to UTXO addresses created via API as permanent addresses.

Account-based addresses created via CoinPayments API may be either temporary or permanent depending on the flag set up by the merchant when creating a new account-based address.

CoinPayments randomly emits temporary account-based address to a merchant so that the merchant could obtain a commercial deposit from a customer. The address stays in merchant's use for a certain period of time set up by the CoinPayments admins. When the time period expires, the address returns to the pool of CoinPayments addresses. This time period is renewed in case the address is topped up again before the set time period rus out. If the address returns to the pool, the funds are automatically assigned to the corresponding merchant API wallet within which the address had been emitted. Consolidation of funds from addresses at the main wallet balance is CoinPayments responsibility in this design and allows for reduction in fees when sweeping wallet balance elsewhere. Nevertheless, some merchants might find it uncomfortable that addresses cannot be assigned permanently to specific customers. Hence, customer must always check for the correct address before sending funds to the merchant.

The merchant can decide to use permanent account-based addresses if it is important to manage funds/balances deposited by their customers individually. For that, when creating a commercial wallet via API, merchant must enable the usePermanentAddresses flag. Thus, all the addresses created within such wallet will be permanent. This will allow merchant to assign specific addresses to specific clients perpetually. Such design allows for better customer experience. Also, merchant can manage themselves when to sweep funds from addresses to the main wallet balance and further. Address balance is always swept in full to the main wallet balance in order to reduce the amount of cases when a small amount of funds is stuck on the address because the fee for withdrawal equals or higher than the withdrawn amount.

The tradeoff of the permanent address vs. temporary address design is fees. In order to be able to consolidate the balances of all permanent addresses within the wallet at its main balance, each new address must be activated. The activation fee is charged only once when the first withdrawal from the address takes place. However, the network fee is charged everytime funds are withdrawn from each address. Unlike with UTXO addresses, accumulation of network fees for withdrawals from the account-based addresses is not possible, hence, leading to larger expenses at the merchant's side.

Note: When sending funds to an address, make sure that the address you are sending to matches the token/coin that you credit to the address. Otherwise, this may lead to the funds being stuck in the network or even lost.

A common case for merchants is to use wallets and addresses created via API for receiving payments from their customers, e.g. top-up a subscription or casino account. A merchant can simplify the payment process for the buyer by incorporating payment details like payment amount, currency and payment address into a QR code. This will decrease the possibility of an error when sending funds.

For the QR code script example check description of the Payment Flow for Integrated Checkout with White Labeling in the Invoices API.

Note:

Unlike wallets and addresses created via UI, wallets and addresses created via API can send webhook notifications to the URL specified by the merchant when funds are received by/withdrawn from the wallet/address:

{
  "walletId":"4ca18e8e-915b-4a69-a17a-0b0b666858a7",
  "address":"myGTmrMtU6vUULkYRCDxJMggF7egsXhcTi",
  "transactionId":"cb44e78f-a97b-44b5-a23d-1e3b025aab47",
  "txHash":"9d9dd1f6f4a62388797e6beeb76c1a3c34d41942303ce6fb49177d3c88a74d11",
  "transactionType":"UtxoExternalReceive",
  "amount":"2",
  "symbol":"LTCT",
  "nativeAmount":"173.35",
  "nativeSymbol":"USD",
  "confirmations":3,
  "requiredConfirmations":3
}

Create wallet

Creates new wallet by currency Id. Note: you can get the currency Id from the Сurrencies API.

Request
Request Body schema: application/json
required

Create wallet payload

currencyId
required
number

Id of the currency for which wallet is created

label
required
string

Label denoting the wallet

webhookUrl
string

when provided, CoinPayments API will be sending notifications to this URL when withdrawals are processed or when funds are moved

contractAddress
string

an optional address of the smart contract representing a token

usePermanentAddresses
boolean

flag that indicates whether the wallet is to use permanent addresses or temporary ones. The wallet will support addresses of one type only

Responses
200

Success

404

Currency Not Found!

post/merchant/wallets
Request samples
application/json
{
  • "currencyId": 1,
  • "label": "John's wallet",
  • "webhookUrl": "https://myapi.com",
  • "contractAddress": "string",
  • "usePermanentAddresses": true
}
Response samples
application/json
{
  • "walletId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "address": "LaN1Vy2FugxWiAyMc8ipKe6Hcnh3mcKuym"
}

Get Wallets

Retrieves a list of wallets with their balances, addresses, statuses and other info.

Responses
200

OK

404

Wallet not found

get/merchant/wallets
Request samples
Response samples
application/json
[
  • {
    }
]

Get Wallet by Id

Retrieves wallet by its Id

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
Responses
200

OK

404

Wallet not found

get/merchant/wallets/{walletIdStr}
Request samples
Response samples
application/json
{
  • "walletId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "walletType": [
    ],
  • "currencyId": 1,
  • "isActive": true,
  • "isLocked": true,
  • "label": "John's wallet",
  • "depositAddress": "0x9939b7b208012cd0395d1411272be6e34c04af7b",
  • "confirmedBalance": {
    },
  • "unconfirmedBalance": {
    },
  • "unconfirmedNativeBalance": {
    },
  • "confirmedNativeBalance": {
    },
  • "confirmedTokens": [
    ],
  • "unconfirmedTokens": [
    ],
  • "canCreateAddress": true,
  • "isVaultLocked": true,
  • "vaultLockoutEndDateTime": "2023-07-04T22:21:41.535Z",
  • "contractAddress": "string",
  • "hasActiveAddress": true
}

Update wallet webhook Url

Allows to update Url used to receiving webhooks for wallet transactions

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
Request Body schema: application/json
required

Update wallet webhook Url

notificationUrl
string

merchant's Url where webhooks are sent

Responses
200

Success

401

Unauthorized

403

Forbidden

put/merchant/wallets/{walletIdStr}/webhook
Request samples
application/json
{
  • "notificationUrl": "string"
}

Create address for an existing wallet

This endpoint creates a new address under the wallet with the specified ID. The walletIdStr parameter is a required path parameter that identifies the target wallet. The request body is optional, but if included, it can contain a label field to provide a label for the new address. The response to a successful request returns a 201 Created status code and an object containing the address and the address ID.

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
query Parameters
label
string

label for the address

Example: label=shop tests address
notificationUrl
string

an optional URL for receiving webhook notifications

Responses
201

Success

404

Wallet Not Found!

post/merchant/wallets/{walletIdStr}/addresses
Request samples
Response samples
application/json
{
  • "addressId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "networkAddress": "LNUPQLeQFfF67RtH1dqFBiwJhYBNZCW7pm"
}

Get wallet addresses

Retrieves a list of wallet addresses

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
query Parameters
skip
integer

used for paging. The page is limited to 100 items. Number of addresses to skip before displaying the following batch of addresses

take
integer

used for paging. The page is limited to 100 items. Number of addresses to display in the batch

Responses
200

OK

404

Wallet not found

get/merchant/wallets/{walletIdStr}/addresses
Request samples
Response samples
application/json
[
  • {
    }
]

Get Address of the Wallet by Id

Retrieves address by wallet and address Ids

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
addressIdStr
required
string

the address Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
Responses
200

OK

404

Address not found

get/merchant/wallets/{walletIdStr}/addresses/{addressIdStr}
Request samples
Response samples
application/json
{
  • "addressId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "label": "string",
  • "address": "string",
  • "notificationUrl": "string",
  • "rentedTill": "string"
}

Update address webhook Url

Allows to update Url used to receiving webhooks for address transactions

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
addressIdStr
required
string

the address Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
Request Body schema: application/json
required

Update address webhook Url

notificationUrl
string

merchant's Url where webhooks are sent

Responses
200

Success

401

Unauthorized

403

Forbidden

put/merchant/wallets/{walletIdStr}/addresses/{addressIdStr}/webhook
Request samples
application/json
{
  • "notificationUrl": "string"
}

Get wallet transactions

Retrieves a list of all wallet transactions

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
Responses
200

Ok

404

Wallet not found

get/merchant/wallets/{walletIdStr}/transactions
Request samples
Response samples
application/json
[
  • {
    }
]

Get wallet transaction

Get a specific transaction of a wallet. This request requires the walletIdStr URL parameter. Additionally, there are two optional query parameters: transactionId and spendRequestId. For a valid request at least one of these parameters must be specified. If both transactionId and spendRequestId are specified, transactionId takes precedence. If only spendRequestId is provided, the first transaction that matches the spendRequestId will be returned.

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
query Parameters
transactionId
string

the transaction Id

Example: transactionId=0a54b29f-51cb-44a8-9bed-111c5cb1b335
spendRequestId
string

the spend request Id

Example: spendRequestId=0a54b29f-51cb-44a8-9bed-111c5cb1b335
Responses
200

Ok

404

Wallet not found

get/merchant/wallets/{walletIdStr}/transaction
Request samples
Response samples
application/json
{
  • "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  • "dateCreated": "2022-10-05T08:39:41.494Z",
  • "dateCompleted": "2022-10-05T08:40:41.494Z",
  • "fromOwnerId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  • "fromWalletId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  • "toWalletId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  • "spendRequestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  • "fromCurrencyId": 1,
  • "toCurrencyId": 2,
  • "fromAmount": "0.22390234",
  • "toAmount": "0.13448434",
  • "coinPaymentsFee": "0.000012",
  • "transactionStatus": "created",
  • "transactionType": "externalSpend",
  • "memo": "July rent",
  • "fromAddress": "1AYASDI34W2W2SIFFRE32452S1Q",
  • "toAddress": "1AYASDI34W2W2SIFFRE32452S1Q",
  • "txHash": "1AYASDI34W2W2SIFFRE32452S1Q3289y7debugDSDSd38d3xSSA33ASDRxw98",
  • "outputIndex": 1,
  • "blockchainFee": "0.00000032",
  • "fromContractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "toContractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "blockchainFeeCurrency": {
    },
  • "coinPaymentsFeeCurrency": {
    },
  • "blockNumberTxAppearedAt": "string",
  • "supportTransactionId": {
    },
  • "confirmations": 2,
  • "requiredConfirmations": 5,
  • "fromAmountNative": {
    },
  • "toAmountNative": {
    },
  • "coinpaymentsFeeNative": {
    },
  • "blockchainFeeNative": {
    },
  • "isInvoicePaymentSend": true,
  • "paymentType": {
    }
}

Execute merchant wallet consolidation

This endpoint executes the sweep of the balances from all selected addresses of the wallet to the main wallet balance. The endpoint is applied only for account-based currency wallets that contain permanent addresses.

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
query Parameters
addressIds
string

comma-separated values of addresses from which funds are to be swept to the main wallet balance

Responses
200

Success

401

Unauthorized

403

Forbidden

post/merchant/wallets/{walletIdStr}/consolidation
Request samples
Response samples
application/json
{
  • "newReceivedInternal": "string",
  • "newReceivedExternal": "string",
  • "activationFee": "string",
  • "transferFee": "string",
  • "totalFee": "string",
  • "available": "string",
  • "addresses": [
    ]
}

Get details of merchant wallet consolidation

This endpoint displays details of the possible sweep from the balances of all available wallet addresses to the main wallet balance. The endpoint is applied only for account-based currency wallets that contain permanent addresses. By using this endpoint merchant can decide from which addresses to make a sweep.

Request
path Parameters
walletIdStr
required
string

the wallet Id

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
query Parameters
addressIds
string

comma-separated values of addresses for which merchant wants to check details before executing sweep

Responses
200

OK

401

Unauthorized

403

Forbidden

get/merchant/wallets/{walletIdStr}/consolidation
Request samples
Response samples
application/json
{
  • "newReceivedInternal": "string",
  • "newReceivedExternal": "string",
  • "activationFee": "string",
  • "transferFee": "string",
  • "totalFee": "string",
  • "available": "string",
  • "addresses": [
    ]
}

Create spend or convert request

The Spend Request API allows users to initiate a withdrawal or a conversion transaction, both features follow a two-step process:

1- Send spend request: This request will trigger a response containing a preview of the transaction, including any applicable fees. The purpose of this step is to allow users to review and verify the information provided, including the amount and any associated fees before proceeding.

2- Confirm spending funds: the confirm spending funds endpoint is used to confirm spending funds from the merchant wallet, or to confirm converting funds. It is used to trigger publishing the transaction on the blockchain.

Note: The "spendRequestId", used to confirm spending funds, is available in the response from the first step.



Here's a simplified flowchart explaining the withdrawal/conversion flow:

markdown file changed

Request
path Parameters
walletIdStr
required
string

the wallet Id where you intend to withdraw funds from

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
Request Body schema: application/json
required

Withdrawal Request payload

toAddress
required
string

Address where client wants to send funds to

toCurrencyId
required
number

currency Id of the benificiary wallet

fromContractAddress
string

Address of the contract of the "fromCurrency" e.g. "0xdac17f958d2ee523a2206206994597c13d831ec7" for ERC20 TetherUSD

toContractAddress
string

Address of the contract of the "toCurrency" e.g. "0xdac17f958d2ee523a2206206994597c13d831ec7" for ERC20 TetherUSD

amountInSmallestUnits
required
string

refers to the amount of a specific cryptocurrency, such as Bitcoin, measured in its smallest divisible unit, AKA atomic units (e.g., Satoshis for Bitcoin). It allows for precise and detailed transactions by specifying the amount in the smallest possible denomination. This approach enables you to send fractional amounts of the currency accurately.

blockchainFeeOverrideInSmallestUnits
number

Used for overriding the system suggested blockchain fee (within 10% range) to manage the transaction processing speed

memo
string

user-defined note for the funds withdrawal

receiverPaysFee
boolean

When set to true, the receiver of the transaction will pay the fees. In this case, the AmountInSmallestUnits will be deducted from the source balance, and the receiver will receive the remaining amount after deducting the fees. When set to false (or not provided), the fees will be added to the AmountInSmallestUnits, and the total sum (including fees) will be deducted from the source balance. The receiver will receive the AmountInSmallestUnits exactly as specified.

Responses
202

Ok

400

Not enough funds

404

Wallet not found

post/merchant/wallets/{walletIdStr}/spend/request
Request samples
application/json
{
  • "toAddress": "mtxASJZHNmGeUPQ3DxLvJeKja6Lh7TcJM9",
  • "toCurrencyId": 6,
  • "fromContractAddress": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
  • "toContractAddress": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
  • "amountInSmallestUnits": "9900000",
  • "blockchainFeeOverrideInSmallestUnits": "0.0003234",
  • "memo": "string",
  • "receiverPaysFee": false
}
Response samples
application/json
{
  • "spendRequestId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "fromWalletId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "toAddress": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "fromContractAddress": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
  • "fromCurrencyId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "toCurrencyId": "0a54b29f-51cb-44a8-9bed-111c5cb1b335",
  • "blockchainFee": 0.0001,
  • "coinpaymentsFee": 0.0001,
  • "fromAmount": 0.0987,
  • "toAmount": 0.0123,
  • "memo": "This is a memo",
  • "toContractAddress": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52"
}

Confirm spend or convert request

Send a request to confirm the withdrawal or conversion

Request
path Parameters
walletIdStr
required
string

the wallet Id from which you intend to withdraw funds

Example: 0a54b29f-51cb-44a8-9bed-111c5cb1b335
Request Body schema: application/json
spendRequestId
required
string

id of the spend request for withdrawal or conversion

Responses
200

Success

404

Spend confirmation not found

post/merchant/wallets/{walletIdStr}/spend/confirmation
Request samples
application/json
{
  • "spendRequestId": "string"
}
Response samples
application/problem+json
{
  • "title": "string",
  • "status": 400,
  • "detail": "string",
  • "instance": "string"
}

Webhooks API

CoinPayments API offers webhook notifications, a powerful feature that allows merchants to seamlessly enable and manage notifications sent from CoinPayments API to their own merchant API when specific events occur. This provides merchants with real-time updates on important activities within their CoinPayments account.

To set up webhook notifications, merchants can easily define a public endpoint URL on their server API and specify the events for which they want to receive notifications.

CoinPayments will send webhooks from one of these IPs:

hook1.coinpayments.com - 23.183.244.249

hook2.coinpayments.com - 23.183.244.250

Authenticate Webhooks from CoinPayments to Your Server

All webhook messages from CoinPayments contain the same headers as used by merchants to sign requests to CoinPayments API:

const headers = {
  'X-CoinPayments-Client': clientId,
  'X-CoinPayments-Timestamp': date,
  'X-CoinPayments-Signature': signature,
};

By verifying the signature with the help of the private key, merchant can make sure that the received webhook is produced by CoinPayments server.

Here is an example of the received notification with headers included:

POST to webhook URL: http://localhost:9004/api/invoices/callbacks

Headers:

X-CoinPayments-Signature = 60NsOvvOwtWxtNBpkrY615Y3iPNGDAWReegr2LUwIpY=
X-CoinPayments-Client = dc6a16e545c34187ba21a9edbbe484a5
X-CoinPayments-Timestamp = 2024-07-01T11:04:10

Body (JSON):

{
  "id": "8a49a588266246a2ab5f43217ca993bd",
  "type": "InvoiceCreated",
  "timestamp": "2024-07-01T11:04:06.8033575+00:00",
  "invoice": {
    "invoiceId": "0067",
    "id": "2008d68d-0f66-44ec-8500-68d054b882b9",
    "userId": "fd2d3885-b90b-4c8a-bf6d-bd94970781db",
    "userEmail": "mykola.lutsenko+t21@hypedriven.com",
    "merchantId": "91695d60-c082-406d-a2ed-5be6fbae58a4",
    "merchantClientId": "dc6a16e5-45c3-4187-ba21-a9edbbe484a5",
    "invoiceNumber": "0067",
    "invoiceNumberSuffix": null,
    "createdAt": 1719831846,
    "invoiceDate": null,
    "dueDate": null,
    "description": null,
    "expiresDate": 1751367846,
    "customData": null,
    "notes": null,
    "notesToRecipient": null,
    "buyerDataCollectionMessage": null,
    "termsAndConditions": null,
    "metadata": null,
    "poNumber": null,
    "buyer": null,
    "shipping": null,
    "lineItems": [
      {
        "amount": 10000,
        "customId": null,
        "description": null,
        "name": "test item",
        "originalAmount": 10000,
        "quantity": 1,
        "sku": null,
        "tax": null,
        "type": "Quantity"
      }
    ],
    "merchantOptions": {
      "additionalInfo": null,
      "showAddress": false,
      "showEmail": true,
      "showPhone": false,
      "showRegistrationNumber": false
    },
    "emailDeliveryOptions": null,
    "amount": {
      "currency": {
        "id": 5057,
        "smartContract": null
      },
      "subtotal": 10000,
      "shippingTotal": 0,
      "handlingTotal": 0,
      "discountTotal": 0,
      "taxTotal": 0,
      "total": 10000
    },
    "state": "Unpaid",
    "flags": {
      "requireBuyerNameAndEmail": false,
      "sendPaymentCompleteEmailNotification": false,
      "isPos": false
    },
    "canceledAt": null,
    "completedAt": null,
    "confirmedAt": null,
    "payments": [],
    "payoutConfig": null,
    "partialAcceptAvailable": false
  }
}

By using the following secret:

ClientSecret - 9ZFHcnGMxawADeXRfDtNkQDCjFUK5998oOMhl51QvzM=

merchant can verify the signature within the header:

X-CoinPayments-Signature = 60NsOvvOwtWxtNBpkrY615Y3iPNGDAWReegr2LUwIpY=

thus, making sure the webhook notification is authentic.


Note: Currently, CoinPayments supports webhook notifications for invoices and merchant wallets and addresses. This section provides information on the invoices webhooks. Webhooks for wallets and addresses are set up within Create-wallet and Create-address-for-an-existing-wallet requests. You can find more information about this here.

It's important to note that webhooks are tied to integration clients, and merchants can create multiple clients under their main account on the CoinPayments website, providing flexibility and customization options.

Here is a list of events for which merchants can choose to receive notifications:

  • invoiceCreated: triggered when a new invoice is created
  • invoicePending: triggered when the transfer amount is detected on the blockchain and the transaction has received enough confirmations on chain
  • invoicePaid: triggered when an invoice is successfully paid. A paid invoice means the funds are received in the CoinPayments' wallet for further payout to the merchant
  • invoiceCompleted: triggered when the invoice is paid and funds are added to merchant's balance
  • invoiceCancelled: triggered when an invoice is cancelled by the merchant
  • invoiceTimedOut: triggered once invoice expiration date and time is over

Merchants have the flexibility to set up webhooks either through the user-friendly UI or via API calls. To set up webhook notifications, first, create an API integration via CoinPayments UI. Then follow these steps:

  • Access the dashboard and click on "Integrations" in the left sidebar.
  • Click on the integration that you want to use for webhooks.
  • On the left side of the popup screen, in the "Permissions" field select all necessary actions for which you would like to enable your API integration. For invoices select "Create Invoice", "List Invoices", "Find Invoice", "Invoice Payouts", "List Invoice History".
  • Click "Save" to confirm your selections.

To create a webhook through the UI, continue in the popup screen with the following steps:

  • On the right side of the popup screen, open the dropdown menu to specify the events for which you want to receive notifications.
  • Click "Save" to confirm your selections.

To set up webhook notifications through the API calls, follow these steps:

  • Create a webhook using 'createWebhook' endpoint indicating merchant's 'clientId' of the API integration.
  • In the request body provide a list of notification types you want to receive in the 'notifications' parameter. Possible values are: 'invoiceCreated', 'invoicePending', 'invoicePaid', 'invoiceCompleted', 'invoiceCancelled', 'invoiceTimedOut'.
  • In the request body provide your server URL where the notifications will be sent in the 'notificationsUrl' parameter.

Once completed, your webhook notifications are all set, and your API will receive notifications based on the events you have chosen. This allows you to stay updated in real-time on the activities that matter most to your business.

Notification Payload will include the event type, timestamp of the invoice status update, and the actual invoice object.

Below is a descriptive flowchart illustrating the process of webhook notifications. This example specifically focuses on the scenario where the merchant intends for their server API to receive notifications upon invoice completion.

markdown file changed

Notification Payload

All webhooks sent by CPs API contain information on the event they signalize about and information on the invoice and payment to which the event refers. Below is the payload of the webhooks sent from CPs API to your server API.

Responses
200

Success status code ( 200 )

400

CoinPayments API could not reach your server

post/merchant/your-server-url
Request samples
Response samples
application/json
{
  • "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  • "type": "invoiceCreated",
  • "timestamp": "2023-04-07T06:58:19.9798764+00:0",
  • "invoice": {
    }
}

Create client webhook

Creates new client webhook

Request
path Parameters
clientId
required
string (id)

client Id

Example: nKCMuD6h3Vsgs4mGDqGeV
Request Body schema: application/json
notificationsUrl
required
string (notificationUrl)

url of your site where webhook notifications should be sent

notifications
required
Array of arrays (notifications)

specify the event name you want your server to be notified about when it occurs, e.g. send notification when an invoice is created. Provide values as a comma separated list of strings.

Responses
200

Success

404

Merchant Not Found!

post/merchant/clients/{clientId}/webhooks
Request samples
application/json
{}
Response samples
application/json
{
  • "id": "0a54b29f-51cb-44a8-9bed-111c5cb1b335"
}

Get webhooks of merchant

Get list of merchant webhook notifications

Request
path Parameters
clientId
required
string (id)

client Id

Example: nKCMuD6h3Vsgs4mGDqGeV
query Parameters
type
string

Optional parameter; if specified, only webhooks that support this notification type are returned. Available values are invoiceCreated, invoicePending, invoicePaid, invoiceCompleted, invoiceCancelled, invoiceTimedOut

Responses
200

Success - List of merchant webhook notifications

404

Merchant Not Found!

get/merchant/clients/{clientId}/webhooks
Request samples
Response samples
application/json
{
  • "items": {
    }
}

Update Webhook

Update list of webhook notifications and/or webhook integration Url

Request
path Parameters
clientId
required
string (id)

client Id

Example: nKCMuD6h3Vsgs4mGDqGeV
webhookId
required
string

webhook integration Id

Example: wLKBuD6h3Vama4mGDqHeF
Request Body schema: application/json
notificationsUrl
required
string (notificationUrl)

url of your site where webhook notifications should be sent

notifications
required
Array of arrays (notifications)

specify the event name you want your server to be notified about when it occurs, e.g. send notification when an invoice is created. Provide values as a comma separated list of strings.

Responses
200

Success

404

Webhook not found

put/merchant/clients/{clientId}/webhooks/{webhookId}
Request samples
application/json
{}

Delete Webhook

Delete a webhook integration by client Id and webhook Id

Request
path Parameters
clientId
required
string (id)

client Id

Example: nKCMuD6h3Vsgs4mGDqGeV
webhookId
required
string (id)

webhook Id

Example: nKCMuD6h3Vsgs4mGDqGeV
Responses
204

Success status code - no content

404

Webhook not found

delete/merchant/clients/{clientId}/webhooks/{webhookId}
Request samples