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

# Get Upload Token

> Generate a Vercel Blob client token for direct media uploads

## Endpoint

```
POST https://api.ugc.inc/media/create/url
```

## Overview

This endpoint generates a short-lived Vercel Blob client token for direct uploads. Upload the file with the returned `pathname` and `clientToken`, then call `/media/create` to register the uploaded blob as media in your organization.

**Upload flow:**

1. Call `/media/create/url` with the filename and optional MIME type
2. Upload the file directly to Vercel Blob using `put(pathname, file, { token: clientToken })`
3. Call `/media/create` with the uploaded blob URL to create the media record

## Request Body

<ParamField body="filename" type="string" required>
  Original filename. The API prefixes the stored path with your organization ID
  and adds a random suffix to avoid collisions.
</ParamField>

<ParamField body="contentType" type="string">
  Optional MIME type (for example `image/jpeg` or `video/mp4`). When omitted,
  the token allows image, video, and audio uploads.
</ParamField>

## Response

<ResponseField name="data" type="UploadTokenResponse">
  Upload token payload

  <Expandable title="UploadTokenResponse properties">
    <ResponseField name="clientToken" type="string">
      Short-lived Vercel Blob client token to pass to `put()`
    </ResponseField>

    <ResponseField name="pathname" type="string">
      Storage pathname to use as the first argument to `put()`
    </ResponseField>
  </Expandable>
</ResponseField>

## TypeScript

```typescript theme={null}
import { put } from "@vercel/blob/client";
import { UGCClient } from "ugcinc";

const client = new UGCClient({
  apiKey: "YOUR_API_KEY",
});

async function uploadFile(file: File, tag?: string) {
  const tokenResponse = await client.media.getUploadToken({
    filename: file.name,
    contentType: file.type || undefined,
  });

  if (!tokenResponse.ok) {
    throw new Error(tokenResponse.message);
  }

  const blob = await put(tokenResponse.data.pathname, file, {
    access: "public",
    token: tokenResponse.data.clientToken,
  });

  const mediaResponse = await client.media.create({
    urls: [blob.url],
    tag,
  });

  if (!mediaResponse.ok) {
    throw new Error(mediaResponse.message);
  }

  return mediaResponse.data.data[0];
}
```

<ResponseExample>
  ```json Success Response theme={null}
  {
    "ok": true,
    "code": 200,
    "message": "Success",
    "data": {
      "clientToken": "vercel_blob_client_...",
      "pathname": "media/org_123/example.mp4"
    }
  }
  ```

  ```json Error Response theme={null}
  {
    "ok": false,
    "code": 400,
    "message": "filename is required"
  }
  ```
</ResponseExample>
