Skip to content
developers
Open TestCollab

Create a defect

POST/defects

Create a new defect

Use resource IDs from your own project. Keep the API token in your server or CI environment.

example.ts
import { createConfiguration, DefectsApi } from '@testcollab/sdk';
const config = createConfiguration(process.env.TESTCOLLAB_TOKEN!);
const api = new DefectsApi(config);
const result = await api.createDefect({
"defectPayload": {
"project": 123,
"title": "Checkout smoke tests",
"executedtestcase": 123
}
});
console.log(result);
Field Type Required Description
id number No —
project number Yes —
title string Yes —
description string No —
executedtestcase integer Yes ID
step_number number No —
configuration string No Stringified JSON object to configuration values as per AvailableIssueManager config fields
issue_manager string No —

200 — Created Defect

Field Type Required Description
id number Yes —
project number Yes —
external_id string Yes —
title string Yes —
user_comment string No —
defect_url string No —
defect_status string No —
testcase Test Case No —
testcase.id number Yes —
testcase.display_number number No Per-company human-readable business number (shown as TC-204). Distinct from the internal id.
testcase.title string Yes —
testcase.suite Suite No —
testcase.suite.id number Yes —
testcase.suite.title string Yes —
testcase.suite.description string No —
testcase.suite.parent_id number No —
testcase.suite.order number No —
testcase.suite.created_by number No —
testcase.suite.is_bdd_managed boolean No True when the suite is managed by BDD sync from a feature file in Git.
testcase.suite.is_reference boolean No Will be true only for links
testcase.suite.source_id number No Only for links - source entity ID
testcase.suite.source_project number No Only for links - source Project ID
testcase.suite.is_main_link boolean No Will be true only for top level link suite
testcase.description string Yes Test case description (generated by rich text editor)
testcase.steps Step Collection No —
testcase.steps[].step string Yes (can contain HTML)
testcase.steps[].expected_result string Yes (can contain HTML)
testcase.steps[].reusable_step_id number Yes Reusable Step ID
testcase.steps_parsed Step Parsed Collection No —
testcase.steps_parsed[].step string Yes (can contain HTML)
testcase.steps_parsed[].step_id number No —
testcase.steps_parsed[].expected_result string Yes (can contain HTML)
testcase.steps_parsed[].step_index number No —
testcase.steps_parsed[].parsed_reusable_step_id number No —
testcase.priority number Yes Priority, 0 - Low, 1- Normal, 2 - High Values: 0, 1, 2.
testcase.tags Tag Collection No —
testcase.tags[].id number Yes —
testcase.tags[].name string Yes —
testcase.tags[].test_case_count number No —
testcase.requirements Requirement Collection No —
testcase.requirements[].id number No —
testcase.requirements[].title string Yes —
testcase.requirements[].requirementManager string No —
testcase.requirements[].requirement_id string Yes —
testcase.requirements[].requirement_key string No —
testcase.requirements[].requirement_url string No —
testcase.requirements[].project number Yes —
testcase.requirements[].status number No —
testcase.requirements[].req_info string No Stringified JSON object
testcase.requirements[].testcase_count number No —
testcase.requirements[].link_sync Requirement Link Sync No Azure DevOps reciprocal-link state for the requested test-case relation.
testcase.requirements[].custom_fields Array of Custom Field Collection Output No Array of custom fields - applicable only for inbuilt
testcase.requirements[].requirement_folder Generic Folder No Requirement folder - applicable only for inbuilt
testcase.requirements[].attachments Upload Collection No Requirement attachments - applicable only for inbuilt
testcase.requirements[].description string No Requirement description - applicable only for inbuilt
testcase.requirements[].created_at string No —
testcase.requirements[].updated_at string No —
testcase.requirements[].created_by User Minified No —
testcase.attachments Upload Collection No —
testcase.attachments[].id number Yes —
testcase.attachments[].name string Yes —
testcase.attachments[].hash string Yes —
testcase.attachments[].ext string Yes —
testcase.attachments[].mime string Yes —
testcase.attachments[].size string Yes —
testcase.attachments[].url string Yes —
testcase.attachments[].created_by number No —
testcase.attachments[].created_at string Yes —
testcase.attachments[].updated_at string Yes —
testcase.custom_fields Array of Custom Field Collection Output No Array of custom fields
testcase.sort_order number No —
testcase.created_at string No —
testcase.updated_at string No —
testcase.created_by User Minified No —
testcase.created_by.id number Yes —
testcase.created_by.username string No —
testcase.created_by.name string Yes —
testcase.created_by.avatar Upload No —
testcase.created_by.is_guest number No —
testcase.last_run_status string No Last run status of the test case
testcase.run_count number No —
testcase.avg_execution_time number No —
testcase.last_run_on string No —
testcase.failure_rate number No Test failure percentage
testcase.archived boolean No True when the test case is archived. An archived case is left out of the default test case lists and cannot be added to a test plan, while its revisions, executions and results are kept. Archive and restore it with the archive and unarchive actions of POST /testcases/bulkAction.
testcase.trash_entry number No ID of the project Trash entry while the test case is in Trash, null otherwise. Ordinary test case reads leave out a case in Trash, so the value is set only where a record keeps its link to the case, for example the testcase of a defect (GET /defects/{id}).
testcase.is_bdd_managed boolean No True when a BDD sync (tc sync) created the test case from a scenario of a .feature file in Git. The repository owns the case, so it cannot be edited, archived, restored or deleted by hand. : when its scenario is removed from the repository, the sync archives the case; when the scenario comes back with the same steps, the sync restores it. So a case with both is_bdd_managed and archived true was removed from the repository.
testcase.is_reference boolean No Will be true only for links
testcase.source_id number No Only for links - source entity ID
testcase.source_project number No Only for links - source Project ID
testcase.under_review number No 1 if test case is under review else 0 (applicable when test case review feature is enabled)
testcase.is_automated number No Can be considered for execution by copilot (applicable when test case automation feature is enabled)
testcase.automation_coverage string No Whether automation covers this case. observed is set by TestCollab when a CI-sourced result matches the case, so coverage reflects what actually ran rather than what someone remembered to tick. declared is set by a person for automation that legitimately never reports in (performance, security, pipelines that are not wired up). Distinct from is_automated, which is a QA Copilot flag. Values: none, observed, declared.
testcase.automation_last_run_at string No When a CI-sourced result last matched this case. Lets coverage age out, so a case stops counting once its automated test stops reporting.
testcase.automation_declared_by User Minified No —
testcase.automation_declared_by.id number Yes —
testcase.automation_declared_by.username string No —
testcase.automation_declared_by.name string Yes —
testcase.automation_declared_by.avatar Upload No —
testcase.automation_declared_by.is_guest number No —
Illustrative response
{
"id": 123,
"project": 123,
"external_id": "example",
"title": "example",
"user_comment": "example",
"defect_url": "example",
"defect_status": "example",
"testcase": {
"id": 123,
"display_number": 123,
"title": "example",
"suite": {
"id": 123,
"title": "example",
"description": "example",
"parent_id": 123,
"order": 123,
"created_by": 123,
"is_bdd_managed": true,
"is_reference": true,
"source_id": 123
},
"description": "example",
"steps": [],
"steps_parsed": [],
"priority": 0,
"tags": []
},
"testplan": {
"id": 123,
"title": "example",
"priority": 0,
"status": 0,
"test_plan_folder": 123,
"start_date": "example",
"end_date": "example",
"created_at": "example",
"custom_fields": []
}
}
Status Meaning
403 Forbidden