Overview
You are looking for instructions on how to delete plan from your provider using the GraphQL API.
Solution
Note: A plan can only be deleted if none of its versions were deployed. If a version has already been launched/deployed, it can only be archived.
Additionally, it is recommended to use the Plans UI to delete a plan 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 one should use the deletePlan operation. For this mutation, it is necessary to know the ID of the plan to be deleted, and one can obtain the planID following the Get Plan(s) details using the API article, or through the Plans UI by opening a plan and checking the ID on the URL.
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 deletePlan{
deletePlan(
input: { planId: "<planId>", providerId: "<providerId>"}
) {
... on PlanIsReadOnly {
errorMessage
errorCode
}
... on PlanVersionHasReferences {
errorMessage
errorCode
planVersion {
id
version
}
}
... on PlanNotFound{
planId
errorMessage
errorCode
}
... on DeletePlanPayload {
__typename
deletedPlanServices
deletedPlanId
deletedPlanVersions
}
}
}
If the plan is successfully deleted, the response will contain the following details.
On the other hand, if the plan cannot be deleted due to a version being deployed, the response will be as follows.