Billing Cycles API
The Billing Cycles API is an integral component of the core
service. As a result, all requests should be directed to: https://api.subsbase.io/core/v2/graphql
.
The core service expects 2 headers, the X-SITE-ID
and Authorization
so the request would be:
POST https://api.subsbase.io/core/v2/graphql
Authorization: Bearer {server token}
X-SITE-ID: {your site id}
Consuming the Billing Cycles API requires that a server token is used to authenticate the request. The server token is expected in the Authorization header.
Queries
Billing Cycles Query
query GetBillingCycles($siteId: String!,$filter: FilterGQLInputType,$pagination: PaginationGQLInputType,$sorting: [SortingGQLInputType]) {
billingCycles (siteId: $siteId,filter: $filter,pagination: $pagination,sorting: $sorting) {
isSuccess
pagination
data{
id
#All properties are found in the BillingCycleGQLType
}
message
}
}
### variables
{"siteId":"", "filter":"", "pagination":"", "sorting":""}
- Returns an array of billing cycles.
- You can specify any of the fields detailed in the Billing Cycle Type Definition.
- For details about Pagination, Sorting, and Filtering Input Types, please check out PaginationGQLInputType, SortingGQLInputType, FilteringGQLInputType.
Billing Cycle Data Query
query GetBillingCycleData($siteId: String!, $billingCycleId: Guid!, $current: Boolean!){
billingCycle(siteId: $siteId, billingCycleId: $billingCycleId, current: $current) {
usageEntries{
id,
requesterId,
code,
name,
quantity,
comment,
utcTimestamp
}
usageQueryResponse{
statusCode
message
timestamp
status
},
usageQueryResult{
usage{
key
value
}
start
end
}
}
}
### variables
{
"siteId": "test-site",
"billingCycleId": "ac46b2cc-9f3f-4eb1-8dae-8ae95ae687eb",
"current": true
}
- Returns a specific billing cycle data.
- You can specify any of the fields detailed in the Billing Cycle Type Definition.
Mutations
Surcharge
Add Surcharge to Billing Cycle
- To add a surcharge to a billing cycle, you need to use the following Mutation:
mutation addSurchargeToBillingCycle($siteId: String!, $billingCycleId: Guid!,
$surcharge: SurchargeEntryGQLInputType!){
billingCycle(siteId: $siteId, billingCycleId: $billingCycleId){
surchargeEntries{
add(surchargeEntry: $surcharge){
isSuccess
message
}
}
}
}
### variables
{
"siteId": "test-site",
"billingCycleId": "4c2972fc-b138-4ddf-a2f2-02291a06c7b9",
"surcharge": {
"amount": 1,
"comment": "any"
}
}
- You can specify any of the fields detailed in the Billing Cycle Type Definition.
Remove Surcharge from Billing Cycle
- To remove a surcharge from a billing cycle, you need to use the following Mutation:
mutation removeSurchargeFromBillingCycle($siteId: String!, $billingCycleId: Guid!,
$surchargeEntryId: Guid!){
billingCycle(siteId: $siteId, billingCycleId: $billingCycleId){
surchargeEntry(surchargeEntryId: $surchargeEntryId){
delete{
isSuccess
message
}
}
}
}
### variables
{
"siteId": "test-site",
"billingCycleId": "4c2972fc-b138-4ddf-a2f2-02291a06c7b9",
"surchargeEntryId": "82f3370e-1f12-4408-b36f-7e34cf3a05c5"
}
- You can specify any of the fields detailed in the Billing Cycle Type Definition.
Usage Query Result
Retry Post Billing
- To retry post billing, you need to use the following Mutation:
mutation RetryPostBilling($siteId: String!, $billingCycleId: Guid!){
billingCycle(siteId: $siteId, billingCycleId: $billingCycleId) {
retryPostBilling{
message
isSuccess
}
}
}
### variables
{
"siteId": "test-site",
"billingCycleId": "e7dd186f-95d6-4d6b-86fd-e2b72c55bdec"
}
- You can specify any of the fields detailed in the Billing Cycle Type Definition.
Usage Entry
Add Usage Entry
- To add a usage entry, you need to use the following Mutation:
mutation AddUsageEntry($usageEntry: UsageEntryGQLInputType!, $siteId: String!, $billingCycleId: Guid!){
billingCycle(siteId: $siteId, billingCycleId: $billingCycleId) {
usageEntries{
add(usageEntry: $usageEntry){
isSuccess
message
}
}
}
}
### variables
{
"siteId": "test-site",
"billingCycleId": "ac46b2cc-9f3f-4eb1-8dae-8ae95ae687eb",
"usageEntry":
{
"code": "XXXX",
"quantity": 10,
"name": "XXXX",
"comment": "XXXX",
"utcTimestamp": "2023-12-19T15:27:55.3145073Z"
}
}
- You can specify any of the fields detailed in the Usage Entry Type Definition.
Delete Usage Entry
- To delete a usage entry, you need to use the following Mutation:
mutation DeleteUsage($usageEntryId: Guid!,$siteId: String!, $billingCycleId: Guid!){
billingCycle(siteId: $siteId, billingCycleId: $billingCycleId) {
usageEntry(usageEntryId: $usageEntryId){
delete{
isSuccess
message
}
}
}
}
### variables
{
"siteId": "test-site",
"billingCycleId": "ac46b2cc-9f3f-4eb1-8dae-8ae95ae687eb",
"usageEntryId": "2fca7045-3294-4d03-9d40-098393596bba"
}
- You can specify any of the fields detailed in the Usage Entry Type Definition.