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

# Upload part to multipart session

PUT https://aihub.instabase.com/api/v2/batches/multipart-upload/sessions/{session_id}/parts/{part_num}
Content-Type: application/octet-stream

Upload part of a file to the multipart upload session. The size of each part must match the `part_size` returned by the [Start multipart upload session](/api-sdk/api-reference/batches/create-multipart-upload-session) call, except for the final part, which can be smaller.

Parts must be uploaded with consecutive part numbers starting at 1.


Reference: https://docs.instabase.com/api-sdk/api-reference/batches/upload-multipart-part

## Authentication

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

## Request

### Path parameters

- `session_id` (string, required) — The session ID obtained from the Start multipart upload session response.
- `part_num` (integer, required) — The part number, starting at 1 and increasing consecutively for each part.

### Headers

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

### Body (application/octet-stream)

This endpoint expects binary data of type application/octet-stream.

- Binary request body.

## Response

### 201

The part was successfully uploaded.

- `part_id` (string, required) — ID of the uploaded part.
- `part_num` (integer, required) — The part number of the uploaded part, indicating upload order. Identical to the part number in the request URL.

## Examples

**Request**

```json
"VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu"
```

**Response**

```json
{
  "part_id": "part_9f8b7c6d5e4a3b2c1d0e",
  "part_num": 1
}
```

**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"
)

parts = []
part_num = 1

# use `session_id` and `part_size` variables set by 
# the "Start multipart upload session" API/SDK operation,
# which must be run before running this operation

local_filepath = "/local/path/to/large-file.pdf"
with open(local_filepath, "rb") as local_file:
    while True:
        part_data = local_file.read(part_size)
        if not part_data:
            break
        
        # upload this part using SDK
        response = client.batches.upload_multipart_part(
            session_id=session_id,
            part_num=part_num,
            part_data=part_data
        )

        parts.append(
            {
                "part_num": part_num,
                "part_id": response.part_id
            }
        )
        print(f"Uploaded part {part_num}")
        
        part_num += 1

```

```python without SDK
import requests

# use `session_id` and `part_size` variables set by
# the "Start multipart upload session" API/SDK operation,
# which must be run before running this operation
session_endpoint = f"https://aihub.instabase.com/api/v2/batches/multipart-upload/sessions/{session_id}"

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

parts = []
part_num = 1

local_filepath = "/local/path/to/large-file.pdf"
with open(local_filepath, "rb") as input_file:
    part = input_file.read(part_size)
    while part:
        # upload this part
        part_url = f"{session_endpoint}/parts/{part_num}"
        part_response = requests.put(part_url, headers=headers, data=part)

        if part_response.status_code == 201:
            parts.append(
                {
                    "part_num": part_num,
                    "part_id": part_response.json()["part_id"]
                }
            )
            print(f"Uploaded part {part_num}")
        else:
            print(f"Error uploading part {part_num}: {part_response.status_code}")
            break

        # read next part
        part = input_file.read(part_size)
        part_num += 1

```

```javascript
const url = 'https://aihub.instabase.com/api/v2/batches/multipart-upload/sessions/session_id/parts/1';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/octet-stream'},
  body: '"VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu"'
};

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/multipart-upload/sessions/session_id/parts/1"

	payload := strings.NewReader("\"VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu\"")

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

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

	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/multipart-upload/sessions/session_id/parts/1")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/octet-stream'
request.body = "\"VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu\""

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.put("https://aihub.instabase.com/api/v2/batches/multipart-upload/sessions/session_id/parts/1")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/octet-stream")
  .body("\"VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu\"")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://aihub.instabase.com/api/v2/batches/multipart-upload/sessions/session_id/parts/1', [
  'body' => '"VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu"',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/octet-stream',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://aihub.instabase.com/api/v2/batches/multipart-upload/sessions/session_id/parts/1");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/octet-stream");
request.AddParameter("application/octet-stream", "\"VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu\"", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/octet-stream"
]

let postData = NSData(data: ""VGhpcyBpcyBhIHRlc3QgcGFydCBvZiB0aGUgbXVsdGlwYXJ0IGZpbGUu"".data(using: String.Encoding.utf8)!)

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