Lock a key to your network addresses
Make a stolen key useless outside your own network.
10 minAny keyWhat you get
- A key that only works from your organisation's outgoing addresses.
- A clear error, naming the address, when a call comes from elsewhere.
Find your outgoing addresses
Your IT knows the public addresses your servers call out from. Not sure? In the sandbox, lock a test key to any address and call once: the
403 ip_not_allowedmessage names the address Kvali saw.Lock the key
In Settings → API, an owner or admin edits the key's network addresses: single addresses (
203.0.113.7) or ranges (203.0.113.0/24,2001:db8::/48), up to 20. The change needs a fresh authenticator code and is in your audit log. A key with no addresses works from anywhere.Check it
From your server, any call works as before. From another address the same call answers
403 ip_not_allowed.curl "https://aikvali.com/api/v1/merchants?limit=1" \ -H "Authorization: Bearer $KVALI_KEY"const res = await fetch("https://aikvali.com/api/v1/merchants?limit=1", { headers: { Authorization: `Bearer ${process.env.KVALI_KEY}` }, }); if (!res.ok) throw new Error((await res.json()).error.message); const { data } = await res.json();import os import requests res = requests.get( "https://aikvali.com/api/v1/merchants?limit=1", headers={"Authorization": f"Bearer {os.environ['KVALI_KEY']}"}, timeout=30, ) if not res.ok: raise RuntimeError(res.json()["error"]["message"]) data = res.json()["data"]{ "error": { "code": "ip_not_allowed", "message": "This API key is locked to your organisation's network addresses, and 198.51.100.23 isn't one of them. An owner or admin can add an address in Settings → API." } }Remember the upload host
Document uploads (
upload_urlofPOST /merchants/{id}/documents/uploads) go to Kvali's file storage host, not to the API. If your firewall only lets known hosts out, allow that host too.