1
Prepare the body and headers
Serialize the JSON body once and retain its exact raw bytes. Generate a fresh nonce for each call and a Unix timestamp in milliseconds.
Requests outside the five-minute timestamp window are rejected. Nonces are retained for ten minutes to prevent replay.
2
Build the canonical string
Calculate the lowercase hexadecimal SHA-256 hash of the raw body, even if you omit the optional An empty query still occupies its blank line. For a documented path such as
X-Content-Hash header.Join the following seven components with a single line feed (\n). Do not add a trailing line feed:/v3/bank_account, use the path without the base URL.Canonical headers: use lowercase names, trim values, and sort names lexically. Always include content-type, x-client-id, x-nonce, and x-timestamp. Include x-content-hash, x-account-number, and x-ispb only when those headers are sent. Do not include X-Signature itself.Canonical query: sort parameter names lexically, preserve the original value order for repeated names, and encode names and values using Go url.QueryEscape semantics.3
Calculate the signature
Calculate HMAC-SHA256 over the canonical string using your API secret. Encode the result as 64 lowercase hexadecimal characters and send it as
X-Signature.Send the exact raw body used to calculate the hash. Changing whitespace, property order, or other body bytes after signing changes the signature input.Example header set for USER account access
Example header set for USER account access
For an account-level operation with a USER credential, add both target headers before calculating the signature. These are illustrative values; generate a current timestamp, fresh nonce, body hash, and signature for your request.For this header set, the canonical names are ordered as
content-type, x-account-number, x-client-id, x-content-hash, x-ispb, x-nonce, and x-timestamp. Omit x-content-hash from the canonical headers only if you omit that request header.Send your first request
Use Get Bank Account to retrieve account information without initiating a payment. It accepts an empty JSON object and requires an ACCOUNT credential or a USER credential with both account-target headers.BASE_URL and CLIENT_ID from your issued configuration, then calculate TIMESTAMP_MS, NONCE, CONTENT_HASH, and SIGNATURE using the signing steps above. The body to hash and send is exactly {}.
Handle the response
Normal API processing returns a JSON envelope. The example below illustrates its structure;data varies by endpoint.
- Check the HTTP response and whether it contains a JSON envelope.
- For an envelope, read the outer
code. On failure,dataisnull. - Choose your error-handling action by code, not by the localized
messagetext. - Handle non-envelope responses separately. Malformed input can return HTTP 400 with plain text; unhandled failures can return plain text, normally with HTTP 500.
error or result fields nested inside data do not override the outer result. Use Error Catalog for the full response contract.
Troubleshoot your first request
Troubleshoot your first request
For every retry, generate a fresh timestamp, nonce, body hash, and signature. Follow the endpoint’s retry and duplicate-handling rules before repeating an operation.
Connect webhooks
Webhooks notify your application about transaction, KYB, and MED events. Pagsmile sends signed HTTP POST requests to your callback URL.1
Choose your events and subscription scope
Use Webhooks to identify the event family and permitted owner scope. For the supported PIX and KYB event values, see Webhook Management. MED uses a separate subscription family; it is not represented by the numeric event values accepted by the management API.
2
Verify each delivery
Retain the raw request body and verify the content hash, signature, timestamp, and nonce before processing the event. Follow Signature Verification.
3
Accept and process events reliably
Store the event with its documented idempotency key, then return HTTP 200 after durable acceptance. Process asynchronously and handle duplicate or out-of-order deliveries. Use a callback URL that returns HTTP 200 directly, without redirects. See Delivery and Retries.
Before handling live operations
- Confirm the assigned environment, credential scope, and target account for each operation.
- Check both successful and failed responses; do not infer success from HTTP status alone.
- Use decimal strings and decimal arithmetic for monetary values. See Object & Enums References.
- Verify webhook signatures and duplicate handling before relying on event notifications.
- Keep API secrets and one-time credential values out of logs.
Choose an API operation
Explore endpoints for accounts, transfers, charges, and refunds.
Handle errors consistently
Map business result codes to the right client behavior.