Your first API request
Go from an API token to a successful request. This example reads your project’s test cases, so you can confirm the connection before creating or changing records.
Before you start
Section titled “Before you start”You need a TestCollab account, access to a project, and Node.js 22 or newer. Find your project ID in the TestCollab project URL. Use the same API region as your account.
1. Install the SDK
Section titled “1. Install the SDK”mkdir testcollab-example && cd testcollab-examplenpm init -ynpm pkg set type=modulenpm install --save-dev tsx typescript2. Create an API token
Section titled “2. Create an API token”In TestCollab, open My Profile Settings → API Token and generate a token. Store it in your environment:
export TESTCOLLAB_TOKEN='your-api-token'Keep the token in your server or CI secret store. Do not put it in browser code or commit it to Git.
3. Read your test cases
Section titled “3. Read your test cases”Save this as quickstart.ts. Replace 123 with your project ID.
import { createConfiguration, TestCasesApi } from '@testcollab/sdk';
const token = process.env.TESTCOLLAB_TOKEN;if (!token) throw new Error('Set TESTCOLLAB_TOKEN before running this example.');
const projectId = 123; // Replace with your project ID.const config = createConfiguration(token);const cases = await new TestCasesApi(config).getTestCases({ project: projectId, limit: 10, start: 0,});
for (const testCase of cases) { console.log(testCase.id, testCase.title);}For an EU account, pass basePath: 'https://api-eu.testcollab.io' to createConfiguration. See choose your region.
4. Run it
Section titled “4. Run it”npx tsx quickstart.tsThe output lists case IDs and titles. An empty list can be a successful request if the project has no test cases yet.
Where to go next
Section titled “Where to go next”- Create a test case with steps and expected results.
- Create and assign a test plan.
- Explore the API reference for individual operations.
If the request fails, check authentication, your region, and troubleshooting.