> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.instabase.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.instabase.com/_mcp/server.

# List batches

GET https://aihub.instabase.com/api/v2/batches

Return a list of batches. Use query parameters to filter results.

Reference: https://docs.instabase.com/api-sdk/api-reference/batches/list-batches

## Authentication

- `Authorization` header (bearer token, required) — Bearer HTTP authentication.

## Request

### Query parameters

- `workspace` (string, optional) — Filter to batches in the specified workspace.
- `username` (string, optional) — Filter to batches created by the specified username (user ID).
- `limit` (integer, optional) — If paginating results, specify how many batches to return.
- `offset` (integer, optional) — If paginating results, specify the offset of the returned list.

### Headers

- `IB-Context` (string, optional) — Typically your organization ID. See [Authorization and context identification](/api-sdk/authorization#ib-context-header) for details.

## Response

### 200

Request successful.

- `batches` (list of batchInfo, optional) — List of batches. See response schema for each batch object.

## Types

### batchInfo

- `id` (integer, required) — The batch ID.
- `name` (string, required) — The batch name.
- `workspace` (string, optional) — The name of the workspace in which the batch exists.
- `mount_point` (string, optional) — The name of the connected drive in which the batch is stored.
- `repo_owner` (string, optional) — The owner of the workspace (also known as the repo) in which the batch exists.
- `batch_owner` (string, optional) — Username of the user that created the batch.
- `created_at_ms` (long, optional) — When the batch was created, in Unix time milliseconds.
- `updated_at_ms` (long, optional) — When the batch was last updated, in Unix time milliseconds.
- `path_suffix` (string, optional) — Batch path suffix from the mount point.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "batches": [
    {
      "id": 1024,
      "name": "InvoiceProcessingBatch_April2024",
      "workspace": "FinanceTeamWorkspace",
      "mount_point": "shared_drive_01",
      "repo_owner": "finance_dept",
      "batch_owner": "alice.smith_acme.com",
      "created_at_ms": 1711804800000,
      "updated_at_ms": 1711891200000,
      "path_suffix": "invoices/2024/april"
    }
  ]
}
```

**SDK Code**

```python with SDK
from aihub import AIHub

client = AIHub(
    api_root="https://aihub.instabase.com/api",
    api_key="abcdefghijklmnopqrst1234567890",
    ib_context="john.doe_acme.com"
)

response = client.batches.list(
    workspace="MyWorkspace",
    username="john.doe_acme.com",
    limit=3,
    offset=6
)

for batch in response.batches:
    print(f"id: {batch.id}")
    print(f"name: {batch.name}")

```

```python without SDK
import requests

url = "https://aihub.instabase.com/api/v2/batches"

headers = {
    "Authorization": "Bearer abcdefghijklmnopqrst1234567890",
    "IB-Context": "john.doe_acme.com"
}

# create query parameters
params = {
    "workspace": "MyWorkspace",
    "limit": 3,
    "offset": 6
}

# make the GET request
response = requests.get(url, headers=headers, params=params)

# handle the response
if response.status_code == 200:
    print(f"Retrieved {len(response.json()['batches'])} batches")
else:
    print(f"Error: {response.status_code} - {response.text}")

```

```javascript
const url = 'https://aihub.instabase.com/api/v2/batches';
const options = {
  method: 'GET',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://aihub.instabase.com/api/v2/batches"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", 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
require 'uri'
require 'net/http'

url = URI("https://aihub.instabase.com/api/v2/batches")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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://aihub.instabase.com/api/v2/batches")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://aihub.instabase.com/api/v2/batches', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://aihub.instabase.com/api/v2/batches");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://aihub.instabase.com/api/v2/batches")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```