---
title: Get invoice history
---

[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 history

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

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

Retrieve a list of past invoices with pagination, optionally filtered by type.

##### 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>

params BillingInvoiceHistoryParams

</summary>

AccountID param.Field\[string]

Path param: Cloudflare account ID.

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

<details>

<summary>

Type param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/ai_gateway/subresources/billing/methods/invoice_history#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_history%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">BillingInvoiceHistoryParamsType</a>]Optional

Query param: Filter invoice type: auto, manual, or all.

</summary>

const BillingInvoiceHistoryParamsTypeAuto <a href="https://developers.cloudflare.com/api/go/resources/ai_gateway/subresources/billing/methods/invoice_history#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_history%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">BillingInvoiceHistoryParamsType</a> = "auto"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_history%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const BillingInvoiceHistoryParamsTypeAll <a href="https://developers.cloudflare.com/api/go/resources/ai_gateway/subresources/billing/methods/invoice_history#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_history%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">BillingInvoiceHistoryParamsType</a> = "all"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_history%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const BillingInvoiceHistoryParamsTypeManual <a href="https://developers.cloudflare.com/api/go/resources/ai_gateway/subresources/billing/methods/invoice_history#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_history%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">BillingInvoiceHistoryParamsType</a> = "manual"

<a href="#(resource)%20ai_gateway.billing%20%3E%20(method)%20invoice_history%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

</details>

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

</details>

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

##### ReturnsExpand Collapse

<details>

<summary>

type BillingInvoiceHistoryResponse struct{…}

</summary>

<details>

<summary>

Invoices \[]BillingInvoiceHistoryResponseInvoice

</summary>

AmountDue float64

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

AmountPaid float64

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

AmountRemaining float64

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

Currency string

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

ID stringOptional

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

AttemptCount float64Optional

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

Attempted boolOptional

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

AutoAdvance boolOptional

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

Created float64Optional

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

CreatedBy stringOptional

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

Description stringOptional

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

InvoiceOrigin stringOptional

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

InvoicePDF stringOptional

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

Status stringOptional

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

</details>

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

<details>

<summary>

Pagination BillingInvoiceHistoryResponsePagination

</summary>

HasMore bool

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

Page float64

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

PerPage float64

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

TotalCount float64

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

</details>

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

</details>

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

### Get invoice history

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.InvoiceHistory(context.TODO(), ai_gateway.BillingInvoiceHistoryParams{
    AccountID: cloudflare.F("account_id"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Invoices)
}
```

200 example

```
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "invoices": [
      {
        "amount_due": 0,
        "amount_paid": 0,
        "amount_remaining": 0,
        "currency": "currency",
        "id": "id",
        "attempt_count": 0,
        "attempted": true,
        "auto_advance": true,
        "created": 0,
        "created_by": "created_by",
        "description": "description",
        "invoice_origin": "invoice_origin",
        "invoice_pdf": "invoice_pdf",
        "status": "status"
      }
    ],
    "pagination": {
      "has_more": true,
      "page": 0,
      "per_page": 0,
      "total_count": 0
    }
  },
  "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": {
    "invoices": [
      {
        "amount_due": 0,
        "amount_paid": 0,
        "amount_remaining": 0,
        "currency": "currency",
        "id": "id",
        "attempt_count": 0,
        "attempted": true,
        "auto_advance": true,
        "created": 0,
        "created_by": "created_by",
        "description": "description",
        "invoice_origin": "invoice_origin",
        "invoice_pdf": "invoice_pdf",
        "status": "status"
      }
    ],
    "pagination": {
      "has_more": true,
      "page": 0,
      "per_page": 0,
      "total_count": 0
    }
  },
  "success": true,
  "result_info": {
    "has_more": true,
    "page": 0,
    "per_page": 0,
    "total_count": 0
  }
}
```