Invoices

Invoices

Improve operations based on key insights from your completed and attempted payments.

📖

See the full documentation here.

API

You can push and get invoice information through the API.

This is a GraphQL API so you can fetch as much or as little information as desired from the different queries and mutations.

Queries

getInvoices

Use this query to get information on previously pushed invoices.

Query
query GetInvoices(
  $filter: GetInvoicesFilter
  $page: PageInput
  $sort: GetInvoicesSort
) {
  getInvoices {
    find_many(filter: $filter, page: $page, sort: $sort) {
      aggregated {
        aggregation_interval
        list {
          amount_msat
          count
          date
        }
        stats {
          countries {
            amount_msat
            count
            country
            pubkeys
          }
          destinations {
            amount_msat
            count
            pubkey
          }
        }
        total {
          amount_msat
          count
        }
      }
      list {
        account_id
        amount_msats
        amount_sats
        created_at
        description
        destination
        id
        invoice_created_at
        invoice_expiry_at
        payment_hash
        payment_request
        routing_info {
          pubkey
        }
        tags {
          boolean_value
          key
          number_value
          string_value
        }
      }
    }
  }
}
Variables
VariableDescriptionDefaultMandatory
page/limitThe amount of invoices to fetch. (Max 50)50
page/offsetHow many invoices to skip. Useful for pagination.0
sort/columnWhich column to sort by.created_at
sort/directionWhich direction to sort the column by.DESC
filter/fromISO date to fetch invoices from.Date of first invoice.
filter/toISO date to fetch invoices to.Current date
filter/tagsInvoice tags to search for.
{
  "filter": {
    "from": "2023-10-01T14:18:33Z",
    "to": "2023-11-01T14:18:33Z",
    "tags": [
      {
        "key": "user-id",
        "string_value": "61274095-7828-45dd-98e8-2daabdb39386"
      }
    ]
  },
  "page": {
    "limit": 50,
    "offset": 0
  },
  "sort": {
    "column": "created_at",
    "direction": "DESC"
  }
}

Mutations

pushInvoice

Use this mutation to push an invoice to the Reflex API.

Mutation
mutation PushInvoice($invoice: CreateInvoice!, $options: ExtraOptions) {
  pushInvoice(invoice: $invoice, options: $options) {
    invoice {
      account_id
      amount_msats
      amount_sats
      created_at
      description
      destination
      id
      invoice_created_at
      invoice_expiry_at
      payment_hash
      payment_request
      routing_info {
        pubkey
      }
      tags {
        boolean_value
        key
        number_value
        string_value
      }
    }
    checks {
      destinations {
        checks {
          report_date
          channels {
            list {
              addresses {
                address
                id
                flags
              }
              chan_id
              id
            }
          }
          ips {
            list {
              created_at
              id
              ip_address
              ip_type
              is_current
              is_hosting
              is_proxy
              is_residential_proxy
              is_smartdns
              is_tor
              is_vpn
              is_vpn_datacenter
              isp
              locations {
                city
                country
                country_code
                id
                lat
                lon
              }
              org
              port
              pubkey
              flags
              vpn_service_name
            }
            statistics {
              country {
                amount
                cities {
                  city
                }
                country
                country_code
                percent
              }
              types {
                amount
                percent
                type
              }
            }
          }
        }
        id
        pubkey
        field_location
      }
    }
  }
}
Variables
VariableDescriptionDefaultMandatory
invoice/payment_requestBolt 11 Lightning Invoice
invoice/descriptionCustom description for this invoice
invoice/tagsTags to assign to this invoice. Read more about tags here
options/invoice/do_not_saveToggle to get back the invoice information without saving it on Reflex.false

Example:

{
  "invoice": {
    "description": "User withdrawal",
    "payment_request": "lntb1u1pwz5w78pp5e8w8cr5c30xzws92v36sk45znhjn098rtc4pea6ertnmvu25ng3sdpywd6hyetyvf5hgueqv3jk6meqd9h8vmmfvdjsxqrrssy29mzkzjfq27u67evzu893heqex737dhcapvcuantkztg6pnk77nrm72y7z0rs47wzc09vcnugk2ve6sr2ewvcrtqnh3yttv847qqvqpvv398x",
    "tags": [
      {
        "key": "product-id",
        "number_value": 534271
      },
      {
        "key": "user-id",
        "string_value": "61274095-7828-45dd-98e8-2daabdb39386"
      },
      {
        "key": "is-withdrawal",
        "boolean_value": true
      }
    ]
  },
  "options": {
    "invoice": {
      "do_not_save": false
    }
  }
}