Skip to content
developers
Open TestCollab

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.

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.

Terminal
mkdir testcollab-example && cd testcollab-example
npm init -y
npm pkg set type=module
npm install @testcollab/[email protected]
npm install --save-dev tsx typescript

In TestCollab, open My Profile Settings → API Token and generate a token. Store it in your environment:

Terminal window
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.

Save this as quickstart.ts. Replace 123 with your project ID.

quickstart.ts
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.

Terminal window
npx tsx quickstart.ts

The output lists case IDs and titles. An empty list can be a successful request if the project has no test cases yet.

If the request fails, check authentication, your region, and troubleshooting.