Resources
| Resource | Description | 
|---|---|
| Challenge | A one-time challenge required in the signed message when creating an order. | 
| Order | A long-living order holding payment and payout instructions. | 
| Exchange | An exchange initiated by funding a previously created order. | 
Download our Postman Collection to find examples on how to work with these resources.
Exchange pairs
| Pair | Base currency | Quote currency | 
|---|---|---|
| btc/eur | btc | eur | 
| btc/chf | btc | chf | 
| btc/gbp | btc | gbp | 
Please note that cost, rate and fee are always denominated in the quote currency eur, chf or gbp,
while the amount is denominated in the base currency btc.
Exchange types
| Type | Description | 
|---|---|
| buy | Buy base currency btcfor quote currencyeur,chforgbp. | 
| sell | Sell base currency btcfor quote currencyeur,chforgbp. | 
Proof of ownership
Pocket needs to make sure that the addresses it pays out to are controlled by its users themselves.
It does this by requesting a signature that can only be produced with the private key of the receiving address.
The message that is signed can be chosen freely but must contain a previously generated Challenge token.
The same signature requirement applies to lightning payout_methods.
Affiliation
All orders created through your api client automatically get affiliated to you.
This means that part of the fees is attributed and paid out to you, according to the conditions
defined during registration. If you have multiple agreements, you can use the optional
affiliate_id field to choose which affiliate agreement to use.
Create a challenge
You'll need to create a challenge before you can create a new order. Its random token will have to be included in the message to be signed.
201 created challenge
Get a challenge
Although unlikely, if you ever need to retrieve a previously created challenge
using your client_id, you can do that very simply.
200 existing challenge
Create buy order
An order is a long-living set of a payment and payout instructions.
You create it once and it can be used for one-time Bitcoin purchases, but also
for standing orders. The order also allows you to define the fee_rate applied
to all exchanges (1.2% - 4.5%).
201 created order
Extended public key
To prevent address reuse when re-using an order, the payout method can be
extended with the extended_public_key. The derivation_path is also
required to identify the location of the bitcoin_address. This allows Pocket to
derive a fresh unused address for every payout.
201 created order
Lightning payout method
Apart from an on-chain payout method, you can also configure your order's exchanges to be
paid out through Lightning, by specifying your node_pubkey.
If a lightning_address is provided, an automatic payout attempt is initiated upon the exchange of each incoming payment, provided an invoice can be retrieved from the respective Lightning node.
201 created order
Create sell order new
In contrast to buy orders, sell orders are intended for one-time use only. Before using this new feature, please contact us to clarify the exact terms.
201 created order
Patch an order
You can patch the active and fee_rate fields of an existing order
created with your client_id at any time.
200 patched order
Get an order
You can retrieve all orders created using your client_id at any time.
200 existing order
Get an exchange
You can retrieve all exchanges initiated by orders created using your client_id at any time.
200 executed exchange
200 interrupted exchange
200 refunded exchange
200 settled exchange
Patch an exchange
Exchanges created for lightning orders require additional instructions on how the exchanged bitcoin should be paid out.
The different payout options and fee conditions are included in the webhook exchange.executed event payload.
Invoice payout
In case the receiving lightning node has enough inbound liquidity, this payout option is preferable.
200 patched exchange
400 bad request
Other bad request error codes are:
- in_progress- the payout is already in progress.
- already_completed- the payout is already completed.
- invoice_amount- Invoice contains no or wrong amount.
- invoice_network- Invoice for wrong bitcoin network.
- invoice_expired- The invoice is expired.
- unexpected_node_pubkey- Invoice from the wrong lightning node.
- invalid_invoice- Invoice not valid.
Channel payout beta
In case the receiving node has not enough inbound liquidity, this payout method can be used to open a new payment channel.
The exchanged amount of bitcoin is paid out by leveraging the push_msat field during channel negotiation (see BOLT 2).
200 patched exchange
400 bad request
Other bad request error codes are:
- in_progress- the payout is already in progress.
- already_completed- the payout is already completed.
- channel_payout_not_allowed- Channel payout is not allowed, a direct channel exists.
- node_address_required- Unable to resolve the lightning node address. Please provide the- node_addressand try again.
- unexpected_node_pubkey- Unexpected node pubkey in provided- node_address.
- connect- Unable to connect to the lightning node.