Users API

User Operations

The User service (client.user) allows you to access information about the user associated with your API key, including account details, bank accounts, and Shopify sessions.

Get User Information

Retrieve comprehensive information about your user account:

const user = await client.user.get();
console.log(`User ID: ${user.id}`);
console.log(`Balance: ${user.polar_balance_usdc} USDC`);
console.log(`KYC Complete: ${user.kyc_complete}`);

Response Type

interface User {
  id: string;
  sign_in_method: 'EMAIL' | 'SHOPIFY';
  email: string;
  shopify_shop: string | null;
  notification_email: string | null;
  business_name: string | null;
  customer_id: string | null;
  kyc_complete: boolean;
  kyc_link_id: string | null;
  polar_balance_usdc: number;
  shopifyConfigurationId: string | null;
  created_at: string;
  updated_at: string;
}

Response Fields

Field
Type
Description

id

string

Unique user identifier

sign_in_method

string

Authentication method used (EMAIL or SHOPIFY)

email

string

User's email address

shopify_shop

string|null

Shopify shop domain (if applicable)

notification_email

string|null

Email for notifications (if different from main email)

business_name

string|null

Business or company name

customer_id

string|null

Bridge customer ID for KYC/banking

kyc_complete

boolean

Whether KYC verification is completed

kyc_link_id

string|null

Bridge KYC link identifier

polar_balance_usdc

number

Current USDC balance in user's SuiPay account

shopifyConfigurationId

string|null

Associated Shopify configuration ID

created_at

string

Account creation timestamp

updated_at

string

Last account update timestamp

Usage Examples

Security Note: This method returns sensitive information including the user's current USDC balance (polar_balance_usdc) and Bridge customer ID (customer_id). Ensure this data is handled securely and not exposed to unauthorized parties.

Get User Bank Accounts

Retrieve a list of bank accounts associated with your user account:

Response Type

Bank Account Fields

Field
Type
Description

id

string

SuiPay bank account identifier

user_id

string

Associated user identifier

bridge_id

string

Bridge service account identifier

bank_name

string?

Name of the bank (optional)

last_four

string

Last 4 digits of account number

country_code

string

Country code for the account

account_type

string

Type of bank account (e.g., checking, savings)

created_at

string

Account connection timestamp

updated_at

string

Last account update timestamp

Usage Examples

Get User Shopify Sessions

Retrieve a list of Shopify sessions associated with your user account (only applicable for Shopify-integrated users):

Response Type

Shopify Session Fields

Field
Type
Description

id

string

Session identifier

shop

string

Shopify shop domain

state

string

OAuth state parameter

isOnline

boolean

Whether this is an online session

scope

string?

Granted OAuth scopes (optional)

expires

string?

Session expiration time (optional)

accessToken

string

Shopify access token

userId

string?

Shopify user ID (optional)

createdAt

string

Session creation timestamp

updatedAt

string

Last session update timestamp

Usage Examples

Security Warning: This method returns Shopify access tokens (accessToken) which are highly sensitive. These tokens should never be logged, stored insecurely, or transmitted to client applications. Handle with extreme care.

Error Handling

All user methods can throw specific error types:

Common Error Scenarios

Error Type
Description
Common Causes

SuiPayAuthenticationError

Invalid or missing API key

Wrong API key, deactivated key

SuiPayServerError

Server-side error

Temporary service issues

Network errors

Connection issues

Network connectivity problems

Complete User Information Example

Here's a comprehensive example showing how to get and display all user information:

Access Control

Important: API keys are scoped to specific users. When you use an API key:

  1. The API key can only access the user account it was created for

  2. You cannot access other users' data with your API key

  3. All resources (payment links, withdrawals, bank accounts) are tied to your user account

  4. Sensitive data like balances and access tokens are returned - handle with care

This ensures proper isolation and security between different API key holders.

Data Handling Best Practices

Sensitive Information

The user methods return sensitive data that requires careful handling:

Sensitive Fields:

  • polar_balance_usdc: Current balance - don't cache or log

  • customer_id: Bridge customer ID - used for KYC/banking

  • accessToken: Shopify tokens - extremely sensitive

  • kyc_complete: KYC status - may be subject to regulations

Security Recommendations

  1. Never log sensitive fields in application logs

  2. Use HTTPS only for all communications

  3. Implement proper access controls in your application

  4. Don't cache sensitive data like balances or tokens

  5. Regularly rotate API keys and monitor usage

  6. Follow data retention policies for financial information

Last updated