---
title: Get invoice preview
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[AI Gateway](https://developers.cloudflare.com/api/go/resources/ai_gateway)

[Billing](https://developers.cloudflare.com/api/go/resources/ai_gateway/subresources/billing)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Get invoice preview

client.AIGateway.Billing.InvoicePreview(ctx, query) (\*[BillingInvoicePreviewResponse](<https://developers.cloudflare.com/api/go/resources/ai_gateway#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)>), error)

GET/accounts/{account\_id}/ai-gateway/billing/invoice-preview

Retrieve a preview of the upcoming invoice including line items and tax.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`AI Gateway Write``AI Gateway Read`

##### ParametersExpand Collapse

<details>

<summary>

query BillingInvoicePreviewParams

</summary>

AccountID param.Field\[string]

Cloudflare account ID.

<a href="#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_preview%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_preview%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type BillingInvoicePreviewResponse struct{…}

</summary>

ID string

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

AmountDue float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20amount_due">Link to this property</a>

AmountPaid float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20amount_paid">Link to this property</a>

AmountRemaining float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20amount_remaining">Link to this property</a>

Currency string

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20currency">Link to this property</a>

<details>

<summary>

InvoiceLines \[]BillingInvoicePreviewResponseInvoiceLine

</summary>

Amount float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20amount">Link to this property</a>

Currency string

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20currency">Link to this property</a>

Description string

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20description">Link to this property</a>

<details>

<summary>

Period BillingInvoicePreviewResponseInvoiceLinesPeriod

</summary>

End float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20period%20%3E%20(property)%20end">Link to this property</a>

Start float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20period%20%3E%20(property)%20start">Link to this property</a>

</details>

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20period">Link to this property</a>

<details>

<summary>

Pricing BillingInvoicePreviewResponseInvoiceLinesPricing

</summary>

UnitAmountDecimal string

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20pricing%20%3E%20(property)%20unit_amount_decimal">Link to this property</a>

</details>

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20pricing">Link to this property</a>

Quantity float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20quantity">Link to this property</a>

<details>

<summary>

PretaxCreditAmounts \[]BillingInvoicePreviewResponseInvoiceLinesPretaxCreditAmountOptional

</summary>

Amount float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20pretax_credit_amounts%20%3E%20(items)%20%3E%20(property)%20amount">Link to this property</a>

Type string

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20pretax_credit_amounts%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

CreditBalanceTransaction stringOptional

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20pretax_credit_amounts%20%3E%20(items)%20%3E%20(property)%20credit_balance_transaction">Link to this property</a>

Discount stringOptional

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20pretax_credit_amounts%20%3E%20(items)%20%3E%20(property)%20discount">Link to this property</a>

</details>

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines%20%3E%20(items)%20%3E%20(property)%20pretax_credit_amounts">Link to this property</a>

</details>

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20invoice_lines">Link to this property</a>

PeriodEnd float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20period_end">Link to this property</a>

PeriodStart float64

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20period_start">Link to this property</a>

<details>

<summary>

Status BillingInvoicePreviewResponseStatus

</summary>

One of the following:

const BillingInvoicePreviewResponseStatusDraft BillingInvoicePreviewResponseStatus = "draft"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%200">Link to this property</a>

const BillingInvoicePreviewResponseStatusOpen BillingInvoicePreviewResponseStatus = "open"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%201">Link to this property</a>

const BillingInvoicePreviewResponseStatusPaid BillingInvoicePreviewResponseStatus = "paid"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%202">Link to this property</a>

const BillingInvoicePreviewResponseStatusUncollectible BillingInvoicePreviewResponseStatus = "uncollectible"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%203">Link to this property</a>

const BillingInvoicePreviewResponseStatusVoid BillingInvoicePreviewResponseStatus = "void"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%204">Link to this property</a>

</details>

<a href="#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)%20%3E%20(property)%20status">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai_gateway.billing%20%3E%20(model)%20BillingInvoicePreviewResponse%20%3E%20(schema)>)

### Get invoice preview

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/ai_gateway"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.AIGateway.Billing.InvoicePreview(context.TODO(), ai_gateway.BillingInvoicePreviewParams{
    AccountID: cloudflare.F("account_id"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ID)
}
```

200 example

```
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "id": "id",
    "amount_due": 0,
    "amount_paid": 0,
    "amount_remaining": 0,
    "currency": "currency",
    "invoice_lines": [
      {
        "amount": 0,
        "currency": "currency",
        "description": "description",
        "period": {
          "end": 0,
          "start": 0
        },
        "pricing": {
          "unit_amount_decimal": "unit_amount_decimal"
        },
        "quantity": 0,
        "pretax_credit_amounts": [
          {
            "amount": 0,
            "type": "type",
            "credit_balance_transaction": "credit_balance_transaction",
            "discount": "discount"
          }
        ]
      }
    ],
    "period_end": 0,
    "period_start": 0,
    "status": "draft"
  },
  "success": true,
  "result_info": {
    "has_more": true,
    "page": 0,
    "per_page": 0,
    "total_count": 0
  }
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "id": "id",
    "amount_due": 0,
    "amount_paid": 0,
    "amount_remaining": 0,
    "currency": "currency",
    "invoice_lines": [
      {
        "amount": 0,
        "currency": "currency",
        "description": "description",
        "period": {
          "end": 0,
          "start": 0
        },
        "pricing": {
          "unit_amount_decimal": "unit_amount_decimal"
        },
        "quantity": 0,
        "pretax_credit_amounts": [
          {
            "amount": 0,
            "type": "type",
            "credit_balance_transaction": "credit_balance_transaction",
            "discount": "discount"
          }
        ]
      }
    ],
    "period_end": 0,
    "period_start": 0,
    "status": "draft"
  },
  "success": true,
  "result_info": {
    "has_more": true,
    "page": 0,
    "per_page": 0,
    "total_count": 0
  }
}
```