// api reference

JavaScript Execution API

Run JavaScript natively inside any HTTP request. Pass your code inline for quick, one-off runs, or save a stored function and call it by ID. With helpers like HTML2PDF and a library of NPM modules built in.

Quick Start

Base URL

https://e.customjs.io

Get your API key from app.customjs.space. See the API Key guide.

For common tasks like HTML to PDF, screenshots, and scraping we offer dedicated endpoints. No JavaScript required.

Inline scripts

Send the code directly in the request body. Ideal for quick tests or dynamic, one-off executions.

Pros

  • No need to save the script beforehand
  • Perfect for ad-hoc requests
  • Test HTML, templates, or logic directly

Cons

  • Code must be sent with every request
  • Can get cumbersome for complex workflows

Example. Generate a PDF inline

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"
  }' > output.pdf

Stored functions

Save the code once on the platform and call it by its Script ID. Ideal for recurring workflows, versioning, and keeping requests small.

Pros

  • Reusable across many requests
  • Centrally managed & versioned
  • Smaller payloads. Only the input data

Cons

  • Script must be saved on the platform first
  • Updates happen in the editor, not the request

Workflow

01

Open the Code Editor in the CustomJS app.

02

Create a new script and enter your code.

03

Save it and note the Script ID.

04

Call /{scriptId} with your input data.

Example. Call a stored function by ID

curl -X POST 'https://e.customjs.io/5CbuoC' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
    "Users": "[{\"name\":\"John\",\"lastName\":\"Doe\"}]"
  }'

Inline vs. Stored

InlineStored
ImplementationCode sent in the request bodySaved on CustomJS, referenced by ID
Best forQuick tests, one-off runsProduction, versioning, sharing logic
Setup effortMinimal. Write and runSave the function first
ReusabilityLimited. Redefine each timeHigh. Reuse across workflows
MaintainabilityHarder to manage changesUpdate once in one place

Available NPM modules

These modules are available in both inline and stored execution. Need another one? Just ask.

// Available in inline & stored execution
const cheerio = require('cheerio');
const { v4: uuidv4 } = require('uuid');
const axios = require('axios').default;
const AWS = require('@aws-sdk/client-s3');
const jsrsasign = require('jsrsasign');
const forge = require('node-forge');
const jsonwebtoken = require('jsonwebtoken');
const crypto = require('crypto');
const { Configuration, OpenAIApi } = require('openai');
const firebaseAdmin = require('firebase-admin');
const { PDFDocument, rgb } = require('pdf-lib');
const mysql2 = require('mysql2');
const nodemailer = require('nodemailer');
const converter = require('json-2-csv');
const moment = require('moment');
const { getJson } = require('serpapi');
const { Storage } = require('@google-cloud/storage');
const hubspot = require('@hubspot/api-client');
const pipedrive = require('pipedrive');
const { GoogleAuth } = require('google-auth-library');
const googleDrive = require('@googleapis/drive');
const googleDocs = require('@googleapis/docs');
// ...and more

// try it first

Prefer to play before you code?

Open the playground on the product page. Write JavaScript, hit run, and copy the generated curl or SDK snippet straight into your stack.

execute.curl
curl -X POST 'https://e.customjs.io/__js1-' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
    "input": "{\"name\":\"Jon Doe\"}",
    "code": "return input.name"
  }'

600 free executions / month ยท no credit card

Frequently Asked Questions