{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":467,"path":"api-reference/rest-apis/atf-code-coverage-api.md","title":"ATF Code Coverage API","bundle":null,"doc_type":null,"release":"australia","body":"\n# ATF Code Coverage API\n\nThe ATF Code Coverage API provides endpoints to compute code coverage from Automated Test Framework \\(ATF\\) runs. Coverage can be retrieved by filtered line numbers, for specific script IDs, or for all scripts covered by a set of test suite/test runs.\n\nATF code coverage is a tool that enables you to determine what percentage of code in a deployment request is covered by ATF test suites.\n\nBy default, if ATF test suites cover less than 70% of the code in a deployment request, ReleaseOps transitions the deployment request to the Reconciling state and a test failure task is automatically created. You can adjust the ATF code coverage threshold in the deployment request assessment playbook. For more information, see [Set Automated Test Framework \\(ATF\\) code coverage](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/application-development/set-atf-code-coverage-threshold.md).\n\nFor information on ATF and Performance Analyzer, see [Testing and debugging applications](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/application-development/testing-and-debugging-applications.md).\n\nFor information on deployment analyzer, see [Deployment analyzer in ReleaseOps](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/application-development/deployment-analyzer.md).\n\n**Parent Topic:**[REST API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/api-rest.md)\n\n## ATF Code Coverage - POST /now/atf/code\\_coverage/all\n\nAggregates coverage across all scripts covered by the provided ATF runs. Supports combining test suite runs and individual test runs.\n\n### URL format\n\nVersioned URL: `/api/now/v1/atf/code_coverage/all`\n\nDefault URL: `/api/now/atf/code_coverage/all`\n\n### Supported request parameters\n\n<table class=\"rest_api_path_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_request_body\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntest\\_suite\\_result\\_ids\n\n</td><td>\n\nRequired unless `test_result_ids` are provided. List of test suite result sys\\_ids. Both `test_result_ids` and `test_suite_result_ids` can be included in the same request.Table: Test Suite Results \\[sys\\_atf\\_test\\_suite\\_result\\]\n\nData type: Array of strings\n\n</td></tr><tr><td>\n\ntest\\_result\\_ids\n\n</td><td>\n\nRequired unless `test_suite_result_ids` are provided. List of test result sys\\_ids to include. Both `test_result_ids` and `test_suite_result_ids` can be included in the same request.Table: Test Results \\[sys\\_atf\\_test\\_result\\]\n\nData type: Array of strings\n\n</td></tr><tr><td>\n\nverbose\n\n</td><td>\n\nFlag that indicates level of detail to provide in the response for each custom test script.Valid values:\n\n-   true: Include detailed per-item coverage in the response body **details** object.\n-   false: The response body **details** object will return empty or not at all.\n\nDefault: false\n\nData type: Boolean\n\n</td></tr><tr><td>\n\nsys\\_scopes\n\n</td><td>\n\nFilter results to specified application scopes. For example, `[\"x_my_app\", \"global\"]`. Multiple scopes use OR logic, so any matching scope is included. No filtering occurs if any empty or NULL array is provided.Data type: Array of strings\n\n</td></tr></tbody>\n</table>### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON\\)\n\n<table id=\"table_10z_n1c_i8e\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nlink\n\n</td><td>\n\nLink to the request record.Data type: String\n\n</td></tr><tr><td>\n\ndetails.&lt;scriptId&gt;\n\n</td><td>\n\nLists the ATF aggregation coverage percent of each custom test script by script sys\\_id.Data type: Number\n\n</td></tr><tr><td>\n\napi\\_request\\_sys\\_id\n\n</td><td>\n\nThe sys\\_id of the request.Table: ATF code coverage API requests \\[sys\\_atf\\_code\\_coverage\\_request\\]\n\nData type: String\n\n</td></tr><tr><td>\n\nresult\n\n</td><td>\n\nSuccess or error message.Error response formats:\n\n-   400 Bad Request\n\n`{ \"result\": \"Validation error: <specific_error_message>\" }`\n\n-   500 Internal Server Error\n\n`{ \"result\": \"Internal server error: <error_message>\" }`\n\n\nPossible errors:\n\n-   Request body validation - `Request body is required and cannot be empty`\n-   Test ID validation - `At least one valid (non-empty) ID must be provided in either test_result_ids or test_suite_result_ids`\n-   Type mismatch - `Invalid data type in request parameters`\n\nData type: String\n\n</td></tr><tr><td>\n\ntotal\n\n</td><td>\n\nOverall code coverage percentage reflecting the combined ATF code coverage of the scripts listed in the **details** property. The value is zero if no custom scripts are associated with the tests provided or no percentage of code coverage has been provided.Possible values: 0-100\n\nData type: Number\n\n</td></tr><tr><td>\n\ntruncation\\_message\n\n</td><td>\n\nIf request data was truncated during persistence, provides details about what scripts have truncated information.Example message:\n\n`truncation_message: \"Field atf_code_coverage_request.metadata_info truncated from 5000 to 4000 characters (max: 4000). Consider increasing column length to prevent data loss\"`\n\nData type: String\n\n</td></tr><tr><td>\n\nwas\\_truncated\n\n</td><td>\n\nFlag that indicates whether request data was truncated during persistence. You can change the default number of characters supported using **glide.db.truncate\\_utf8** system property as described in the **Additional information** section.Valid values:\n\n-   true: Request data was truncated during persistence.\n-   false: Request data was not truncated during persistence.\n\nData type: Boolean\n\nDefault number of characters: 4000\n\n</td></tr></tbody>\n</table>### cURL request\n\nThe following example shows how to retrieve all of the code coverage for a selected test result suite and test result.\n\n```\ncurl \"https://instance.service-now.com/api/now/atf/code_coverage/all\" \\\n--request POST \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data \"{\n  \\\"test_suite_result_ids\\\": [\\\"5f81c7c4ff943210b88affffffffffc5\\\"],\n  \\\"test_result_ids\\\": [\\\"bb8daec1ff103210b88affffffffff1c\\\"],\n  \\\"verbose\\\": true,\n  \\\"sys_scopes\\\": [\\\"x_my_app\\\", \\\"global\\\"]\n}\" \\\n--user 'username':'password'\n```\n\nOutput:\n\n```\n{\n  \"result\": \"success\",\n  \"total\": 73,\n  \"details\": {\n    \"sys_script_include_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6\": 85,\n    \"sys_script_include_b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7\": 92,\n    \"sys_ui_script_c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8\": 45,\n    \"sys_script_d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9\": 68,\n    \"sys_script_include_e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0\": 100\n  },\n  \"api_request_sys_id\": \"f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1\",\n  \"link\": \"https://instance.service-now.com/sys_atf_code_coverage_request.do?sys_id=f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1\"\n}\n```\n\n## ATF Code Coverage - POST /now/atf/code\\_coverage/by\\_script\\_id\n\nComputes coverage for specific script records.\n\nTo compute code coverage for all scripts covered by specified ATF runs, use the endpoint /now/atf/code\\_coverage/all.\n\n### URL format\n\nVersioned URL: `/api/now/v1/atf/code_coverage/by_script_id`\n\nDefault URL: `/api/now/atf/code_coverage/by_script_id`\n\n### Supported request parameters\n\n<table class=\"rest_api_path_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_request_body\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntest\\_suite\\_result\\_ids\n\n</td><td>\n\nRequired unless `test_result_ids` are provided. List of test suite result sys\\_ids. Both `test_result_ids` and `test_suite_result_ids` can be included in the same request.Table: Test Suite Results \\[sys\\_atf\\_test\\_suite\\_result\\]\n\nData type: Array of strings\n\n</td></tr><tr><td>\n\ntest\\_result\\_ids\n\n</td><td>\n\nRequired unless `test_suite_result_ids` are provided. List of test result sys\\_ids to include. Both `test_result_ids` and `test_suite_result_ids` can be included in the same request.Table: Test Results \\[sys\\_atf\\_test\\_result\\]\n\nData type: Array of strings\n\n</td></tr><tr><td>\n\nscript\\_array\n\n</td><td>\n\nRequired. One or more valid script sys\\_ids to evaluate for code coverage. Must contain at least one valid \\(non-empty\\) script identifier. Null, empty, or whitespace-only entries are filtered out.Table: Metadata Tracing \\[sys\\_traced\\_metadata\\]\n\nData type: Array\n\n</td></tr><tr><td>\n\nverbose\n\n</td><td>\n\nFlag that indicates level of detail to provide in the response for each custom test script.Valid values:\n\n-   true: Include detailed per-item coverage in the response body **details** object.\n-   false: The response body **details** object will return empty or not at all.\n\nDefault: false\n\nData type: Boolean\n\n</td></tr><tr><td>\n\nsys\\_scopes\n\n</td><td>\n\nFilter results to specified application scopes. For example, `[\"x_my_app\", \"global\"]`. Multiple scopes use OR logic, so any matching scope is included. No filtering occurs if any empty or NULL array is provided.Data type: Array of strings\n\n</td></tr></tbody>\n</table>### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON\\)\n\n<table id=\"table_10z_n1c_i8e\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nlink\n\n</td><td>\n\nLink to the request record.Data type: String\n\n</td></tr><tr><td>\n\ndetails.&lt;scriptId&gt;\n\n</td><td>\n\nLists the ATF aggregation coverage percent of each custom test script by script sys\\_id.Data type: Number\n\n</td></tr><tr><td>\n\napi\\_request\\_sys\\_id\n\n</td><td>\n\nThe sys\\_id of the request.Table: ATF code coverage API requests \\[sys\\_atf\\_code\\_coverage\\_request\\]\n\nData type: String\n\n</td></tr><tr><td>\n\nresult\n\n</td><td>\n\nSuccess or error message.Error response formats:\n\n-   400 Bad Request\n\n`{ \"result\": \"Validation error: <specific_error_message>\" }`\n\n-   500 Internal Server Error\n\n`{ \"result\": \"Internal server error: <error_message>\" }`\n\n\nPossible errors:\n\n-   Request body validation - `Request body is required and cannot be empty`\n-   Script array validation results if the **script\\_array** request entries provided are null, empty, or whitespace - `\"script_array is required and cannot be empty - script_array must contain at least one valid script identifier\"`\n-   Test ID validation - `At least one valid (non-empty) ID must be provided in either test_result_ids or test_suite_result_ids`\n-   Type mismatch - `Invalid data type in request parameters`\n\nData type: String\n\n</td></tr><tr><td>\n\ntotal\n\n</td><td>\n\nOverall code coverage percentage reflecting the combined ATF code coverage of the scripts listed in the **details** property. The value is zero if no custom scripts are associated with the tests provided or no percentage of code coverage has been provided.Possible values: 0-100\n\nData type: Number\n\n</td></tr><tr><td>\n\ntruncation\\_message\n\n</td><td>\n\nIf request data was truncated during persistence, provides details about what scripts have truncated information.Example message:\n\n`truncation_message: \"Field atf_code_coverage_request.metadata_info truncated from 5000 to 4000 characters (max: 4000). Consider increasing column length to prevent data loss\"`\n\nData type: String\n\n</td></tr><tr><td>\n\nwas\\_truncated\n\n</td><td>\n\nFlag that indicates whether request data was truncated during persistence. You can change the default number of characters supported using **glide.db.truncate\\_utf8** system property as described in the **Additional information** section.Valid values:\n\n-   true: Request data was truncated during persistence.\n-   false: Request data was not truncated during persistence.\n\nData type: Boolean\n\nDefault number of characters: 4000\n\n</td></tr></tbody>\n</table>### Additional information\n\nLarge request payloads may be truncated when persisted if the request data exceeds database field limits.\n\nThe following fields in the ATF code coverage API requests \\[sys\\_atf\\_code\\_coverage\\_request\\] table are subject to truncation:\n\n-   test\\_suite\\_results - JSON array of test suite result IDs.\n-   test\\_results - JSON array of test result IDs.\n-   metadata\\_info - JSON object containing filtered lines or a script array.\n\nIf the **was\\_truncated** property is true, details are provided in the **truncation\\_message** property of the response body. Additionally, the system logs the following message:\n\n`Field <table_name>.<field_name> truncated from <original_length> to <truncated_length> characters (max: <max_field_length>). Consider increasing column length to prevent data loss\"`\n\nThe **glide.db.truncate\\_utf8** system property truncation behavior:\n\n-   If **glide.db.truncate\\_utf8** is true, the information truncates at UTF-8 byte boundaries. This setting is safer for multi-byte characters.\n-   If **glide.db.truncate\\_utf8** is false \\(default\\), the information truncates at character boundaries. The default boundary is 4000 characters.\n\n### cURL request\n\nThe following example shows how to retrieve the code coverage for a selected test result suite filtered by a specific test script. When **verbose** is `false` or omitted, the **details** object is empty. Only the overall **total** percentage is returned.\n\n```\ncurl \"https://instance.service-now.com/api/now/atf/code_coverage/by_script_id\" \\\n--request POST \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data \"{\n  \\\"test_suite_result_ids\\\": [\\\"5f81c7c4ff943210b88affffffffffc5\\\"],\n  \\\"script_array\\\": [\n    \\\"sys_script_include_db95cb370a0a0b2b00244880b5cacda7\\\",\n    \\\"sys_script_include_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6\\\"\n  ]\n}\" \\\n--user 'username':'password'\n```\n\nOutput:\n\n```\n{\n  \"result\": \"success\",\n  \"total\": 78,\n  \"details\": {},\n  \"api_request_sys_id\": \"a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2\",\n  \"link\": \"https://instance.service-now.com/sys_atf_code_coverage_request.do?sys_id=a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2\"\n}\n```\n\n## ATF Code Coverage - POST /now/atf/code\\_coverage/by\\_line\\_number\n\nComputes code coverage using a set of filtered line numbers per metadata record.\n\n### URL format\n\nVersioned URL: `/api/now/v1/atf/code_coverage/by_line_number`\n\nDefault URL: `/api/now/atf/code_coverage/by_line_number`\n\n### Supported request parameters\n\n<table class=\"rest_api_path_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n<table id=\"table_fyr_lf4_k3c\" class=\"rest_api_request_body\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntest\\_suite\\_result\\_ids\n\n</td><td>\n\nRequired unless `test_result_ids` are provided. List of test suite result sys\\_ids. Both `test_result_ids` and `test_suite_result_ids` can be included in the same request.Table: Test Suite Results \\[sys\\_atf\\_test\\_suite\\_result\\]\n\nData type: Array of strings\n\n</td></tr><tr><td>\n\ntest\\_result\\_ids\n\n</td><td>\n\nRequired unless `test_suite_result_ids` are provided. List of test result sys\\_ids to include. Both `test_result_ids` and `test_suite_result_ids` can be included in the same request.Table: Test Results \\[sys\\_atf\\_test\\_result\\]\n\nData type: Array of strings\n\n</td></tr><tr id=\"atfCC-reqParms-filtered_lines\"><td>\n\nfiltered\\_lines\n\n</td><td>\n\nRequired. Map of metadata sys\\_ids and corresponding code lines to designate for code coverage \\(e.g., `{ \"<metadata_sys_id>\": { \"script\": [...] } }`\\).Data type: Object\n\n</td></tr><tr id=\"atfCC-reqParms-filtered_linesID\"><td>\n\nfiltered\\_lines.&lt;sys\\_id&gt;\n\n</td><td>\n\nRequired, must not be empty. One or more script sys\\_ids to evaluate for code coverage. Must contain at least one valid \\(non-empty\\) script identifier. Null, empty, or whitespace-only entries are filtered out.Table: Metadata Tracing \\[sys\\_traced\\_metadata\\]\n\nData type: Object\n\n</td></tr><tr id=\"atfCC-reqParms-filtered_linesScrpt\"><td>\n\nfiltered\\_lines.&lt;sys\\_id&gt;.script\n\n</td><td>\n\nRequired. List of line numbers and strings of ranges of lines numbers. All values provided must be positive integers greater than or equal to 1.Valid line number formats:\n\n-   Individual lines: \\[1, 7, 10\\]\n-   Ranges: For example, \\[\"1-7\"\\] expands to \\[1, 2, 3, 4, 5, 6, 7\\].\n    -   The format is start-end, where the value of start is less than or equal to end.\n    -   The maximum range is 10000 lines.\n-   Mixed formats. For example, \\[1, \"3-6\", 7\\] expands to \\[1, 3, 4, 5, 6, 7\\].\n\nExample:\n\n```\n{\n  \"filtered_lines\": {\n    \"sys_script_include_db95cb370a0a0b2b00244880b5cacda7\": {\n      \"script\": [1, \"3-6\", 7, \"10-12\"]\n    }\n  }\n}\n```\n\nData type: Array\n\n</td></tr><tr><td>\n\nverbose\n\n</td><td>\n\nFlag that indicates level of detail to provide in the response for each custom test script.Valid values:\n\n-   true: Include detailed per-item coverage in the response body **details** object.\n-   false: The response body **details** object will return empty or not at all.\n\nDefault: false\n\nData type: Boolean\n\n</td></tr><tr><td>\n\nsys\\_scopes\n\n</td><td>\n\nFilter results to specified application scopes. For example, `[\"x_my_app\", \"global\"]`. Multiple scopes use OR logic, so any matching scope is included. No filtering occurs if any empty or NULL array is provided.Data type: Array of strings\n\n</td></tr></tbody>\n</table>### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON\\)\n\n<table id=\"table_10z_n1c_i8e\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nlink\n\n</td><td>\n\nLink to the request record.Data type: String\n\n</td></tr><tr><td>\n\ndetails.&lt;scriptId&gt;\n\n</td><td>\n\nLists the ATF aggregation coverage percent of each custom test script by script sys\\_id.Data type: Number\n\n</td></tr><tr><td>\n\napi\\_request\\_sys\\_id\n\n</td><td>\n\nThe sys\\_id of the request.Table: ATF code coverage API requests \\[sys\\_atf\\_code\\_coverage\\_request\\]\n\nData type: String\n\n</td></tr><tr><td>\n\nresult\n\n</td><td>\n\nSuccess or error message.Error response formats:\n\n-   400 Bad Request\n\n`{ \"result\": \"Validation error: <specific_error_message>\" }`\n\n-   500 Internal Server Error\n\n`{ \"result\": \"Internal server error: <error_message>\" }`\n\n\nPossible errors:\n\n-   Filtered lines validation - `\"filtered_lines is required and cannot be empty\" - \"filtered_lines must contain at least one metadata entry with valid line numbers\"`\n-   Filtered lines structure errors:\n    -   `\"Invalid line number format in filtered_lines: <details>\"`\n    -   `\"Invalid data type in filtered_lines: Ensure line numbers are integers or valid range strings (e.g., '1-7')\"`\n    -   `\"Null value found in filtered_lines structure. All metadata IDs, field names, and line number lists must be non-null\"`\n    -   `\"Unexpected error processing filtered_lines: <exception_type>: <message>\"`\n-   Line number format errors:\n    -   Generic parsing failure - `\"Invalid line number format: <item>\"` -\n    -   Line number &lt; 1 - `\"Line number must be positive: <line_number>\"`\n    -   Line range selection error, such as \"a-b\" - `\"Invalid range format: <range>. Both start and end must be valid integers\"`\n    -   Line range selection error, such as \"10-5\" - `\"Invalid range: <range>. Start value (<start>) must be less than or equal to end value (<end>)\"`\n    -   Line range selection error, such as \"-5-10\" - `\"Invalid range: <range>. Line numbers must be positive (start: <start>)\"`\n    -   Line range selection error, such as \"1-50000\" - `\"Range too large: <range>. Maximum range size is 10000 lines (requested: <size>)\"`\n-   Request body validation - `Request body is required and cannot be empty`\n-   Test ID validation - `At least one valid (non-empty) ID must be provided in either test_result_ids or test_suite_result_ids`\n-   Type mismatch - `Invalid data type in request parameters`\n\nData type: String\n\n</td></tr><tr><td>\n\ntotal\n\n</td><td>\n\nOverall code coverage percentage reflecting the combined ATF code coverage of the scripts listed in the **details** property. The value is zero if no custom scripts are associated with the tests provided or no percentage of code coverage has been provided.Possible values: 0-100\n\nData type: Number\n\n</td></tr><tr><td>\n\ntruncation\\_message\n\n</td><td>\n\nIf request data was truncated during persistence, provides details about what scripts have truncated information.Example message:\n\n`truncation_message: \"Field atf_code_coverage_request.metadata_info truncated from 5000 to 4000 characters (max: 4000). Consider increasing column length to prevent data loss\"`\n\nData type: String\n\n</td></tr><tr><td>\n\nwas\\_truncated\n\n</td><td>\n\nFlag that indicates whether request data was truncated during persistence. You can change the default number of characters supported using **glide.db.truncate\\_utf8** system property as described in the **Additional information** section.Valid values:\n\n-   true: Request data was truncated during persistence.\n-   false: Request data was not truncated during persistence.\n\nData type: Boolean\n\nDefault number of characters: 4000\n\n</td></tr></tbody>\n</table>### Additional information\n\nLarge request payloads may be truncated when persisted if the request data exceeds database field limits.\n\nThe following fields in the ATF code coverage API requests \\[sys\\_atf\\_code\\_coverage\\_request\\] table are subject to truncation:\n\n-   test\\_suite\\_results - JSON array of test suite result IDs.\n-   test\\_results - JSON array of test result IDs.\n-   metadata\\_info - JSON object containing filtered lines or a script array.\n\nIf the **was\\_truncated** property is true, details are provided in the **truncation\\_message** property of the response body. Additionally, the system logs the following message:\n\n`Field <table_name>.<field_name> truncated from <original_length> to <truncated_length> characters (max: <max_field_length>). Consider increasing column length to prevent data loss\"`\n\nThe **glide.db.truncate\\_utf8** system property truncation behavior:\n\n-   If **glide.db.truncate\\_utf8** is true, the information truncates at UTF-8 byte boundaries. This setting is safer for multi-byte characters.\n-   If **glide.db.truncate\\_utf8** is false \\(default\\), the information truncates at character boundaries. The default boundary is 4000 characters.\n\n### cURL request\n\nThe following example shows how to retrieve all code coverage for a selected test result suite and test result.\n\n```\ncurl \"https://instance.service-now.com/api/now/atf/code_coverage/by_line_number\" \\\n--request POST \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data \"{\n  \\\"test_suite_result_ids\\\": [\\\"5f81c7c4ff943210b88affffffffffc5\\\"],\n  \\\"test_result_ids\\\": [\\\"bb8daec1ff103210b88affffffffff1c\\\"],\n  \\\"filtered_lines\\\": {\n    \\\"sys_script_include_db95cb370a0a0b2b00244880b5cacda7\\\": {\n      \\\"script\\\": [1, \\\"3-6\\\", 7, \\\"10-12\\\"]\n    }\n  },\n  \\\"verbose\\\": true,\n  \\\"sys_scopes\\\": [\\\"x_my_app\\\", \\\"global\\\"]\n}\" \\\n--user 'username':'password'\n```\n\nOutput:\n\n```\n{\n  \"result\": \"success\",z\n  \"total\": 64,\n  \"details\": {\n    \"sys_script_include_db95cb370a0a0b2b00244880b5cacda7\": 80,\n    \"sys_ui_script_c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8\": 50\n  },\n  \"api_request_sys_id\": \"b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3\",\n  \"link\": \"https://instance.service-now.com/sys_atf_code_coverage_request.do?sys_id=b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3\",\n  \"was_truncated\": false\n}\n```\n\n"}}