> 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 files in a batch

GET https://aihub.instabase.com/api/v2/batches/{batch_id}/files

Return a list of files in a batch.

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

## Authentication

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

## Request

### Path parameters

- `batch_id` (integer, required) — The batch ID.

### Query parameters

- `page_size` (integer, optional) — The number of files to return in each page.
- `start_token` (string, optional) — The token to start the list from.

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

- `nodes` (list of ListBatchFilesResponseNodesItems, optional) — List of files in the batch.
- `next_page_token` (string, optional) — Token for retrieving the next page of results.
- `has_more` (boolean, optional) — Indicates whether there are more files to be retrieved.

## Errors

### 404 Not Found Error

Batch does not exist, or denied access.

- `any`

## Types

### ListBatchFilesResponseNodesItems

- `full_path` (string, optional) — Complete path to the file in the storage system.
- `metadata` (ListBatchFilesResponseNodesItemsMetadata, optional) — Metadata information about the file.
- `perms` (ListBatchFilesResponseNodesItemsPerms, optional) — Permission settings for the file.
- `name` (string, optional) — Name of the file, including optional extension.

### ListBatchFilesResponseNodesItemsMetadata

Metadata information about the file.

- `node_type` (string, optional) — Type of the node (e.g., 'file').
- `size` (integer, optional) — Size of the file in bytes.
- `modified_timestamp` (integer, optional) — Last modification timestamp of the file, in Unix time seconds.

### ListBatchFilesResponseNodesItemsPerms

Permission settings for the file.

- `can_read` (boolean, optional) — Whether the user has read permission.
- `can_write` (boolean, optional) — Whether the user has write permission.
- `can_delete` (boolean, optional) — Whether the user has delete permission.

## Examples

**Response**

```json
{
  "nodes": [
    {
      "full_path": "/path/to/document1.pdf",
      "metadata": {
        "node_type": "file",
        "size": 1024,
        "modified_timestamp": 1647532800
      },
      "perms": {
        "can_read": true,
        "can_write": true,
        "can_delete": true
      },
      "name": "document1.pdf"
    },
    {
      "full_path": "/path/to/document2.pdf",
      "metadata": {
        "node_type": "file",
        "size": 2048,
        "modified_timestamp": 1647619200
      },
      "perms": {
        "can_read": true,
        "can_write": false,
        "can_delete": false
      },
      "name": "document2.pdf"
    }
  ],
  "next_page_token": "eyJwYWdlIjogMn0=",
  "has_more": true
}
```

**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_files(
    batch_id=12345,
    page_size=2,
    start_token="abcd...<snip>...1234"
)

print(f"Has more files? {response.has_more}")
for node in response.nodes:
    print(f"File name: {node.name}")

```

```python without SDK
import requests

batch_id = 12345
url = f"https://aihub.instabase.com/api/v2/batches/{batch_id}/files"

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

page_size = 2
start_token = None

# make repeated calls to fetch more files until there are no more
while True:
    params = {
        "page_size": page_size,
        "start_token": start_token
    }
    # make the GET request
    response = requests.get(url, headers=headers, params=params)

    # handle the response
    if response.status_code != 200:
        print(f"Error: {response.status_code} - {response.text}")
        break

    for node in response.json()['nodes']:
        print(f"File name: {node['name']}")

    if not response.json().get("has_more"):
        break

    start_token = response.json().get("next_page_token")

```

```javascript Batches_listFiles_example
const url = 'https://aihub.instabase.com/api/v2/batches/12345/files';
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 Batches_listFiles_example
package main

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

func main() {

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

	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 Batches_listFiles_example
require 'uri'
require 'net/http'

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

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 Batches_listFiles_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://aihub.instabase.com/api/v2/batches/12345/files")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://aihub.instabase.com/api/v2/batches/12345/files', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Batches_listFiles_example
using RestSharp;

var client = new RestClient("https://aihub.instabase.com/api/v2/batches/12345/files");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Batches_listFiles_example
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://aihub.instabase.com/api/v2/batches/12345/files")! 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()
```