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.| Need | Use |
|---|---|
| Create Pix, voucher, card, refund, and transfer requests from your backend | TypeScript SDK |
| Mount hosted card fields and tokenize card details in the browser | SDK v3 Reference |
| Continue a 3D Secure browser challenge | SDK v3 Reference |
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 globalfetch, inject a custom implementation in the client options.
Install
Create a client
| Environment | Base URL |
|---|---|
production | https://api.pagou.ai |
sandbox | https://api.sandbox.pagou.ai |
baseUrl for internal 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:| Option | Use |
|---|---|
idempotencyKey | Required for safe retries on POST and PUT requests. |
requestId | Sends X-Request-Id for tracing. |
timeoutMs | Overrides the client timeout for one request. |
signal | Cancels the request with an AbortSignal. |
Auth variants
Bearer auth is the default and recommended setup.Retry behavior
- Retries cover network failures and
429,500,502,503,504. GETandHEADretry automatically.POSTandPUTretry only when you setidempotencyKey.- Default retry count is
2. - Default timeout is
30_000ms.
Error handling
AuthenticationError, PermissionError, RateLimitError, InvalidRequestError, NotFoundError, ConflictError, ServerError, and NetworkError.

