Overview
You are looking for instructions on how to create a new plan for your provider using the GraphQL API.
Solution
Note: It is recommended to use the Plans UI when Creating a New 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.
In order to create a new plan, one should use the createPlanFromInitialTemplate operation. With this method, one can create a plan using the existing default template by passing some of the parameters mentioned in CreatePlanFromInitialTemplateInput.
Below is an example payload with some important specifications:
- The planID can be passed but should not.
- The plan 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 request handles different possible results such as what to return if the PlanAlreadyExists or on CreatePlanPayload.
mutation createPlanFromInitialTemplate{
createPlanFromInitialTemplate(
input: {
name: "API Plan",
providerId: "<providerId>",
period: { periodType: MONTH, numberOfPeriods: 1, recurring: true },
fee: 10,
version: "alpha",
voice: {
periodAllowance: 6000,
rollover:true,
longDistance: {
origination:{
aNumberCurrentCountryExpr: "*",
bNumberHomeCountryExpr: "*",
}
rate: {
rate: 1,
taxRate:0
}
}},
text: {
periodAllowance: null,
},
data: {
periodAllowance: 1073741824,
rollover:true
}
}
) {
... on CreatePlanValidationFailed {
errorMessage
errorCode
}
... on PlanAlreadyExists {
planId
errorMessage
errorCode
}
... on InvalidField{
fieldName
errorMessage
errorCode
}
... on CreatePlanPayload {
__typename
plan {
id
name
versions(first: 10) {
edges {
node {
id
state
version
createdAt
createdBy
}
}
}
}
}
}
}
The result (if the plan is successfully created) is the plan information along with its version as shown below.