Skip to content

Internal APIs ​

Not every API is for sale. An internal API is one your own teams, services or partners call. MicroAuth gives it the same keys, rate limits and usage counts as an API you sell. Two settings make it internal: sign up is Invite only, and billing is off.

There are two ways to protect one. Pick by who is calling:

Who calls itUse
Other teams, services and partners, each with their own keyAn internal API service, below
People who sign in to your apps, or scripts acting for themA sign in service with access tokens and API keys for your users

Create an internal API service ​

In the dashboard, click New service and choose Protect an internal API. Give it a name and an address. The address is where the teams you invite sign in to get their keys and see their usage.

It starts with two settings that every API has:

  • Invite only, under Settings, Sign up. Nobody can sign up on their own. You invite each team from the Customers tab, and they get the portal's keys, usage and team pages. See sign up modes.
  • Billing off, at the top of the Billing tab. There is no pay as you go, no plans, no credit and no Stripe. Requests are counted, never charged. See billing on or off.

Each team gets 10 requests a second, with no monthly quota. Change that under Billing, Default limits, and give a team more with custom limits. Besides keys teams create themselves, you can issue a key for a team from its page in the dashboard. The activity log works the same as for an API you sell. See customers and limits.

Connect your API ​

The code is the same as for an API you sell. Use the SDK secret key from the Connect tab:

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

app = FastAPI()
auth = MicroAuth(app)  # reads MICROAUTH_SECRET_KEY


@app.get("/reports")
async def reports(customer: Customer = Security(auth)):
    return {"team": customer.id}

Keys are checked inside your app from a cached copy, with no call to MicroAuth on the request path. A key past its expiry date stops working, the same as a revoked one. Other languages use the HTTP API, which honors expiry dates too.

Keys that expire ​

Give keys you issue an expiry date when they're for a contractor, a pilot or a migration. Teams see the date on their keys page, and you see it on the team's page in the dashboard. To extend access, issue a new key before the old one expires.

Expiry dates work on every API, not only internal ones. Teams can set one on keys they create on the portal too.

Start selling it later ​

An internal API is an API like any other with two settings changed, so there is no type to switch. Change the settings when you want to sell it:

  1. Turn billing on at the top of the Billing tab. Only workspace owners and admins can.
  2. On the same tab, turn on pay as you go, plans or both, and connect Stripe.
  3. To let anyone sign up, choose Open or Approval under Settings, Sign up. Keep Invite only to sell only to the partners you invite.

Customers, keys and limits carry over, and balances from before count again once billing is on.

To make an API you sell internal, choose Invite only under Settings, Sign up, and turn billing off on the Billing tab. Billing only turns off once nothing can still charge anyone, so disconnect Stripe and retire paid plans first. Turning billing off lists the checks. Customers and their keys keep working, requests are counted but no longer charged, and balances are kept in case you turn billing back on.

Your plan ​

Internal APIs use the same MicroAuth plans as APIs you sell, with a monthly request allowance and a limit on teams. See pricing.

MicroAuth is a product of Zyref, LLC.