Overview
You are looking for instructions on how to create a new plan version using the GraphQL API.
Solution
Note: It is recommended to use the Plans UI when Creating a New 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 a Plan Designer user.
In order to create a new plan version, one should use the createPlanVersionFromInitialTemplate operation. With this method, one can create a plan version using an existing plan version as a base and passing some of the parameters mentioned in CreatePlanVersionFromInitialTemplateInput.
Note that it is necessary to know the ID of the previous plan version to be used as a template, and one can obtain it following the Get Plan(s) details using the API article.
The name of the plan version should be unique for the plan.
Below is an example payload using API version 10.1 with some specific details.
- The plan version is meant to renew every month and the cost is $10.
- The voice service is limited to 100 minutes (6000 seconds) per month and it also has international calling.
- The text service is unlimited.
- The data service is limited to 1 GB (1073741824 bytes) per month.
- The plan version name will be "Version 8"
mutation createPlanVersionFromInitialTemplate{
createPlanVersionFromInitialTemplate(
input: {
planVersionId: "<planVersionId>"
providerId: "<providerId>",
period: { periodType: MONTH, numberOfPeriods: 1, recurring: true },
fee: 10,
version: "Version 8",
voice: {
periodAllowance: 6000,
rollover:true,
longDistance: {
origination:{
aNumberCurrentCountryExpr: "*",
bNumberHomeCountryExpr: "*",
}
rate: {
rate: 1,
taxRate:0
}
}},
text: {
periodAllowance: null,
},
data: {
periodAllowance: 1073741824,
rollover:true
}
}
) {
... on PlanVersionAlreadyExists {
errorMessage
errorCode
plan{
name
id
}
}
... on CreatePlanValidationFailed {
errorMessage
errorCode
}
... on PlanVersionNotFound {
planVersionId
errorMessage
errorCode
}
... on InvalidField{
fieldName
errorMessage
errorCode
}
... on PlanVersionPayload {
__typename
planVersion {
id
version
basedOn {
id
version
}
plan {
id
name
}
createdAt
createdBy
state
priority
}
}
}
}
If the new plan version is successfully created, the response will contain the version details such as its ID, the plan name, and the version it was based on.
On the other hand, if there is an error with the version creation such as using an existing name, the response will contain the error details.