> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobrouter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Backblaze B2

> Add B2 as a routing target for archive and low-cost storage.

<Info>
  **BlobRouter v0.1** · Last updated: August 2026 · Architecture version: **2.0**
</Info>

Backblaze B2 is the preferred destination for `priority: "archive"` uploads — low storage cost for rarely accessed data.

## Prerequisites

* A Backblaze account
* A B2 bucket
* An application key with access to that bucket

## 1. Create a bucket

1. Backblaze → **Buckets** → **Create a Bucket**
2. Choose a private bucket
3. Note the bucket name and region (for example `us-west-004`)

## 2. Create an application key

1. **App Keys** → **Add a New Application Key**
2. Restrict to your bucket if possible
3. Copy **keyID** (access key) and **applicationKey** (secret)

S3-compatible endpoint:

```text theme={null}
https://s3.<region>.backblazeb2.com
```

Example: `https://s3.us-west-004.backblazeb2.com`

## 3. Add credentials in BlobRouter

1. Open [Dashboard → Providers](https://app.blobrouter.com)
2. Choose **Backblaze B2**
3. Enter Access Key ID, Secret Access Key, bucket name, and region
4. Save and **Test connection**

## 4. Upload with archive priority

```javascript theme={null}
import { BlobRouter } from "@blobrouter/sdk";
import { readFileSync } from "fs";

const storage = new BlobRouter({
  apiKey: process.env.BLOBROUTER_API_KEY,
});

const file = readFileSync("./checkpoint.bin");

const result = await storage.upload(file, {
  fileName: "checkpoint.bin",
  contentType: "application/octet-stream",
  fileSizeBytes: file.length,
  priority: "archive",
});

console.log(result.provider); // "backblaze-b2" when B2 is configured
```

## Troubleshooting

| Symptom                          | Fix                                                                                             |
| -------------------------------- | ----------------------------------------------------------------------------------------------- |
| 403 on test / upload             | Key lacks bucket permission, or wrong region/endpoint                                           |
| Routes away from B2 with warning | Confirm B2 is saved under Providers                                                             |
| Path-style issues                | BlobRouter uses path-style S3 clients; keep the regional `s3.<region>.backblazeb2.com` endpoint |
