API Key

To use the CustomJS HTTP API, you need a CustomJS account.
Your account provides an API key, which is required to authenticate your HTTP requests.

  1. Go to https://www.customjs.space and click Sign in.
  2. Sign up using your email and password or your Google account.
  3. After registration, you’ll be redirected to your CustomJS dashboard.
    Under API Key, click Show to reveal your key.
    CustomJS V2 API Key
    CustomJS V2 API Key
  4. Copy your API key — you’ll use it in the x-api-key header for all API requests.

Example Request (cURL)

curl -X POST 'https://e.customjs.io/__js1-YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-H 'customjs-origin: inline/pdf-generator' \
--data-raw '{"input":{"html":"<h1>Hello World</h1>"},"code":"const { HTML2PDF } = require(\"./utils\"); return HTML2PDF(input.html);","returnBinary":"true"}' \
> customjs-output.pdf

JavaScript Example

const apiKey = "YOUR_API_KEY";

const response = await fetch(`https://e.customjs.io/__js1-${apiKey}`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "customjs-origin": "inline/pdf-generator"
  },
  body: JSON.stringify({
    input: { html: "<h1>Hello World</h1>" },
    code: "const { HTML2PDF } = require(\"./utils\"); return HTML2PDF(input.html);",
    returnBinary: "true"
  })
});

const pdfArrayBuffer = await response.arrayBuffer();
// Browser example: create a Blob and trigger a download
// const blob = new Blob([pdfArrayBuffer], { type: "application/pdf" });
// const url = URL.createObjectURL(blob);
// const a = document.createElement('a'); a.href = url; a.download = 'customjs-output.pdf'; a.click(); URL.revokeObjectURL(url);
// Node.js example: write to file
// require('fs').writeFileSync('customjs-output.pdf', Buffer.from(pdfArrayBuffer));