Docs/API Reference

API Reference

Complete reference for the Hedge Payments REST API

Base URLs

EnvironmentBase URLDescription
Sandboxhttps://api-sandbox.hedgepayments.comTesting and development
Productionhttps://api.hedgepayments.comLive transactions

Important: Always use the sandbox environment for testing. Sandbox and production API keys are not interchangeable.

Authentication

Hedge Payments uses two authentication methods depending on the context:

API Key (Server-side)

Use your API secret key in the Authorization header for all server-side requests:

Authorization: Bearer sk_live_your_api_secret_key

JWT (Client-side)

For client-side SDK operations, use a short-lived JWT obtained from your server. JWTs are scoped to a specific customer and expire after 15 minutes.

// Server-side: generate a client token
const token = await hedge.clientTokens.create({
  customerId: 'cust_abc123',
  scopes: ['checkout', 'payment_methods']
})

// Client-side: pass the token to the SDK
<HedgeProvider clientToken={token.jwt}>
  <CheckoutForm />
</HedgeProvider>

Never expose your API secret key in client-side code. Use publishable keys or JWTs for browser and mobile applications.

Request / Response Format

  • All request bodies must be JSON with Content-Type: application/json
  • All responses are JSON encoded in UTF-8
  • Monetary amounts are in cents (e.g., 9999 = $99.99)
  • Timestamps are ISO 8601 format in UTC
  • IDs use prefixed strings (e.g., pay_, cust_, evt_)
// Example request
curl -X POST https://api.hedgepayments.com/v1/payments \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 9999,
    "currency": "USD",
    "customer_email": "customer@example.com"
  }'

// Example response
{
  "id": "pay_abc123",
  "amount": 9999,
  "currency": "USD",
  "status": "pending",
  "created_at": "2024-06-15T10:30:00Z"
}

Rate Limits

API requests are limited to 100 requests per minute per API key. Rate limit headers are included in every response:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1718450460

If you exceed the limit, you will receive a 429 Too Many Requests response. Wait until the X-RateLimit-Reset timestamp before retrying.

Versioning

The current API version is v1. The version is included in the URL path:

https://api.hedgepayments.com/v1/payments

Breaking changes will be introduced in new versions. Non-breaking additions (new fields, new endpoints) may be added to the current version without notice.

Endpoints

Auth

MethodPathDescription
POST/v1/auth/client-tokenGenerate a client-side JWT
GET/v1/auth/api-keysList API keys for your account

Payments

MethodPathDescription
POST/v1/paymentsCreate a new payment
GET/v1/payments/:idRetrieve a payment
GET/v1/paymentsList all payments
POST/v1/payments/:id/cancelCancel a pending payment
POST/v1/payments/:id/refundRefund a payment (full or partial)

Checkout

MethodPathDescription
POST/v1/checkout/sessionsCreate a checkout session
GET/v1/checkout/sessions/:idRetrieve a checkout session
POST/v1/checkout/sessions/:id/expireExpire a checkout session

Merchants

MethodPathDescription
POST/v1/merchantsCreate a merchant account
GET/v1/merchants/:idRetrieve a merchant
PATCH/v1/merchants/:idUpdate merchant settings
GET/v1/merchants/:id/balanceGet merchant balance

Round-Ups

MethodPathDescription
POST/v1/roundups/configureConfigure round-up settings
GET/v1/roundupsList round-up transactions
GET/v1/roundups/summaryGet round-up summary and totals

Webhooks

MethodPathDescription
POST/v1/webhooks/endpointsRegister a webhook endpoint
GET/v1/webhooks/endpointsList webhook endpoints
DELETE/v1/webhooks/endpoints/:idDelete a webhook endpoint
POST/v1/webhooks/testSend a test webhook event