Create a user, connect account to a user, get user accounts

User is a main data container in MoneyMade Connect User API.
It stores connected accounts and their balances, bank details information and transactions history.

Navigation

Create a user

Route: POST /api/v2/users

Parameters:

  • client_user_id - it's a unique string which links MoneyMade Connect user to your internal one. We recommend to set your internal user id here.
  • email (optional) - user email.

Response: returns User object

// USING https://www.npmjs.com/package/@moneymade/connect-api

const moneymade = new MoneymadeSDK({
  secret: process.env.MONEYMADE_API_SECRET,
  apiKey: process.env.MONEYMADE_API_KEY,
});

await moneymade.init();

const user = await moneymade.users.create({
  client_user_id: 'you-internal-user-id',
  email: '[email protected]',
});

// Result user object has id (uuid). 
// We recommend to store it in your local db to make manipulation with our API easier.

Connect account to a user

Account connection is handled on frontend side.
To start it you should retrieve session token to authorize the user on the widget.

Token expires in 1 hour. Check response body expires_at field for more info.

Route: POST /v2/users/{userId}/sessions

Parameters:

  • userId - moneymade user id or client user id you set on user creation
// USING https://www.npmjs.com/package/@moneymade/connect-api

const moneymade = new MoneymadeSDK({
  secret: process.env.MONEYMADE_API_SECRET,
  apiKey: process.env.MONEYMADE_API_KEY,
});

await moneymade.init();

const session = await moneymade.createSession('user-id-value');
const token = session.token; // send this token to frontend side

Once you get this token send it to frontend side and initialize Connect Widget .

Get user accounts

Route: GET /v1/users/{userId}

Parameters:

  • userId - moneymade user id or client user id you set on user creation

Response: returns Account object without subaccounts.

// USING https://www.npmjs.com/package/@moneymade/connect-api

const moneymade = new MoneymadeSDK({
  secret: process.env.MONEYMADE_API_SECRET,
  apiKey: process.env.MONEYMADE_API_KEY,
});

await moneymade.init();

// use previously stored MoneyMade user id to get user with connected accounts
const user = await moneymade.users.getOne('moneymade-user-id');

// Also you can use your internal user id 
// if you set it as client_user_id on user creation
// const user = await moneymade.users.getOne('you-internal-user-id');

It returns user accounts with short info. Each account in accounts array has provider info with no subaccounts and balances. Use get user full account info.