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

# UploadThing Adapter

> Gate file uploads to subscribers

## Install

```bash theme={null}
npm install @stellartools/uploadthing-adapter uploadthing
```

## Usage

```ts theme={null}
import { shield } from "@stellartools/uploadthing-adapter";

const f = shield({
  apiKey: process.env.STELLAR_TOOLS_API_KEY!,
  productId: "prod_xxx",
});

export const fileRouter = {
  imageUploader: f({ image: { maxFileSize: "8MB" } })
    .onUploadComplete(async ({ metadata, file }) => {
      console.log("Upload complete for:", metadata.customerId);
      console.log("File URL:", file.url);
    }),
};
```

Each request must include an `x-customer-id` header with the StellarTools customer ID. The check runs before any file transfer begins — if the customer has no active subscription, the upload is rejected immediately with a `FORBIDDEN` error.

The `customerId` and `productId` are passed through to `metadata` inside `onUploadComplete`.

## Config

<ParamField body="apiKey" type="string" required>
  Your StellarTools API key.
</ParamField>

<ParamField body="productId" type="string" required>
  The product the customer must have an active subscription to.
</ParamField>

## Required headers

<ParamField header="x-customer-id" type="string" required>
  The StellarTools customer ID to verify access for.
</ParamField>
