Skip to main content
Use the TypeScript SDK from trusted server-side code. Do not ship secret API keys to the browser.

Which SDK should I use?

Use the TypeScript SDK in trusted server-side code to create payments, retrieve transactions, issue refunds, and create transfers. Use the browser SDK v3 through Payment Element when you need hosted card fields in a checkout page.

Requirements

  • TypeScript or JavaScript running on your backend.
  • A Pagou secret key for the environment you are calling.
  • A runtime with fetch. If your runtime does not expose global fetch, inject a custom implementation in the client options.

Install

Create a client

Environments: You can also pass baseUrl for development tests or controlled proxies.

Response shape

SDK methods return { data, meta }. data is the API payload. meta contains HTTP metadata and the request ID used for tracing.

First Pix payment

Request options

Every resource method accepts an optional second argument:

Auth variants

Bearer auth is the default and recommended setup.
Use the other schemes only for legacy integrations or compatibility layers:

Retry behavior

  • Retries cover network failures and 429, 500, 502, 503, 504.
  • GET and HEAD retry automatically.
  • POST and PUT retry only when you set idempotencyKey.
  • Default retry count is 2.
  • Default timeout is 30_000 ms.
Set idempotency keys on any payment, refund, transfer, or cancel request that may be retried:

Error handling

Exported SDK errors include AuthenticationError, PermissionError, RateLimitError, InvalidRequestError, NotFoundError, ConflictError, ServerError, and NetworkError.