POST /v1/widget-sessions
Create a session for users to complete their cryptocurrency purchase through our widget.Request Headers
X-Request-Signature Header: This header is required for all widget session creation requests. See the X-Request-Signature Authentication section below for detailed signature generation instructions.
Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fiatAmount | number | Yes* | Amount in fiat currency |
cryptoAmount | number | Yes* | Amount in cryptocurrency |
fiatCurrency | string | Yes | Fiat currency code (USD, EUR) |
cryptoCurrency | string | Yes | Cryptocurrency symbol |
network | string | Yes | Blockchain network name |
destinationAddress | string | Yes | Wallet address to receive crypto |
email | string | No | User’s email address |
paymentMethod | string | No | Payment method |
unlockedFields | array | No | Fields that will be available to be changed in the widget (see available fields below) |
metadata | object | No | Additional information for the transaction that you would like to receive in webhook (see metadata below) |
successUrl | string | No | URL to redirect on successful payment |
failureUrl | string | No | URL to redirect on failed payment |
ipAddress | string | No | IP address of the user |
Conversion Type
- use
fiatAmountto create a widget based on amount you want to spend on crypto tokens - use
cryptoAmountto create a widget based on crypto tokens you want to buy.
Payment Methods
There are several payment methods available for various countries and currencies.
Verify available methods using the fiat currencies endpoint
| Payment method | Testnet | Production |
|---|---|---|
card | Yes | Yes |
bank_transfer | Yes | Yes |
apple_pay | No | Yes |
google_pay | No | Yes |
astropay | No | Yes |
blik | No | Yes |
ideal | No | Yes |
IP Address
Value: Can be in IPv4 dotted decimal (
192.0.2.1), IPv6 (2001:db8::68), or IPv4-mapped IPv6 (::ffff:192.0.2.1) form.Purpose: Include the end user’s public IP address with requests to strengthen fraud prevention, identity verification, and session integrity checks.Behavior: Providing the correct End-User IP is essential for a seamless checkout experience. If this field is missing or cannot be verified, additional checks or restrictions may apply. This can lead to extra verification steps, reduced limits, or delayed processing.Metadata
Collection of property/value pairs.Properties: Additional information for the transaction that you would like to receive in webhookReserved properties (prefixed with
_):_externalPartnerId(string): Identifier for external partner attribution
X-Request-Signature Authentication
All widget creation requests require HMAC-SHA256 signature validation for enhanced security. You must include theX-Request-Signature header with every request to the widget sessions endpoint.
How to generate the signature:
- Serialize your request payload to JSON
- Convert to UTF-8 bytes
- Compute HMAC-SHA256 using your partner’s signature secret
- Encode the result as a hexadecimal string
- Include in the
X-Request-Signatureheader
Available Unlocked Fields
The
Fields not included in
unlockedFields parameter controls which passed params are available for change in the widget.
Only the following fields can be included in this array:| Field Name | Description |
|---|---|
fiatAmount | Amount in source currency |
cryptoAmount | Amount in target cryptocurrency |
fiatCurrency | Source fiat currency |
email | User’s email address |
network | Blockchain network name |
paymentMethod | Payment method type |
successUrl | Success redirect URL |
failureUrl | Failure redirect URL |
unlockedFields will be encrypted and hidden from view in the widget.This feature is not available for the general audience at the moment. Using this parameter will not change the widget behavior.Response
Response Fields
| Field | Type | Description |
|---|---|---|
sessionId | string | Unique session identifier, used as a transaction id later on |
widgetUrl | string | URL to redirect users to |
expiresAt | string | Session expiration timestamp (UTC timezone) |
Sessions expire after 30 minutes. Make sure to redirect users promptly after creating a session.
Integration Examples
requestExample.js
Widget Integration Options
1. Full Page Redirect
Redirect users to the widget URL in the current window:2. New Window/Tab
Open the widget in a new window or tab:Handling Redirects
After users complete or cancel their transaction, they’ll be redirected based on your configuration:Success Redirect
Users are redirected tosuccessUrl with query parameters:
Failure Redirect
Users are redirected tofailureUrl if the payment fails or is cancelled:
Using Metadata
Themetadata field allows you to store additional information with the session:
- Included in webhook notifications
- Useful for reconciliation and tracking
Error Responses
Unsupported Network
Signature Validation Errors
The following error may occur if signature validation fails:Unauthorized Request
Possible Signature Issues
Issue 1: “Unauthorized request” after deployment
Cause: Signature secret not configured in production Solution:- Verify
SIGNATURE_SECRETenvironment variable is set - Check that it matches the value received from Kryptonim
- Restart your application after setting the variable
Issue 2: Signature validation fails intermittently
Cause: JSON formatting differences between signature generation and request Solution:- Ensure you’re using the same JSON serialization for both signature and request
- Use consistent separators (e.g.,
separators=(',', ':')in Python) - Avoid extra whitespace or formatting differences
Issue 3: Works in development, fails in production
Cause: Different signature secret in production environment Solution:- Verify production environment variables are correctly set
- Check that you’re not using development credentials in production
- Ensure secrets are properly loaded in production environment
Security Best Practices
- Minimize unlocked fields: Only include essential fields in
unlockedFieldsto maintain security - Validate wallet addresses before creating sessions
- Store the sessionId for tracking and reconciliation
- Set up webhooks to receive real-time updates
- Handle expired sessions gracefully
- Test the full flow in development before going live
- Use HTTPS for all redirect URLs to ensure secure communication
- Always include signature: The
X-Request-Signatureheader is required for all widget session creation requests - Protect signature secrets: Never expose your signature secret in client-side code or public repositories
- Validate signatures: Always verify signature generation matches the expected format