# Get Invoices

GET https://sandbox-api.shipbob.com/Experimental/invoices

Gets a paginated list of invoices, optionally filtered by invoice types and date range

Reference: https://developer-stage.shipbob.dev/api/billing/get-invoices

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: api-experimental
  version: 1.0.0
paths:
  /Experimental/invoices:
    get:
      operationId: get-invoices
      summary: Get Invoices
      description: >-
        Gets a paginated list of invoices, optionally filtered by invoice types
        and date range
      tags:
        - subpackage_billing
      parameters:
        - name: cursor
          in: query
          description: >
            [Optional] A pagination token used to jump to first, last, next or
            previous pages. When supplied, it overrides all other filter
            parameters.
          required: false
          schema:
            type: string
        - name: fromDate
          in: query
          description: >
            [Optional] Start date for filtering invoices by invoice date.
            Default is current - 1 month date.
          required: false
          schema:
            type: string
            format: date-time
        - name: toDate
          in: query
          description: >
            [Optional] End date for filtering invoices by invoice date. Default
            is current date.
          required: false
          schema:
            type: string
            format: date-time
        - name: invoiceTypes
          in: query
          description: >-
            [Optional] Filter invoices by invoice type. Valid values:
            Shipping,WarehouseStorage,Inbound Fee,Return,AdditionalFee,Credits
          required: false
          schema:
            type: array
            items:
              type: string
        - name: pageSize
          in: query
          description: >
            Number of invoices to return per page (default: 100). Must be
            between 1 and 1000.
          required: false
          schema:
            type: integer
        - name: sortOrder
          in: query
          description: >
            Sort invoices by Invoice Date. Values - Ascending, Descending.
            Default: Descending.
          required: false
          schema:
            type: string
        - name: Authorization
          in: header
          description: Authentication using Personal Access Token (PAT) token
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Billing.InvoiceDtoCursorPagedResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Billing.ProblemDetails'
        '401':
          description: Authorization missing or invalid
          content:
            application/json:
              schema:
                description: Any type
        '403':
          description: The provided credentials are not authorized to access this resource
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Client Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Billing.ProblemDetails'
        '500':
          description: Server Error
          content:
            application/json:
              schema:
                description: Any type
servers:
  - url: https://sandbox-api.shipbob.com
components:
  schemas:
    Billing.InvoiceDto:
      type: object
      properties:
        amount:
          type: number
          format: double
          description: The total invoice amount.
        currencyCode:
          type:
            - string
            - 'null'
          description: The ISO currency code used in the invoice (e.g., USD, EUR).
        invoiceDate:
          type:
            - string
            - 'null'
          description: The invoice date in yyyy-mm-dd format.
        invoiceId:
          type: integer
          description: Unique identifier for the invoice.
        invoiceType:
          type:
            - string
            - 'null'
          description: "The type or category of the invoice. Available options:\r\n- Shipping  \r\n- Inbound Fee  \r\n- WarehouseStorage  \r\n- AdditionalFee  \r\n- Return   \r\n- Credits  \r\n- BalanceAdjustment  \r\n- Payment"
        runningBalance:
          type: number
          format: double
          description: The running balance of the account after this invoice is applied.
      description: Data transfer object representing an invoice.
      title: Billing.InvoiceDto
    Billing.InvoiceDtoCursorPagedResponse:
      type: object
      properties:
        first:
          type:
            - string
            - 'null'
          description: Go to the first page
        items:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Billing.InvoiceDto'
        last:
          type:
            - string
            - 'null'
          description: Go to the Last page
        next:
          type:
            - string
            - 'null'
          description: Go to the Next page
        prev:
          type:
            - string
            - 'null'
          description: Go to the Previous page
      title: Billing.InvoiceDtoCursorPagedResponse
    Billing.ProblemDetails:
      type: object
      properties:
        detail:
          type:
            - string
            - 'null'
        instance:
          type:
            - string
            - 'null'
        status:
          type:
            - integer
            - 'null'
        title:
          type:
            - string
            - 'null'
        type:
          type:
            - string
            - 'null'
      title: Billing.ProblemDetails
  securitySchemes:
    PAT:
      type: http
      scheme: bearer
      description: Authentication using Personal Access Token (PAT) token
    OAuth2:
      type: http
      scheme: bearer
      description: OAuth2 authentication using JWT tokens

```

## SDK Code Examples

```python Billing_getInvoices_example
import requests

url = "https://sandbox-api.shipbob.com/Experimental/invoices"

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

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

print(response.json())
```

```javascript Billing_getInvoices_example
const url = 'https://sandbox-api.shipbob.com/Experimental/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 Billing_getInvoices_example
package main

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

func main() {

	url := "https://sandbox-api.shipbob.com/Experimental/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 Billing_getInvoices_example
require 'uri'
require 'net/http'

url = URI("https://sandbox-api.shipbob.com/Experimental/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 Billing_getInvoices_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://sandbox-api.shipbob.com/Experimental/invoices")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://sandbox-api.shipbob.com/Experimental/invoices', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Billing_getInvoices_example
using RestSharp;

var client = new RestClient("https://sandbox-api.shipbob.com/Experimental/invoices");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Billing_getInvoices_example
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox-api.shipbob.com/Experimental/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()
```