---
title: "Pre-Conditions - REST"
canonical: "https://docs.getxray.app/space/XRAY/301668997/Pre-Conditions%20-%20REST"
format: markdown
---
You can manage (i.e., create, update, delete) Pre-Conditions directly through [Jira's native REST API](https://docs.atlassian.com/software/jira/docs/api/REST/9.14.0/#api/2/issue-createIssue).

The Xray REST API provides the following endpoints.

# Pre-Condition Tests

- <span style="color: #333333">**TO VIEW THE TEST ASSOCIATED WITH A PRE-CONDITION YOU NEED TO SPECIFY THE KEY**</span><span style="color: #333333">** OF THE PRE-CONDITION YOU WISH TO VIEW. **</span>
- <span style="color: #333333">**TO ASSOCIATE OR REMOVE A TEST FROM A PRE-CONDITION, YOU NEED TO SEND A JSON**</span><span style="color: #333333">** WITH A LIST OF THE TEST KEYS. **</span>
- <span style="color: #333333">**TO REMOVE A TEST FROM A PRE-CONDITION YOU NEED TO SPECIFY THE KEY**</span><span style="color: #333333">** **</span><span style="color: #333333">**OF THE TEST YOU WISH TO REMOVE.**</span>


> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> Return a json with a list of the test associated with the pre-condition.
> 
> ### ** **<span style="color: #003366">**Request**</span>** **
> 
> ###### ** **<span style="color: #003366">**PATH **</span><span style="color: #003366">**PARAMETERS**</span>
> 
> | **parameter** | **type** | **description** |
> | --- | --- | --- |
> | `preConditionKey` | *String* | - key of the pre-condition. |
> | testVersion | String | Test version name |
> 
> > ✅ **Example Request**
> > ✅ 
> > ✅ <span style="color: #000000">curl -H "Content-Type: application/json" -X GET -u admin:admin </span>[<span style="color: #000000">http://yourserver/rest/raven/1.0/api/precondition/TEST-123/test</span>](http://yourserver/rest/raven/1.0/api/precondition/TEST-123/test)
> 
> ### **<span style="color: #000000">Responses </span>**
> 
> 200 OK : **text/plain** : Successful. Return a json.
> 
> ##### **Example Output**
> 
> ```
> [{
> 	key: "TEST-1",
> 	self: "http://localhost:6080/rest/api/2/issue/19701",
> 	reporter: "admin",
> 	precondition: [{
> 		preconditionKey: "TEST-4",
> 		self: "http://localhost:6080/rest/api/2/issue/19705",
> 		reporter: "admin",
> 		type: "Cucumber"
> 	}],
> 	type: "Cucumber"
> }, {
> 	key: "TEST-2",
> 	self: "http://localhost:6080/rest/api/2/issue/19701",
> 	reporter: "admin",
> 	precondition: [{
> 		preconditionKey: "TEST-4",
> 		self: "http://localhost:6080/rest/api/2/issue/19705",
> 		reporter: "admin",
> 		type: "Cucumber"
> 	}],
> 	type: "Cucumber"
> }]
> ```
> 
> 400 BAD_REQUEST : **text/plain** : Returns the error.
> 
> 401 UNAUTHORIZED : **text/plain** : The Xray for JIRA license is not valid.
> 
> 500  INTERNAL SERVER ERROR : **text/plain** : An internal error occurred getting the tests.

> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> Associate tests with the pre-condition. Return error messages, if there are any.
> 
> ### ** **<span style="color: #003366">**Request**</span>** **
> 
> ###### ** **<span style="color: #003366">**PATH **</span><span style="color: #003366">**PARAMETERS**</span>
> 
> | **parameter** | **type** | **description** |
> | --- | --- | --- |
> | preConditionKey | *String* | - key of the pre-condition. |
> | testVersion | String | Test version name |
> 
> ##### **Example Input**
> 
> ```
> {
> 	"add": [
> 		"CALC-14",
> 		"CALC-29"
> 	],
> 	"remove": [
> 		"CALC-15",
> 		"CALC-50"
> 	]
> }
> ```
> 
> > ✅ **Example Request**
> > ✅ 
> > ✅ <span style="color: #000000">curl -H "Content-Type: application/json" -X POST -u admin:admin </span><span style="color: #000000">--data @example.json</span><span style="color: #000000"> </span>[<span style="color: #000000">http://yourserver</span>](http://yourserver)<span style="color: #000000">/</span><span style="color: #000000">rest/raven/1.0/api/</span><span style="color: #000000">precondition</span><span style="color: #000000">/TEST-123/test</span>
> 
> <span style="color: #003366">**Responses**</span><span style="color: #000000">** **</span>
> 
> 200 OK : **text/plain** : Successful. Returns error messages if there are any.
> 
> 
> ##### **Example Output**
> 
> ```
> ["Test with key TEST-3 was not associated with Pre-Condition with key TEST-4.","Test with key TEST-2 was already associated with Pre-Condition with key TEST-4."]
> ```
> 
> 400 BAD_REQUEST : **text/plain** : Returns the error.
> 
> 401 UNAUTHORIZED : **text/plain** : The Xray for JIRA license is not valid.
> 
> 500  INTERNAL SERVER ERROR : **text/plain** : An internal error occurred associating the tests.

> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> Remove a test from the pre-condition.
> 
> ### ** **<span style="color: #003366">**Request**</span>** **
> 
> ###### ** **<span style="color: #003366">**PATH **</span><span style="color: #003366">**PARAMETERS**</span>
> 
> | **parameter** | **type** | **description** |
> | --- | --- | --- |
> | preConditionKey | *String* | - key of the pre-condition. |
> | testKey | *String* | - key of the test. |
> | testVersion | String | Test version name |
> 
> > ✅ **Example Request**
> > ✅ 
> > ✅ <span style="color: #000000">curl -H "Content-Type: application/json" -X DELETE -u admin:admin </span>[<span style="color: #000000">http://yourserver</span>](http://yourserver)<span style="color: #000000">/</span><span style="color: #000000">rest/raven/1.0/api/precondition/TEST-123/test/TEST-321?testVersion=v2 </span>
> 
> ###### <span style="color: #003366">**Responses**</span><span style="color: #000000">** **</span>
> 
> 200 OK : **text/plain** : Successful.
> 
> 400 BAD_REQUEST : **text/plain** : Returns the error.
> 
> 401 UNAUTHORIZED : **text/plain** : The Xray for JIRA license is not valid.
> 
> 500  INTERNAL SERVER ERROR : **text/plain** : An internal error occurred removing the test.