Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/Storx/llms.txt

Use this file to discover all available pages before exploring further.

GET /api/imagekit-auth generates signed authentication parameters for use with ImageKit’s client-side SDK. It wraps ImageKit’s getAuthenticationParameters() method, signs the parameters server-side using your IMAGEKIT_PRIVATE_KEY, and returns them to the authenticated caller. A valid Clerk session is required.

Request

PropertyValue
MethodGET
Path/api/imagekit-auth
AuthClerk session required
This endpoint accepts no query parameters or request body.

Response

200 — Success

{
  "authParams": {
    "token": "abc123def456",
    "expire": 1700000000,
    "signature": "sha1signature"
  }
}
authParams
object
ImageKit authentication object generated by imagekit.getAuthenticationParameters().

Error Responses

StatusError messageCause
401unauthorizedNo active Clerk session found for the request.
500failed to generate auth parameters for imagekitIMAGEKIT_PRIVATE_KEY is missing or ImageKit threw an error.

Usage

Call this endpoint before performing a client-side upload via the ImageKit Next.js SDK (@imagekit/next). The SDK requires a fresh set of auth parameters for every upload to authenticate the request against ImageKit’s servers — this endpoint is the server-side provider for those parameters. Typical flow:
1

Fetch auth parameters

Your client calls GET /api/imagekit-auth to obtain a signed token, expire, and signature.
2

Initiate the upload

Pass the authParams object to the ImageKit client-side upload function alongside the file and any metadata.
3

ImageKit validates the signature

ImageKit’s upload API uses the signature to verify the request originated from your authorised backend before storing the file.

Examples

curl https://your-app.vercel.app/api/imagekit-auth \
  -H "Cookie: __session=<clerk_session_token>"

Full client-side upload example

import { upload } from '@imagekit/next';

// 1. Fetch auth params from your server
const res = await fetch('/api/imagekit-auth');
const { authParams } = await res.json();

// 2. Upload the file directly to ImageKit
const result = await upload({
  file: fileInput,                       // File | Blob
  fileName: 'my-document.pdf',
  publicKey: process.env.NEXT_PUBLIC_IMAGEKIT_PUBLIC_KEY!,
  urlEndpoint: process.env.NEXT_PUBLIC_IMAGEKIT_URL_ENDPOINT!,
  ...authParams,                         // token, expire, signature
});

console.log(result.url); // CDN URL of the uploaded file

This endpoint is called automatically by the Storx dashboard’s file upload flow. You only need to call it directly if you are building a custom upload integration outside of the default dashboard UI.
IMAGEKIT_PRIVATE_KEY must be set in your server-side environment variables for this endpoint to function. Never expose this key in client-side code or commit it to version control — doing so would allow anyone to forge upload signatures on your ImageKit account.

Build docs developers (and LLMs) love