Download the SDK into your project. The files are public and need no token.
curl -fsSLO https://dash.openwaf.dev/v1/sdk/openwaf.tscurl -fsSLO https://dash.openwaf.dev/v1/sdk/openwaf.pyCommit the file with your code. To update it, download it again; see How the SDKs are generated.
Create an API token in the dashboard under API tokens. Read only is enough for this guide; use Tech to make changes. Tokens start with
owf_.Configure the client through the environment, so the token stays out of your code:
export OPENWAF_API_URL=https://dash.openwaf.dev read -rs OPENWAF_TOKEN && export OPENWAF_TOKENList your zones.
list-zones.tsimport { OpenWAF } from "./openwaf.ts"; const owf = new OpenWAF(); const { items = [] } = await owf.listZones(); for (const z of items) { console.log([z.name, z.status, "v" + z.config_version].join("\t")); }bun list-zones.ts # or: node --experimental-strip-types list-zones.tslist_zones.pyfrom openwaf import OpenWAF owf = OpenWAF() for z in owf.list_zones()["items"]: print(z["name"], z["status"], "v%d" % z["config_version"], sep="\t")python3 list_zones.py
The client finds your organisation from the token. Every zone has an id: zone methods take that id, not the domain name. Next: Create a DNS record.