Guides

Build a Token Grant Dashboard

End-to-end guide: integrate with Toku to build your own token grant management dashboard

Overview#

This guide walks you through building a complete token grant management integration with the Toku API. By the end, you'll have everything needed to:

  • Onboard recipients and assign roles
  • Create and manage token grants with vesting schedules
  • Set up and verify recipient wallets
  • Configure token distributions
  • Handle terminations and reversals
  • Monitor vesting progress

Prerequisites#

  • A Toku organization with CLIENT_ORG_ADMIN access
  • A personal API token
  • Your organization's orgID (found in Settings → Organization ID)

Base Setup#

Every request needs these headers:

const TOKU_BASE_URL = 'https://app.toku.com/api/tokuApi/v1';
const API_TOKEN = 'your-api-token-here';

const headers = {
  'Authorization': `Bearer ${API_TOKEN}`,
  'x-role-type': 'CLIENT_ORG_ADMIN',
  'Content-Type': 'application/json'
};

async function tokuAPI(method: string, endpoint: string, body?: any) {
  const res = await fetch(`${TOKU_BASE_URL}/${endpoint}`, {
    method,
    headers,
    body: body ? JSON.stringify(body) : undefined
  });
  const json = await res.json();
  if (!res.ok || json.error) {
    // Operation errors: { "error": { "message": "..." } }
    // Token, routing and rate-limit errors: { "error": "..." }
    const message = typeof json.error === 'string' ? json.error : json.error?.message;
    throw new Error(`${res.status}: ${message}`);
  }
  // Success: { "data": <result>, "error": null }
  return json.data;
}

Every successful response is wrapped as { "data": ..., "error": null }. The helper returns data, so the examples below work with the result directly.


Step 1: Verify Your Connection#

const hello = await tokuAPI('GET', 'hello');
console.log(hello.message); // "Hello World"
curl https://app.toku.com/api/tokuApi/v1/hello \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "x-role-type: CLIENT_ORG_ADMIN"

Step 2: Get Your Organization Info#

const orgInfo = await tokuAPI('GET', 'getOrgWalletInfo');
console.log(orgInfo);
// {
//   isMfaEnabled: true,
//   orgID: "aa0e8400-...",
//   orgName: "Acme Corp",
//   isSCPMultiWalletSupportEnabled: false,
//   automatedTestTransactionsEnabled: true,
//   isTestTxAmountVerificationEnabled: false,
//   tokenId: "0x1234...your-token-contract"
// }

Step 3: Configure Networks & Tokens#

Check what networks and tokens are available:

// Get configured networks (only those with an enabled token)
const { networks } = await tokuAPI('GET', 'getNetworksNew');
// [{ networkID: "...", name: "Ethereum", tokenTypes: [{ tokenTypeID, name, currencyCode, isTokenEnabled }] }]

// Get enabled token types
const { tokenTypes } = await tokuAPI('GET', 'getTokenTypesNew');
// [{ tokenTypeID: "...", name: "USDC", currencyCode: "USDC", Network: {...} }]

In a token grant organization, Toku sets up networks, tokens and your token contract address. updateOrgTokenAddress returns 403 there, so ask your Toku team to change them.


Step 4: Add Recipients#

Create users who will receive grants:

// Add a single recipient
const recipient = await tokuAPI('POST', 'createUserRoleInOrg', {
  email: 'jane.smith@company.com',
  givenName: 'Jane',
  familyName: 'Smith',
  externalEmployeeID: 'EMP-001',  // Your HRIS ID
  country: 'US',
  employmentType: 'FULL_TIME'
});

console.log(recipient.roleInOrgID);
// "660e8400-..." — save this, you'll need it for grants and wallets

The new seat has the USER role. If the email already has a seat in your organization, the call returns 409.

curl -X POST https://app.toku.com/api/tokuApi/v1/createUserRoleInOrg \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "x-role-type: CLIENT_ORG_ADMIN" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "jane.smith@company.com",
    "givenName": "Jane",
    "familyName": "Smith",
    "externalEmployeeID": "EMP-001",
    "country": "US"
  }'

For bulk onboarding, use batch updates. Each row is matched to an existing seat by tgaRoleInOrgID, loginEmail or externalEmployeeID; a row that matches no seat creates a new USER seat.

const result = await tokuAPI('PUT', 'batchUpdateRoleInOrg', {
  updates: [
    { employeeID: 'EMP-001', externalEmployeeID: 'EMP-001', loginEmail: 'jane.smith@company.com', givenName: 'Jane', familyName: 'Smith' },
    { employeeID: 'EMP-002', externalEmployeeID: 'EMP-002', loginEmail: 'bob.jones@company.com', givenName: 'Bob', familyName: 'Jones' }
  ]
});
// { updated: 2, failed: 0, results: [{ employeeID: "EMP-001", success: true, roleInOrgID: "..." }, ...] }

Step 5: Get Grant Configurations#

Before creating grants, you need a grant configuration (template):

const configs = await tokuAPI('GET', 'listGrantConfigurations');
// [{ grantConfigurationID: "...", name: "Standard RTU", kind: "RTU", isExercisable: false, ... }]

const configID = configs[0].grantConfigurationID;

Grant configurations define the grant type (kind, such as RTU, RTA, TPA or TOKEN_BONUS) and signing requirements. Create them in the TGA dashboard first.


Step 6: Create Grants#

Single Grant#

const grant = await tokuAPI('POST', 'addSingleGrant', {
  grantName: 'Q1 2026 Token Grant - Jane Smith',
  grantDescription: 'Q1 2026 token grant',
  grantConfigurationID: configID,
  grantAmount: 50000,
  recipientID: recipient.roleInOrgID,
  grantDate: '2026-01-01T00:00:00.000Z',
  vestingStartDate: '2026-01-01T00:00:00.000Z',
  vestingFrequencyType: 'MONTHLY',
  vestingPeriods: 48,
  vestingCliffPeriods: 12,
  vestingCliffPercentage: 25,
  lockup: 0,
  tags: ['engineering', '2026']
});

console.log(grant.grantID);

All the fields above are required (tags can be an empty array), and unknown fields are rejected. The grant starts as ACCEPTED.

New Hire Grant (creates user + grant in one call)#

const newHireGrant = await tokuAPI('POST', 'createGrantForNewHire', {
  email: 'new.hire@company.com',
  givenName: 'New',
  familyName: 'Hire',
  employmentType: 'EMPLOYEE',  // CONTRACTOR, EMPLOYEE, ADVISOR, SERVICE_PROVIDER or OTHER
  grantName: 'New Hire Grant',
  grantDescription: 'Signing bonus',
  grantConfigurationID: configID,
  grantAmount: 10000,
  vestingStartDate: '2026-04-01T00:00:00.000Z',
  vestingFrequencyType: 'MONTHLY',
  vestingPeriods: 48,
  vestingCliffPeriods: 12,
  vestingCliffPercentage: 25,
  lockup: 0,
  offPlatformDate: '2030-04-01T00:00:00.000Z',
  tags: ['new-hire']
});
// { grantID: "..." }

The grant date is set to today.


Step 7: Monitor Grants#

List all grants#

const grants = await tokuAPI('GET', 'listGrants');

// Filter by status
const activeGrants = grants.filter(g => g.grantStatus === 'ACCEPTED');
const terminatedGrants = grants.filter(g => g.grantStatus === 'TERMINATED');

// Filter by employee
const janeGrants = grants.filter(g => g.externalEmployeeID === 'EMP-001');

Get grants for a specific employee#

const employeeGrants = await tokuAPI('GET',
  'getEmployeeGrants?externalEmployeeID=EMP-001'
);
// or ?payrollEmployeeID=... (wins if you send both)

List endpoints return all results (no pagination). For large organizations, cache results locally and poll periodically rather than calling on every page load.


Step 8: Set Up Wallets#

Add wallets for recipients#

As an admin, add wallets for recipients with a bulk upload:

await tokuAPI('POST', 'bulkUploadMultipleWallets', {
  wallets: [
    {
      recipientID: recipient.roleInOrgID,
      walletAddress: '0x1234567890abcdef1234567890abcdef12345678',
      networkName: 'Ethereum',
      walletType: 'Hot Wallet'
    }
  ]
});
// { success: true, createdWallets: 1 }

networkName and walletType must match a network and wallet type set up in your organization. A recipient can also add their own wallet with addWallet, using a token that acts as their own seat (x-role-type: USER).

Verify the wallet (test transaction flow)#

// 1. Find the new wallet and send it a test transaction
//    (needs automated test transactions turned on for your organization)
const pending = await tokuAPI('GET', `getPendingWallets?roleInOrgID=${recipient.roleInOrgID}`);
await tokuAPI('POST', 'sendTestTransaction', {
  walletID: pending[0].walletID
});

// 2. After the recipient confirms receipt, approve the wallet
const awaiting = await tokuAPI('GET', 'getPendingWalletTestRequests');
for (const req of awaiting) {
  await tokuAPI('POST', 'approveWalletRequest', {
    walletRequestID: req.walletVerificationRequestID
  });
}

See Wallet Verification Flow for the complete state machine.


Step 9: Configure Distributions#

Set how tokens are distributed across a recipient's wallets:

await tokuAPI('POST', 'configureWalletRefsDistributionForGrant', {
  grantID: grant.grantID,
  roleInOrgID: recipient.roleInOrgID,
  walletRefsconfig: [
    { walletReferenceID: 'ref-uuid', distRatio: 1.0 }
  ]
});

distRatio is a fraction from 0 to 1 for each of the recipient's wallet references on that grant.

setTokenWalletRefsDistribution is a different setting: it splits a person's pay in stablecoin across their wallets, for stablecoin payroll. It does not change how grants are distributed.


Step 10: Handle Terminations#

Terminate a single grant#

await tokuAPI('POST', 'terminateGrant', {
  grantID: 'grant-uuid',
  terminationDate: '2026-06-30T00:00:00.000Z'
});
// { grantID: "grant-uuid" }; status → TERMINATED

Terminate all grants for a departing employee#

const result = await tokuAPI('POST', 'terminateEmployeeGrants', {
  externalEmployeeID: 'EMP-001',
  terminationDate: '2026-06-30T00:00:00.000Z'
});
// { terminatedGrantIDs: [...], alreadyTerminatedGrantIDs: [...] }

Revert a termination (mistake recovery)#

await tokuAPI('POST', 'revertEmployeeGrants', {
  externalEmployeeID: 'EMP-001',
  grantIDs: ['grant-uuid-1', 'grant-uuid-2']
});
// { revertedGrantIDs: [...], alreadyActiveGrantIDs: [...] }

Step 11: Polling for Status Changes#

The API has no webhooks, so poll for changes:

// Poll grants every 5 minutes
async function pollGrants() {
  const grants = await tokuAPI('GET', 'listGrants');

  for (const grant of grants) {
    // Check for newly vested tokens
    if (grant.percentageOfUnitsVested > lastKnownPercentage[grant.grantID]) {
      console.log(`Grant ${grant.grantName}: ${grant.percentageOfUnitsVested}% vested`);
    }

    // Check for status changes
    if (grant.grantStatus !== lastKnownStatus[grant.grantID]) {
      console.log(`Grant ${grant.grantName}: status changed to ${grant.grantStatus}`);
    }
  }
}

setInterval(pollGrants, 5 * 60 * 1000);

Complete Example: Onboard & Grant#

async function onboardAndGrant(employee: {
  email: string;
  firstName: string;
  lastName: string;
  externalID: string;
  tokenAmount: number;
}) {
  // 1. Create the recipient
  const recipient = await tokuAPI('POST', 'createUserRoleInOrg', {
    email: employee.email,
    givenName: employee.firstName,
    familyName: employee.lastName,
    externalEmployeeID: employee.externalID,
    country: 'US'
  });

  // 2. Get grant config
  const configs = await tokuAPI('GET', 'listGrantConfigurations');
  const config = configs[0];

  // 3. Create the grant
  const today = new Date().toISOString();
  const grant = await tokuAPI('POST', 'addSingleGrant', {
    grantName: `${employee.firstName} ${employee.lastName} - Token Grant`,
    grantDescription: 'New hire token grant',
    grantConfigurationID: config.grantConfigurationID,
    grantAmount: employee.tokenAmount,
    recipientID: recipient.roleInOrgID,
    grantDate: today,
    vestingStartDate: today,
    vestingFrequencyType: 'MONTHLY',
    vestingPeriods: 48,
    vestingCliffPeriods: 12,
    vestingCliffPercentage: 25,
    lockup: 0,
    tags: []
  });

  return { recipientID: recipient.roleInOrgID, grantID: grant.grantID };
}

Next Steps#

Was this page helpful? Suggest edits