# List invoices

GET https://agents.gwop.io/v1/invoices

Reference: https://docs.gwop.io/api-reference/gwop-api/invoices/list-invoices

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Gwop API
  version: 1.0.0
paths:
  /v1/invoices:
    get:
      operationId: list-invoices
      summary: List invoices
      tags:
        - subpackage_invoices
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 20
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
        - name: status
          in: query
          description: Filter by invoice status
          required: false
          schema:
            $ref: '#/components/schemas/InvoiceStatus'
        - name: Authorization
          in: header
          description: |
            Merchant API key (`sk_m_*`).

            ```
            Authorization: Bearer sk_m_abc123def456...
            ```
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Invoice list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceListResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Valid authentication but insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
servers:
  - url: https://agents.gwop.io
components:
  schemas:
    InvoiceStatus:
      type: string
      enum:
        - OPEN
        - PAYING
        - PAID
        - EXPIRED
        - CANCELED
      title: InvoiceStatus
    UUID:
      type: string
      format: uuid
      title: UUID
    PublicInvoiceId:
      type: string
      title: PublicInvoiceId
    MoneyUsdc:
      type: integer
      format: int64
      description: >-
        USDC amount in atomic units (6 decimals). Used in REST response bodies.
        1000000 = 1.00 USDC.
      title: MoneyUsdc
    Currency:
      type: string
      enum:
        - USDC
      title: Currency
    Timestamp:
      type: string
      format: date-time
      title: Timestamp
    InvoiceListItemPaymentChain:
      type: string
      enum:
        - solana
        - base
      title: InvoiceListItemPaymentChain
    InvoiceListItem:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/UUID'
        public_invoice_id:
          $ref: '#/components/schemas/PublicInvoiceId'
        status:
          $ref: '#/components/schemas/InvoiceStatus'
        amount_usdc:
          $ref: '#/components/schemas/MoneyUsdc'
        currency:
          $ref: '#/components/schemas/Currency'
        description:
          type: string
        metadata:
          type: object
          additionalProperties:
            description: Any type
        expires_at:
          $ref: '#/components/schemas/Timestamp'
        created_at:
          $ref: '#/components/schemas/Timestamp'
        paid_at:
          $ref: '#/components/schemas/Timestamp'
        paid_tx_hash:
          type: string
          description: Transaction hash (Base58 for Solana, hex for Base)
        payment_chain:
          $ref: '#/components/schemas/InvoiceListItemPaymentChain'
      required:
        - id
        - public_invoice_id
        - status
        - amount_usdc
        - currency
        - expires_at
        - created_at
      title: InvoiceListItem
    Pagination:
      type: object
      properties:
        total:
          type: integer
        limit:
          type: integer
        offset:
          type: integer
        has_more:
          type: boolean
      required:
        - total
        - limit
        - offset
        - has_more
      title: Pagination
    InvoiceListResponse:
      type: object
      properties:
        invoices:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceListItem'
        pagination:
          $ref: '#/components/schemas/Pagination'
      required:
        - invoices
        - pagination
      title: InvoiceListResponse
    ErrorResponseError:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        details:
          type: object
          additionalProperties:
            description: Any type
        requestId:
          type: string
      required:
        - code
        - message
      title: ErrorResponseError
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorResponseError'
      required:
        - error
      title: ErrorResponse
    RateLimitError:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorResponseError'
      required:
        - error
      title: RateLimitError
  securitySchemes:
    MerchantApiKey:
      type: http
      scheme: bearer
      description: |
        Merchant API key (`sk_m_*`).

        ```
        Authorization: Bearer sk_m_abc123def456...
        ```

```

## SDK Code Examples

```python
import requests

url = "https://agents.gwop.io/v1/invoices"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://agents.gwop.io/v1/invoices';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://agents.gwop.io/v1/invoices"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://agents.gwop.io/v1/invoices")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://agents.gwop.io/v1/invoices")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://agents.gwop.io/v1/invoices', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://agents.gwop.io/v1/invoices");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://agents.gwop.io/v1/invoices")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```