Skip to content

Users

Manage Rain cardholders -- create, update, delete users and query their balances.

List Users

typescript
const { data: users } = await rain.users.getUsers();

Returns an array of RainUser objects.

Get a User

typescript
const { data: user } = await rain.users.getUser("user-id");

console.log(user.firstName); // "Jane"
console.log(user.role); // "cardholder"
console.log(user.status); // "active"

Create a User

typescript
const { data: user } = await rain.users.createUser({
  firstName: "Jane",
  lastName: "Smith",
  email: "jane@example.com",
  role: "cardholder"
});
FieldTypeRequiredDescription
firstNamestringYesUser's first name
lastNamestringYesUser's last name
emailstringYesUser's email address
rolestringYes"owner", "admin", or "cardholder"
companyIdstringNoAssociate user with a company

Update a User

typescript
await rain.users.updateUser("user-id", {
  firstName: "Janet",
  phoneCountryCode: "1",
  phoneNumber: "5555551234",
  walletAddress: "0x..."
});

Updatable fields include firstName, lastName, email, role, isActive, isTermsOfServiceAccepted, address, phoneCountryCode, phoneNumber, walletAddress, solanaAddress, tronAddress, and stellarAddress.

Delete a User

typescript
await rain.users.deleteUser("user-id");

Get User Balance

typescript
const { data: balance } = await rain.users.getUserBalance("user-id");

console.log(`Credit limit: $${balance.creditLimit / 100}`);
console.log(`Spending power: $${balance.spendingPower / 100}`);
console.log(`Balance due: $${balance.balanceDue / 100}`);

See the Payment System page for full details on the credit balance model.

Create User in Company (Corporate Flow)

After a corporate application is approved, add employees to the company. The initialUser from the application is created automatically -- this endpoint is for additional users.

typescript
const { data: user } = await rain.users.createUserInCompany("company-id", {
  firstName: "Jane",
  lastName: "Smith",
  email: "jane@company.com",
  isTermsOfServiceAccepted: true,
  birthDate: "1990-05-15",
  walletAddress: "0x...",
  phoneCountryCode: "1",
  phoneNumber: "5555551234"
});

// Then issue a card for the new user
const { data: card } = await rain.cards.createCard({
  userId: user.id,
  type: "virtual",
  limit: { amount: 50000, frequency: "per30DayPeriod" }
});
FieldTypeRequiredDescription
firstNamestringYesMax 50 characters
lastNamestringYesMax 50 characters
emailstringYesEmployee email
isTermsOfServiceAcceptedbooleanYesMust be true
birthDatestringNoYYYY-MM-DD format
walletAddressstringNoEVM wallet address
solanaAddressstringNoSolana wallet address
addressRainAddressNoPhysical address
phoneCountryCodestringNoe.g. "1" for US
phoneNumberstringNoWithout country code

Charge a User

Apply custom fees to a user's account. Charges are per-user, not per-card and reduce the user's spending power.

typescript
await rain.users.chargeUser("user-id", {
  amount: 500, // $5.00 in cents
  description: "Express shipping fee"
});

WARNING

Custom charges are post-authorization and may cause a user's balance to go negative. The Rain charge API does not accept an idempotency key -- implement your own deduplication logic.

User Roles

RoleDescription
ownerFull control including admin management
adminCreate cards, manage members, set limits
cardholderUse assigned cards, view own expenses

User Statuses

StatusDescription
activeFully functional user
inactiveDisabled user
pendingAwaiting activation or approval
Users has loaded