Overview
You are looking for instructions on how to update the settings/values of a plan version using the GraphQL API.
Solution
Note: A plan version can only be updated if is still in a Draft/NEW state. If the version was already deployed, then it would be necessary to Create a New Version.
It is recommended to use the Plans UI when updating a plan version as the process is more user-friendly than using the API.
In order to make the plan 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 update a plan version one should use the updatePlanVersionFromInitialTemplate operation. The list of available parameters for this operation can be found in UpdatePlanVersionFromInitialTemplateInput.
For this mutation, it is necessary to know the ID of the plan version to update, and one can obtain it following the Get Plan details using the API article.
Below is an example payload using API version 10.1 with the following specifications:
- The new price for the plan version will be 15$
- The call minutes allowance will be updated to 300 (18000 seconds).
- The text allowance will be updated to unlimited.
- Only the values that need to be updated are being passed. For instance, the 'version' field is not being passed as the name doesn't need to be updated. Additionally, data allowance will stay as is.
mutation updatePlanVersionFromInitialTemplate{
updatePlanVersionFromInitialTemplate(
input: {
planVersionId: "<planVersionId>"
providerId: "<providerId>",
fee: 15,
voice: {
periodAllowance: 18000,
rollover:true,
longDistance: {
origination:{
aNumberCurrentCountryExpr: "*",
bNumberHomeCountryExpr: "*",
}
rate: {
rate: 1,
taxRate:0
}
}},
text: {
periodAllowance: null,
}
}
) {
... on PlanVersionAlreadyExists {
errorMessage
errorCode
planVersion{
version
state
id
}
plan{
name
id
}
}
... on PlanVersionIsReadOnly {
errorMessage
errorCode
planVersion{
version
state
id
}
}
... on CreatePlanValidationFailed {
errorMessage
errorCode
}
... on PlanVersionNotFound {
planVersionId
errorMessage
errorCode
}
... on InvalidField{
fieldName
errorMessage
errorCode
}
... on PlanVersionPayload {
__typename
planVersion {
id
version
plan {
id
name
}
modifiedAt
modifiedBy
state
priority
}
}
}
}
If the request is valid and the plan version is updated, the following details will be returned.
On the other hand, if the plan version one is attempting to update is not in a Draft/NEW state, the response would be as follows.