Skip to main content

SpacePay API Reference

Welcome to the SpacePay API documentation. This reference provides comprehensive information about our REST API endpoints, authentication methods, and integration examples.

Getting Started

1

Get Your API Keys

Generate your API keys in the admin dashboard under Settings → Developers → API Keys.
API Keys: Available in both testnet and mainnet environments. Test keys start with pk_test_ and sk_test_.
2

Choose Your Environment

Select the appropriate base URL for your integration: - Testnet: https://api-testnet.spacepay.co.uk (for development) - Mainnet: https://api.spacepay.co.uk (for production)
3

Start Integrating

Use our SDK or integrate directly with our REST API endpoints.

Authentication

All API requests require authentication using your secret key with the X-SpacePay-Secret-Key header:
const headers = {
  "X-SpacePay-Secret-Key": "sk_test_your_secret_key",
  "Content-Type": "application/json",
  "Idempotency-Key": "unique-key-for-request", // Optional but recommended
};
Never expose your API keys in client-side code or public repositories. Use environment variables and server-side implementations only.

Learn More

Detailed authentication examples and API integration guide

Base URLs

SpacePay provides different base URLs for different environments:

Testnet Environment

Base URL: https://api-testnet.spacepay.co.ukNetworks: Base Sepolia, Ethereum SepoliaUse for: Development and testing

Mainnet Environment

Base URL: https://api.spacepay.co.ukNetworks: Base, Ethereum, Polygon, BSC, AvalancheUse for: Production with real tokens

Learn More

Detailed test environments, scenarios, and token addresses

Payment Statuses

SpacePay payments progress through the following statuses:

PENDING

Payment has been created and is waiting for customer payment.

PROCESSING

Payment is being processed and waiting for blockchain confirmations.

COMPLETED

Payment has been confirmed and is complete.

FAILED

Payment failed due to network issues or insufficient funds.

EXPIRED

Payment expired before completion.

CANCELLED

Payment was cancelled by the merchant.

Learn More

Detailed payment processing flow and status explanations

Webhook Events

SpacePay sends webhooks for the following events:
  • payment.created: Payment has been created and is ready for customer payment
  • payment.updated: Payment status has been updated (confirmed, failed, expired, etc.)
Webhook Secret: Each webhook endpoint gets its own unique secret key for signature verification. Set up webhooks in your admin dashboard under Settings → Developers → Webhooks.

Learn More

Complete webhook setup, payload structure, and signature verification

Error Handling

SpacePay uses standard HTTP status codes and provides detailed error information:
try {
  const response = await fetch(url, options);

  if (!response.ok) {
    const error = await response.json();
    console.error("API Error:", error.message);
    console.error("Error Code:", error.code);
  }
} catch (error) {
  console.error("Network Error:", error.message);
}

Learn More

Detailed error handling examples and troubleshooting guide

Integration Resources

Support

Need help with the API?