Right To Work Checker

← Back to docs

Quickstart — Node.js

Sign up, mint a test key, send your first check in under 5 minutes.

1. Mint a test key

Sign in, open /app/keys, click New key, choose test mode. Copy the rtw_test_… plaintext — it's only shown once.

2. Send a request

Using Node's built-in fetch (Node ≥ 18). No SDK needed.

const RTW_KEY = process.env.RTW_KEY!; // rtw_test_… or rtw_live_…

const res = await fetch('https://api.rtwchecker.dev/api/check', {
  method: 'POST',
  headers: {
    'content-type': 'application/json',
    authorization: `Bearer ${RTW_KEY}`,
  },
  body: JSON.stringify({
    share_code: 'AA1AA1AA1',          // sandbox: ACCEPTED fixture
    date_of_birth: '1990-01-01',
    company_name: 'Acme Ltd',
  }),
});

if (!res.ok) {
  const { error } = await res.json();
  throw new Error(`${error.code}: ${error.message}`);
}

const data = await res.json();
console.log(data.outcome, data.name, data.expiry_date);

3. Sandbox dispatch by share code

With a test key the response is deterministic; pick the share code that matches the path you want to exercise (see /docs for the full table).

// Force a NOT_FOUND error path:
{ share_code: 'CC3CC3CC3', date_of_birth: '1990-01-01', company_name: 'Acme Ltd' }
// Expected response: 404 { error: { code: 'NOT_FOUND', ... } }

4. Swap to a live key

The wire shape is identical. Mint a rtw_live_… key, set RTW_KEY, rerun. Each successful live check counts toward your monthly quota.

5. Next steps