@cosmosapp/pay_sdkServer

Configuration reference

The full option reference and the advanced overrides for self-hosting the gateway.

Most integrations need none of this. It documents every option and the advanced overrides for self-hosting or local development.

new Client({
  apiKey: 'prod_xxx',            // required — the only thing you normally set
  webhookSecret: 'whsec_...',    // default secret for the webhook listener
  timeout: 30_000,               // ms (default 30000)
  retries: 2,                    // network errors / 429 / 5xx (default 2)
  headers: { 'X-Trace': 'abc' }, // extra headers on every request
  fetch: customFetch,            // custom fetch implementation

  // Advanced / internal — pre-filled from Client.shared, rarely overridden:
  baseURL: 'https://api.cosmospay.lat/cosmos-api', // gateway URL (default)
  version: 'v1',                 // route prefix
});

Environment variables (convention)

The SDK reads nothing from the environment itself — you pass values in. Common convention used across the docs/examples:

VarUsed for
COSMOS_PAY_API_KEYnew Client({ apiKey })
COSMOS_WEBHOOK_SECRETnew Client({ webhookSecret }) / handler { secret }

References

  • Client: The main entry point of the SDK — a single, atomic client that exposes every resource through its own manager — an atomic, single-client design.

On this page