Custom Integration

Using the BTCPay API for Custom Integration

BTCPay implements the same API as Bitpay for creating and managing invoices.

Migrating from BitPay to BTCPay normally is as easy as changing a URL.

While Bitpay only allows one account for one merchant, BTCPay allows a user to manage multiple stores.

Official Client Libraries

BTCPay maintains official client libraries for both Python and NodeJS.

In addition, there are forked repositories of Bitpay's PHP and Ruby clients.

Accessing the API Manually

If not using one of the libraries above, the REST API can be accessed manually.

The authentication mechanism is using BitId.

With BitId, the client of the API (like an e-commerce plugin) generates a private key, then inform the server (BTCPay) about the public key.

Every requests to the API sent by the client is signed with the client's private key.

We call pairing the process to inform BTCPay about your public key.

Pairing process

Your first need to create a new store:

  1. Log in

  2. Go to Stores menu

  3. Click on Create a new store

  4. Enter a friendly name for the store, validate.

There is two method of pairing, client side pairing and server side pairing.

Client side pairing

With client side pairing, the client generates a URL from his public key which a human user can browse to validate the pairing.

Typically the URL looks like<pairingcode_goes_here>.

You can find documentation about how to achieve this with this link.

Server side pairing

The second way, is to generate your private key via some bitcoin library then:

  1. Go to the store's settings

  2. Click on Access tokens

  3. Click on Create new Token

  4. Select merchant's facade and enter your public key,

  5. Click request pairing

  6. Click on Approve


BTCPay Server has an API compatible with Bitpay; changing your e-commerce application from Bitpay to BTCPay should take minimal effort.

You can read the full API documentation on Bitpay's website.

There is only one difference: Bitpay only allows one account for one merchant, BTCPay allows a user to manage multiple stores.

To geneate a pop-up modal experience: 1. Include the btcpay.js script in your html page

<script src ="https://your.btcpay.url/modal/btcpay.js"></script>
  1. Call the invoice API to generate an invoice (example code). This is sample backend code as it contains an auth token that should not be exposed in your front-end.

const axiosClient = axios.create({
timeout: 5000,
responseType: 'json',
headers: {
'Content-Type': 'application/json',
'Authorization': BTCPAY_AUTH
const invoiceCreation = {
"price": 12345,
"currency": "USD",
"orderId": "something",
"itemDesc": "item description",
"notificationUrl": "",
"redirectURL": ""
const response = await"/invoices", invoiceCreation);
const invoiceId =;
  1. Use the invoiceId to pop up the modal

  1. You'll often want to do something like refresh the state of your page when the invoice is paid, or note some kind of state before the modal pops up. You can attach event listeners like this: