Invoice Narrative Templates API

The Invoice Narrative Templates API enables the creation, updating, and deletion of narrative templates, allowing you to manage the extra text or messages, such as headers, comments, and footers, included in your invoices.

The Invoice Narrative Templates API is part of the core service. All requests should be made to: https://api.subsbase.io/core/v2/graphql.

The core service requires two headers, X-SITE-ID and Authorization. A typical request would look like this:

POST https://api.subsbase.io/core/v2/graphql
Authorization: Bearer {server token}
X-SITE-ID: {your site id}
Using the Invoice Narrative Templates API requires authentication via a server token, which should be included in the Authorization header.

Queries

Narrative Templates Query

query NarrativeTemplates(
    $siteId: String!
    $pagination: PaginationGQLInputType
    $sorting: [SortingGQLInputType]
    $filter: FilterGQLInputType
) {
    narrativeTemplates(
        siteId: $siteId
        sorting: $sorting
        pagination: $pagination
        filter: $filter
    ) {
        isSuccess
        message
        data {
            id
            name
            header
            footer
            default
            leftComment
            rightComment
        }
    }
}

Narrative Template Query

query narrativeTemplate($siteId: String!, $narrativeTemplateId: String!) {
narrativeTemplate(
        siteId: $siteId
        narrativeTemplateId: $narrativeTemplateId
    ) {
        id
        name
        header
        footer
        default
        leftComment
        rightComment
    }
}

Mutations

Create Narrative Template

  • To create an invoice narrative template, you need to use the following Mutation:
mutation CreateNarrativeTemplate(
  $siteId: String!
  $narrativeTemplate: NarrativeTemplateGQLInputType!
) {
  narrativeTemplates(siteId: $siteId) {
    create(narrativeTemplate: $narrativeTemplate) {
      isSuccess
      message
      value {
        id
        siteId
        name
        header
        footer
        leftComment
        rightComment
        default
      }
    }
  }
}

### variables
{
  "siteId": "test-site",
  "narrativeTemplate": {
    "name": "Example Template",
    "header": "Header Content",
    "footer": "Footer Content",
    "leftComment": "Left Comment Content",
    "rightComment": "Right Comment Content",
    "default": true
  }
}

Update Narrative Template

  • To update an invoice narrative template, you need to use the following Mutation:
mutation updateNarrativeTemplate(
  $siteId: String!
  $narrativeTemplateId: String!
  $narrativeTemplate: NarrativeTemplateGQLInputType!
) {
  narrativeTemplate(
    siteId: $siteId
    narrativeTemplateId: $narrativeTemplateId
  ) {
    update(narrativeTemplate: $narrativeTemplate) {
      isSuccess
      message
      value {
        id
        siteId
        name
        header
        footer
        leftComment
        rightComment
        default
      }
    }
  }
}

### variables
{
  "siteId": "example-site-id",
  "narrativeTemplateId": "example-template-id",
  "narrativeTemplate": {
    "name": "Updated Template Name",
    "header": "Updated Header Content",
    "footer": "Updated Footer Content",
    "leftComment": "Updated Left Comment Content",
    "rightComment": "Updated Right Comment Content",
    "default": false
  }
}

Delete Narrative Template

  • To delete an invoice narrative template, you need to use the following Mutation:
mutation DeleteNarrativeTemplate(
  $siteId: String!
  $narrativeTemplateId: String!
) {
  narrativeTemplate(
    siteId: $siteId
    narrativeTemplateId: $narrativeTemplateId
  ) {
    delete {
      isSuccess
      message
    }
  }
}

### variables
{
  "siteId": "example-site-id",
  "narrativeTemplateId": "example-template-id"
}

Set Narrative Template As Default

  • To set an invoice narrative template as default, you need to use the following Mutation:
mutation SetNarrativeTemplateAsDefault(
  $siteId: String!
  $narrativeTemplateId: String!
) {
  narrativeTemplate(
    siteId: $siteId
    narrativeTemplateId: $narrativeTemplateId
  ) {
    setAsDefault {
      isSuccess
      message
    }
  }
}

### variables
{
  "siteId": "example-site-id",
  "narrativeTemplateId": "example-template-id"
}