LogoFreestyle
API Reference/Execute

Execute Code

Send a TypeScript or JavaScript module, get the result

POST/execute/v1/script

Request Body

application/jsonRequired
scriptRequiredstring

The JavaScript or TypeScript script to execute

configobject
curl -X POST "https://api.freestyle.sh/execute/v1/script" \
  -H "Content-Type: application/json" \
  -d '{
    "script": "export default () => {\n  // get the value of the factorials of the numbers from 1 to 10 combined\n  const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\n  function factorial(n) {\n    if (n === 0) {\n      return 1;\n    }\n    return n * factorial(n - 1);\n  }\n\n  const b = a.map(factorial);\n\n  return b.reduce((a, b) => a + b);\n};\n",
    "config": {
      "envVars": {
        "RESEND_API_KEY": "re_123456789"
      },
      "nodeModules": {
        "resend": "4.0.1"
      },
      "tags": [
        "email"
      ],
      "timeout": null,
      "peerDependencyResolution": true,
      "networkPermissions": null,
      "customHeaders": {},
      "proxy": "https://aproxyyouown.com"
    }
  }'

Success

{
  "result": null,
  "logs": [
    {
      "message": "I'm a log!",
      "type": "log"
    }
  ]
}