# Search transactions

POST https://sandbox-api.shipbob.com/Experimental/transactions:query
Content-Type: application/json

Search transactions with filters (date, invoice, fee type, etc.)

Reference: https://developer-stage.shipbob.dev/api/billing/search-transactions

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: api-experimental
  version: 1.0.0
paths:
  /Experimental/transactions:query:
    post:
      operationId: search-transactions
      summary: Search transactions
      description: Search transactions with filters (date, invoice, fee type, etc.)
      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: 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.TransactionDtoCursorPagedResponse'
        '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
        '500':
          description: Server Error
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        description: >-
          Used to filter transactions based on search criteria. Required if
          cursor is not provided. Ignored when cursor is present (i.e., for
          paginated requests).
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Billing.TransactionRequestFilter'
servers:
  - url: https://sandbox-api.shipbob.com
components:
  schemas:
    Billing.SortOrder:
      type: string
      enum:
        - Ascending
        - Descending
      title: Billing.SortOrder
    Billing.TransactionRequestFilter:
      type: object
      properties:
        fromDate:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Start date for filtering transactions by transaction charge date.
            Default is current – 7 days
        invoiceIds:
          type:
            - array
            - 'null'
          items:
            type: string
          description: List of invoice IDs to filter transactions
        invoicedStatus:
          type:
            - boolean
            - 'null'
          description: "Filter Transactions by invoicing status:\r\n- True(Billed Transactions)\r\n- False(Unbilled Transactions)\r\n- null (Billed + Unbilled Transactions)"
        pageSize:
          type: integer
          description: >-
            Number of transactions to return per page (default is 100, to be
            entered when API is called for first time). Must be between 1 and
            1000.
        referenceIds:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            List of reference IDs (like Shipment ID, WRO id) to filter
            transactions (can be numeric or string identifiers).
        referenceTypes:
          type:
            - array
            - 'null'
          items:
            type: string
          description: "The type of reference associated with the ReferenceId. Available options:\r\n- Shipment  \r\n- Return  \r\n- WRO  \r\n- URO"
        sortOrder:
          $ref: '#/components/schemas/Billing.SortOrder'
        toDate:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            End date for filtering transactions by transaction charge date.
            Default is current date.
        transactionFees:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            To get all the available transaction fees use this endpoint:-
            '/transaction-fees'
        transactionTypes:
          type:
            - array
            - 'null'
          items:
            type: string
          description: "The classification or nature of the transaction \r\nTransaction Types - Charge, Refund, Credit, Payment, BalanceAdjustment"
      title: Billing.TransactionRequestFilter
    Billing.InvoiceTaxDto:
      type: object
      properties:
        taxAmount:
          type: number
          format: double
          description: Tax amount charged for the tax type.
        taxRate:
          type: number
          format: double
          description: Rate of Tax charged for the tax type
        taxType:
          type:
            - string
            - 'null'
          description: Type of tax charged for eg. GST
      title: Billing.InvoiceTaxDto
    Billing.TransactionDto:
      type: object
      properties:
        additionalDetails:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
          description: >-
            Any additional details related to the transaction in a key-value
            pair format.
        amount:
          type:
            - number
            - 'null'
          format: double
          description: Charge Amount for the transaction
        chargeDate:
          type:
            - string
            - 'null'
          description: The Charge date of transaction
        currencyCode:
          type:
            - string
            - 'null'
          description: The ISO currency code (e.g., USD, EUR) for the transaction
        fulfillmentCenter:
          type:
            - string
            - 'null'
          description: >-
            The name or code of the fulfillment center involved in the
            transaction.
        invoiceDate:
          type:
            - string
            - 'null'
          description: The date the invoice was generated
        invoiceId:
          type:
            - integer
            - 'null'
          description: The unique identifier of the related 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"
        invoicedStatus:
          type:
            - boolean
            - 'null'
          description: Indicates whether the transaction has been invoiced.
        referenceId:
          type:
            - string
            - 'null'
          description: A unique reference identifier associated with the transaction
        referenceType:
          type:
            - string
            - 'null'
          description: "The type of reference associated with the ReferenceId. Available options:\r\n- Shipment  \r\n- Return  \r\n- WRO  \r\n- URO  \r\n- Ticket Number  \r\n- FC  \r\n- LPN Reference  \r\n- Transfer Plan"
        taxes:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Billing.InvoiceTaxDto'
          description: A list of tax details applied to the transaction if exists.
        transactionFee:
          type:
            - string
            - 'null'
          description: "The fee type associated with the transaction for eg. Shipping fees\r\nTo get all the available transaction fees use the endpoint -  '/transaction-fees'"
        transactionId:
          type:
            - string
            - 'null'
          description: The unique identifier for transaction
        transactionType:
          type:
            - string
            - 'null'
          description: "The classification or nature of the transaction \r\nTransaction Types - Charge, Refund, Credit, Payment, BalanceAdjustment"
      description: Represents a transaction data object.
      title: Billing.TransactionDto
    Billing.TransactionDtoCursorPagedResponse:
      type: object
      properties:
        first:
          type:
            - string
            - 'null'
          description: Go to the first page
        items:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Billing.TransactionDto'
        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.TransactionDtoCursorPagedResponse
    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_searchTransactions_example
import requests

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

payload = {
    "fromDate": "2019-08-24",
    "invoiceIds": ["123", "456"],
    "invoicedStatus": True,
    "pageSize": 0,
    "referenceIds": ["11553288", "43-12000928-Pallet00"],
    "referenceTypes": ["FC"],
    "sortOrder": "Ascending",
    "toDate": "2019-08-24",
    "transactionFees": ["Kitting Fee", "Warehousing Fee"],
    "transactionTypes": ["Charge"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Billing_searchTransactions_example
const url = 'https://sandbox-api.shipbob.com/Experimental/transactions:query';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"fromDate":"2019-08-24","invoiceIds":["123","456"],"invoicedStatus":true,"pageSize":0,"referenceIds":["11553288","43-12000928-Pallet00"],"referenceTypes":["FC"],"sortOrder":"Ascending","toDate":"2019-08-24","transactionFees":["Kitting Fee","Warehousing Fee"],"transactionTypes":["Charge"]}'
};

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

```go Billing_searchTransactions_example
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"fromDate\": \"2019-08-24\",\n  \"invoiceIds\": [\n    \"123\",\n    \"456\"\n  ],\n  \"invoicedStatus\": true,\n  \"pageSize\": 0,\n  \"referenceIds\": [\n    \"11553288\",\n    \"43-12000928-Pallet00\"\n  ],\n  \"referenceTypes\": [\n    \"FC\"\n  ],\n  \"sortOrder\": \"Ascending\",\n  \"toDate\": \"2019-08-24\",\n  \"transactionFees\": [\n    \"Kitting Fee\",\n    \"Warehousing Fee\"\n  ],\n  \"transactionTypes\": [\n    \"Charge\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

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

url = URI("https://sandbox-api.shipbob.com/Experimental/transactions:query")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"fromDate\": \"2019-08-24\",\n  \"invoiceIds\": [\n    \"123\",\n    \"456\"\n  ],\n  \"invoicedStatus\": true,\n  \"pageSize\": 0,\n  \"referenceIds\": [\n    \"11553288\",\n    \"43-12000928-Pallet00\"\n  ],\n  \"referenceTypes\": [\n    \"FC\"\n  ],\n  \"sortOrder\": \"Ascending\",\n  \"toDate\": \"2019-08-24\",\n  \"transactionFees\": [\n    \"Kitting Fee\",\n    \"Warehousing Fee\"\n  ],\n  \"transactionTypes\": [\n    \"Charge\"\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.post("https://sandbox-api.shipbob.com/Experimental/transactions:query")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"fromDate\": \"2019-08-24\",\n  \"invoiceIds\": [\n    \"123\",\n    \"456\"\n  ],\n  \"invoicedStatus\": true,\n  \"pageSize\": 0,\n  \"referenceIds\": [\n    \"11553288\",\n    \"43-12000928-Pallet00\"\n  ],\n  \"referenceTypes\": [\n    \"FC\"\n  ],\n  \"sortOrder\": \"Ascending\",\n  \"toDate\": \"2019-08-24\",\n  \"transactionFees\": [\n    \"Kitting Fee\",\n    \"Warehousing Fee\"\n  ],\n  \"transactionTypes\": [\n    \"Charge\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox-api.shipbob.com/Experimental/transactions:query', [
  'body' => '{
  "fromDate": "2019-08-24",
  "invoiceIds": [
    "123",
    "456"
  ],
  "invoicedStatus": true,
  "pageSize": 0,
  "referenceIds": [
    "11553288",
    "43-12000928-Pallet00"
  ],
  "referenceTypes": [
    "FC"
  ],
  "sortOrder": "Ascending",
  "toDate": "2019-08-24",
  "transactionFees": [
    "Kitting Fee",
    "Warehousing Fee"
  ],
  "transactionTypes": [
    "Charge"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Billing_searchTransactions_example
using RestSharp;

var client = new RestClient("https://sandbox-api.shipbob.com/Experimental/transactions:query");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"fromDate\": \"2019-08-24\",\n  \"invoiceIds\": [\n    \"123\",\n    \"456\"\n  ],\n  \"invoicedStatus\": true,\n  \"pageSize\": 0,\n  \"referenceIds\": [\n    \"11553288\",\n    \"43-12000928-Pallet00\"\n  ],\n  \"referenceTypes\": [\n    \"FC\"\n  ],\n  \"sortOrder\": \"Ascending\",\n  \"toDate\": \"2019-08-24\",\n  \"transactionFees\": [\n    \"Kitting Fee\",\n    \"Warehousing Fee\"\n  ],\n  \"transactionTypes\": [\n    \"Charge\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Billing_searchTransactions_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "fromDate": "2019-08-24",
  "invoiceIds": ["123", "456"],
  "invoicedStatus": true,
  "pageSize": 0,
  "referenceIds": ["11553288", "43-12000928-Pallet00"],
  "referenceTypes": ["FC"],
  "sortOrder": "Ascending",
  "toDate": "2019-08-24",
  "transactionFees": ["Kitting Fee", "Warehousing Fee"],
  "transactionTypes": ["Charge"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox-api.shipbob.com/Experimental/transactions:query")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```