Skip to content

Sell an API quickstart ​

This takes about five minutes. You will launch an API in the dashboard, add the SDK to a FastAPI app and send a request with a test key. Adding sign in to an app instead? Follow the sign in quickstart.

You need Python 3.10 or newer and a FastAPI app. Using another language? The dashboard steps are the same, and the HTTP API guide replaces steps 3 to 5.

Create your account ​

Sign up at microauth.com/app/signup with your work email. We send a 6 digit code to confirm it, then you choose your name and a password. That creates your workspace.

Launch your API ​

The dashboard asks what you want MicroAuth to do. Choose Sell an API, then fill in:

  • API name, for example Weather API. It is shown on your portal and in emails.
  • Portal address, filled in from the name, like weather-api.microauth.dev. You can change it later, and add your own domain when your plan includes one.
  • Your API's base URL, optional, for the code samples your customers see.
  • How do you want to charge? Pick Pay as you go, Free with a quota or Monthly plans. Each one fills in sensible prices and limits that you can change at any time. Free with a quota starts with billing off, so requests are counted and never charged. See Pricing and payments.

Later services start from New service in the dashboard.

Click Create API. Your portal is live right away, and the next screen shows your SDK secret key (mas_...). Your server uses it to talk to MicroAuth. You can reveal it again later from the Connect tab.

Install the SDK ​

bash
pip install "fastapi[standard]" "microauth-fastapi>=3.1"
bash
# Skip uv init when the folder is already a uv project
uv init
uv add "fastapi[standard]" "microauth-fastapi>=3.1"
bash
# Skip poetry init when the folder is already a Poetry project
poetry init
poetry add "fastapi[standard]" "microauth-fastapi>=3.1"

Put the secret in a .env file next to your app, or export it in your shell. The SDK reads either one.

bash
# .env
MICROAUTH_SECRET_KEY=mas_...

Protect a route ​

python
from fastapi import FastAPI, Security
from microauth_fastapi import Customer, MicroAuth

app = FastAPI()
auth