Skip to content

Environment Variables

Environment variables let you pass configuration to your tool at runtime without hardcoding values in your code. Common uses: API keys, base URLs, and feature flags.


Setting environment variables

Manage environment variables from inside the tool editor:

  1. Open your tool in the editor (Step 2 — Code & Test)
  2. Find the Environment Variables panel in the sidebar
  3. Add a key and value, then save

Variables are available to all versions of the tool.


Accessing variables in your code

Python

import os
def cortexone_handler(event, context):
api_key = os.environ.get("MY_API_KEY")
base_url = os.environ.get("BASE_URL", "https://api.example.com")
return {"statusCode": 200, "body": {"ready": api_key is not None}}

JavaScript

function cortexone_handler(event, context) {
var apiKey = process.env.MY_API_KEY;
var baseUrl = process.env.BASE_URL || "https://api.example.com";
return { statusCode: 200, body: { ready: !!apiKey } };
}

Lua

function cortexone_handler(event, context)
local apiKey = process.env.MY_API_KEY
local baseUrl = process.env.BASE_URL or "https://api.example.com"
return {statusCode = 200, body = {ready = apiKey ~= nil}}
end

Security

  • Values are stored encrypted at rest.
  • Avoid hardcoding secrets in your source code — use environment variables instead.