API: Template - TestRail

API: Templates

Use the following API methods to request details about templates (field layouts for cases/results)

API Rate Limit

Please note that the API is rate-limited on TestRail Cloud to ensure optimal performance for all users and may throttle requests. TestRail might also return a 429 Too Many Requests response, which you are expected to handle. Such a response also includes a Retry-After header indicating how many seconds to wait before you are allowed to submit the next request.

To avoid rate limits on TestRail Cloud, try using bulk API endpoints (e.g. using as add_results_for_cases instead of add_results_for case), build a time delay into your API calls, or upgrade to TestRail Enterprise Cloud.

Rate limits for TestRail Cloud are as follows:

  • 180 Requests per instance, per minute for TestRail Cloud Professional subscriptions.
  • 300 Requests per instance, per minute for TestRail Cloud Enterprise subscriptions.

No API rate limits are built into TestRail Server installations.

get_templates

Returns a list of available templates (requires TestRail 5.2 or later).

GET index.php?/api/v2/get_templates/:project_id
:project_id The ID of the project

 

Response content

The response includes an array of templates (field layouts). Each template has a unique ID and a name. The is_default field is true for the default template and false otherwise.

[
	{
		"id": 1,
		"is_default": true,
		"name": "Test Case (Text)"
	},
	{
		"id": 2,
		"is_default": false,
		"name": "Test Case (Steps)"
	},
	{
		"id": 3,
		"is_default": false,
		"name": "Exploratory Session"
	},
	..
]

Response codes

200 Success, the templates are returned as part of the response
400 Invalid or unknown project
403 No access to the project