Invoice API
The Invoice API is part of the core
service and thus all requests should go to https://api.subsbase.io/core/graphql
.
The core service expects 2 headers, the X-SITE-ID
and authorization
so the request would be:
POST https://api.subsbase.io/core/graphql
Authorization: Bearer {server token}
X-SITE-ID: {your site id}
Consuming the Invoice API requires that a server token is used to authenticate the request. The server token is expected in the
Authorization
header
Queries
Invoices Query
query GetInvoices($siteId: String!, $pagination: PaginationGQLInputType, $sorting: [SortingGQLInputType], $filter: [FilterGQLInputType])
{
invoices(siteId: $siteId, pagination: $pagination, sorting: $sorting, filter: $filter) {
isSuccess
message
pagination {
page
perPage
totalRecords
}
data {
id
total
// all invoice fields are available...
}
}
}
- Request Variables Sample:
const variables = {
siteId: "Your site ID",
pagination: {
page: 1,
perPage: 10,
},
sorting: [
{
field: "number",
direction: "Ascending",
},
],
filter: [
{
field: "number",
operator: "Contains",
value: "1024",
},
],
};
- Returns an array of invoices
- You can specify any of the fields detailed in the Invoice Type Definition
- For details about Pagination, Sorting and Filtering Input Types check out PaginationGQLInputType, SortingGQLInputType, FilteringGQLInputType
Invoice Query
query GetInvoice($siteId: String!, $invoiceId: String!) {
invoice(siteId: $siteId, invoiceId: $invoiceId) {
id
total
// all invoice fields are available...
}
}
- Returns the specific invoice
- You can specify any of the fields detailed in the Invoice Type Definition
Invoice Creation
mutation CreateInvoiceMutation($siteId: String!, $customerId: String!, $requesterId: String!, $invoice: InvoiceGQLInputType!) {
createInvoiceMutation(siteId: $siteId, customerId: $customerId, requesterId: $requesterId, invoice: $invoice) {
isSuccess
message
value
{
customerId
siteId
}
{
billedOn
dueOn
// all invoice fields are available...
}
}
}
}
- You can specify any of the fields detailed in the Invoice Type Definition
- Returns a result with the new invoice as it's value
{
"data": {
"CreateInvoiceMutation": {
"isSuccess": true,
"message": "",
"value": {
"id": "invoice_id"
}
}
}
}
Mark invoice as PAID
mutation MarkInvoiceAsPaid($siteId: String!, $invoiceId: String!, $requesterId: String!, $sitePaymentMethodId: String!) {
markInvoiceAsPaid(siteId: $siteId, invoiceId: $invoiceId, requesterId: $requesterId, sitePaymentMethodId: $sitePaymentMethodId) {
isSuccess
message
variables
{
invoiceId
siteId
sitePaymentMethodId
}
data
{
invoiceId
siteId
}
}
}
}
- Returns a result with success
{
"data": {
"markInvoiceAsPaid": {
"isSuccess": true,
"message": ""
}
}
}
}
Void
an invoice
mutation VoidInvoice(
$siteId: String!
$invoiceId: String!
$requesterId: String!
) {
voidInvoice(
siteId: $siteId
invoiceId: $invoiceId
requesterId: $requesterId
) {
isSuccess
message
variables {
invoiceId
siteId
requesterId
}
}
}
- Returns a result with success
{
"data": {
"voidInvoice": {
"isSuccess": true,
"message": ""
}
}
}
}