> ## 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.ufsUrl);
  }),
};
```

Pass the customer email on each upload. The adapter looks up the StellarTools customer and checks their subscription before the file transfer starts.

```tsx theme={null}
<UploadDropzone
  endpoint="imageUploader"
  headers={{ "x-customer-email": customerEmail }}
/>
```

Use the email from checkout for that product. If the customer is not found or has no active subscription, the upload is rejected.

`metadata.customerId` and `metadata.productId` are available in `onUploadComplete`.

## Config

**apiKey** `string` *required*

Your StellarTools API key.

**productId** `string` *required*

The product the customer must have an active subscription to.

## Required headers

**x-customer-email** `string` *required*

The customer email to look up and verify access for.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.