Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. See our Privacy Policy and
Terms.
openapi: 3.2.0
info:
title: BTCPay Greenfield Lightning (Store) API
version: v1
description: '# Introduction
The BTCPay Server Greenfield API is a REST API. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
# Authentication
You can authenticate either via Basic Auth or an API key. It''s recommended to use an API key for better security. You can create an API key in the BTCPay Server UI under `Account` -> `Manage Account` -> `API keys`. You can restrict the API key for one or multiple stores and for specific permissions. For testing purposes, you can give it the ''Unrestricted access'' permission. On production you should limit the permissions to the actual endpoints you use, you can see the required permission on the API docs at the top of each endpoint under `AUTHORIZATIONS`.
If you want to simplify the process of creating API keys for your users, you can use the Authorization endpoint to predefine permissions and redirect your users to the BTCPay Server Authorization UI. You can find more information about this on the API Authorization Flow docs page.
# Usage examples
Use **Basic Auth** to read store information with cURL:
```bash
BTCPAY_INSTANCE="https://mainnet.demo.btcpayserver.org"
USER="MyTestUser@gmail.com"
PASSWORD="notverysecurepassword"
PERMISSION="btcpay.store.canmodifystoresettings"
BODY="$(echo "{}" | jq --arg "a" "$PERMISSION" ''. + {permissions:[$a]}'')"
API_KEY="$(curl -s \
-H "Content-Type: application/json" \
--user "$USER:$PASSWORD" \
-X POST \
-d "$BODY" \
"$BTCPAY_INSTANCE/api/v1/api-keys" | jq -r .apiKey)"
```
Use an **API key** to read store information with cURL:
```bash
STORE_ID="yourStoreId"
curl -s \
-H "Content-Type: application/json" \
-H "Authorization: token $API_KEY" \
-X GET \
"$BTCPAY_INSTANCE/api/v1/stores/$STORE_ID"
```
You can find more examples on our docs for different programming languages:
- cURL
- Javascript/Node.Js
- PHP'
contact:
name: BTCPay Server
url: https://btcpayserver.org
license:
name: MIT
url: https://github.com/btcpayserver/btcpayserver/blob/master/LICENSE
servers:
- url: /
description: BTCPay Server Greenfield API
security:
- API_Key: []
Basic: []
tags:
# --- truncated at 32 KB (34 KB total) ---
# Full source: https://artifacts.apis.io/btcpay/openapi/btcpay-lightning-store-api-openapi.yml