Securing your endpoints with API Authentication

You can enable one-click API authentication for your Napkin functions so that only people with an API key can call them. To enable API Auth, go to the Other tab of the Napkin editor and see the API Authentication section. Set authentication to On. You can also view and reset your API Key here, but be careful - all of your auth-enabled Napkin functions will be updated to use the new key as well if you reset!

To call an auth-enabled Napkin, include your API key in the HTTP request header using the key NAPKIN-ACCOUNT-API-KEY. See below for some examples of how to pass headers in an HTTP request.

Bash

curl -H "napkin-account-api-key: 123exampleAPIK3y" <account-name>.npkn.net/<endpoint>

Python

import requests

headers = {"napkin-account-api-key": "123exampleAPIK3y"}
res = requests.get("<account-name>.npkn.net/<endpoint>", headers=headers)

JavaScript

const response = await fetch("<account-name>.npkn.net/<endpoint>", {
  headers: {
    "napkin-account-api-key": "123exampleAPIK3y"
  }
})