Developer Guide

21min
Document image


Introduction

The Voltage API enables you to integrate Lightning Network functionality into your applications. This guide will walk you through common tasks and help you get started with the API.

If you are starting here we are assuming that you already have a team and a staging wallet setup for you. If you do not, the Wallet Setup Guide will get you ready.

Base URL

https://voltageapi.com/v1

Authentication

The Voltage API uses x-api-key authentication methods for API calls:

  • API Key Authentication (via x-api-key header):
--header 'x-api-key: YOUR_API_KEY'

Generating API Key

You can manage your API keys by visiting your team page and clicking on "API Keys"

Document image


Be sure to select the correct Environment for your API key when generating and give it a descriptive name.

Document image


Quick Start Guides

Receiving a payment

The payment flow for receiving payments follows these steps:

1: Create a new payment (Returns 202 on success)

Bash


2: After receiving 202, fetch the payment details to get the invoice

Bash


Important: The payment creation endpoint returns a 202 status code on success, indicating the request was accepted. You must then fetch the payment details separately to get the invoice and monitor its status.

Example Payment Details Response

JSON


Sending a Payment

The payment flow for sending payments follows these steps:

1: Initiate payment send (returns 202 on success)

Bash


2: After receiving 202, fetch payment status to monitor progress

Bash


Important: Like the receive flow, the send payment endpoint returns a 202 status code on success. You must fetch the payment details separately to monitor its status.

Payment Status Monitoring

When sending or receiving payments, you must actively monitor the payment status by fetching the payment details. The status field will progress through these states:

  1. For sent payments:
    • Initial: sending
    • Final: completed or failed
  2. For received payments:
    • Initial: receiving
    • Final: completed or failed

Best practices for monitoring:

  • Poll the payment status endpoint every few seconds
  • Implement appropriate timeout logic
  • Handle both success and error states
  • Consider implementing webhook notifications for status changes

Example of checking payment status:

JS


Wallet Balance Management

Regularly check wallet balances to ensure sufficient funds:

Curl


Payment History

Track payment history and events:

Curl


Creating A Staging Wallet through the API:

In order to create a Staging Wallet through the API you must have already created your first wallet through the UI. Doing this will autmatically generated you a line of credit ID that you can use to start creating new wallets through the API.

Team Page
After creating your first wallet navigate to the API Keys page

API Keys
Click on your created API key

API Keys
A sidebar will popout and your line of credit ID will be available to copy


Great! You now have the info required to make the request BELOW and create staging wallets through the API.

Curl


Metadata Support

Add custom metadata to wallets for better organization:

Bash


Error Handling

The API uses standard HTTP status codes:

  • 200: Success
  • 201: Resource created
  • 202: Successfully requested a new payment be created
  • 400: Bad request
  • 403: Authentication/authorization error
  • 404: Resource not found
  • 500: Server error

Always check the response status and handle errors appropriately.

Support and Resources

For additional support:



Remember to always use appropriate error handling and logging in your integration to ensure reliable operation of your Lightning Network payments.