Overview
You are looking for instructions on how to delete a plan version using the GraphQL API.
Solution
Note: A plan version can only be deleted if it was not deployed. If the version has already been launched, it can only be Archived.
Moreover, it is recommended to use the Plans UI to delete a plan version as the process is more user-friendly than using the API.
In order to make the requests through the API, the information below is required. For further details on the API refer to Using the CCAB GraphQL API.
- The Provider ID.
- An Access Token using the credentials from the Config/Plan User.
To delete a plan version one should use the deletePlanVersion operation. For this mutation, it is necessary to know the ID of the plan version to be deleted, and one can obtain the planVersionID following the Get Plan(s) details using the API article.
Below is an example payload using API version 10.1 where one passes the required parameters and handle the different union types that can be returned from this request.
mutation deletePlanVersion{
deletePlanVersion(
input: { planVersionId: "<planversionId>", providerId: "<providerId>"}
) {
... on PlanVersionHasReferences {
errorMessage
errorCode
planVersion {
id
version
}
}
... on PlanVersionNotFound{
planVersionId
errorMessage
errorCode
}
... on DeletePlanVersionPayload {
__typename
deletedPlanVersionId
plan{
id
name
versions (first:10) {
edges {
node {
version
state
id
}
}
}
}
}
}
}
If the plan version is successfully deleted, the response will contain the confirmation as well as list the remaining versions in the plan.
On the other hand, if the plan version cannot be deleted due it being previously deployed, the response will be as follows.