Authentication
Authenticate every request with your Webrocket API key.
Generate an API key
- Go to https://www.webrocket.app/app/lead-hub
- In the API section, give your key a name and click Generate.
- Copy the key and store it securely (server-side only).
Keep your API key out of browsers, mobile apps, and public repositories.
Rotate and revoke on compromise.
Send authenticated requests
Add your key in the x-api-key header.
x-api-key: YOUR_API_KEY
Example (cURL)
curl -X POST https://api.webrocket.app/api/contact -H "Content-Type: application/json" -H "x-api-key: YOUR_API_KEY" -d '{
"name": "Ada Lovelace",
"email": "ada@example.com",
"subject": "Hello",
"description": "Tell me more about Webrocket",
"metadata": {
"utm_source": "homepage",
"plan": "pro"
}
}'
Example (Next.js server route)
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
const body = await req.json();
const payload = {
...body,
// Put any extra fields you want to log inside `metadata`
metadata: {
...(body.metadata || {}),
utm_source: "landing",
feature_flag: "alpha",
},
};
const res = await fetch("https://api.webrocket.app/api/contact", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.INTERNAL_API_KEY!, // set in your .env
},
body: JSON.stringify(payload),
});
const data = await res.json();
return NextResponse.json(data, { status: res.status });
}