Your API, Your OAuth App, Your Rules
How we split custom OAuth apps from private APIs, and what happened to providers already downloaded to customers' machines.
The problem
We started with one plan switch called "custom". A plan either allowed custom things or it didn't. That caused a few problems:
- Pro users couldn't use their own OAuth app. It was behind the same switch as uploading your own API, which was a Business feature. A team that only wanted its own name on the consent screen had to pay for something else.
- Some providers charge per API call. Running them on our OAuth app would mean every call an agent made was billed to us.
- Teams got the wrong result both ways. A free-plan teammate in a paying team was blocked from the team's own API, while someone who had downgraded could keep using theirs.
- A private provider already downloaded into a project kept running, even after access to it had ended.
All four came from the same place. We had one word for two different things.
Two requests that sounded the same
We had treated both of these as one feature: "I don't want Swytchcode's defaults." But customers were really asking for two different things:
- BYOC, bring your own OAuth app: "I want to use my own OAuth app for an API you already support."
- BYOP, bring your own provider: "I want to call an API that isn't in your catalog."
One changes how an existing provider signs in. The other changes which providers exist. They have different users, different costs and different risks, so one switch could never get both right.
Three ways to call an API
- Our OAuth app. You click "Connect GitHub", sign in, and you're done. Swytchcode's own registered app handles the sign-in. This is the default, and it's the quickest way to start.
- Your own OAuth app (BYOC). Same provider, but you register your own app with it and give us its client ID and secret. Your users see your app's name on the consent screen, and the provider's limits apply to your app.
- Your own API (BYOP). This is an API we don't list, like your internal API or a partner's. You upload its spec, and it becomes a private provider that only you or your team can see.
The first two are about who signs in. The third is about what you can call.
So we split the switch into two plan features:
| Feature | What it allows | Plans |
|---|---|---|
| Own OAuth app | Register your own client ID and secret for a listed provider | Pro and above |
| Private providers | Upload your own API as a provider | Business and above |
Choosing how a provider signs in
You choose once per provider, per workspace:
swytchcode auth connect githubPick Default Swytchcode or your own app. For your own app, you enter its client ID and secret.
We never store the client secret. It goes straight to the OAuth service that handles sign-in, and we keep only the client ID, so we can show it back to you.
After that, every connection for that provider, yours or your end users', uses the app you chose.
Providers that charge per call
Some providers charge for each API call, X being the obvious one. On our OAuth app, every call your agent makes would be billed to us. That can't work on a free plan, or at any real scale.
So those providers are marked as needing your own app. Without one, the connection is refused with a clear reason:
x charges per API call and needs your own x developer app, available on Pro and abovex charges per API call and needs your own x developer app - run `swytchcode auth connect x` to register itThe first is plan_limit: your plan doesn't include the feature. The second is setup_required: your plan includes it, but you haven't registered an app yet. Both exit with 3, and neither is retryable, because retrying gives the same answer.
Making the split safe
The new setting had to roll out without anyone losing access along the way. Plans saved before the split only had the old switch, so the new setting falls back to it when it isn't set yet:
// Plans written before byoc_enabled existed had one switch for both.
byoc_enabled: flag(d.byoc_enabled ?? d.custom_providers_enabled),Old plans kept working exactly as before, and new plans could set the two features apart. Nobody's access changed in between.
Access follows the owner, not the caller
Every provider a customer creates starts as private. Only Swytchcode staff can make one public.
Once teams came in, we had to decide who a private provider belongs to:
- In a personal workspace, it belongs to the person who created it.
- In a team workspace, it belongs to the team, and the team owner's plan decides whether it can be used.
From that one rule, the rest follows:
- Teammates on a free plan can use the team's private providers, because the owner is paying. They never see the owner's personal ones.
- Nobody else can see it. Asking for it by name returns 404, not 403, so you can't even tell it exists.
Our first version checked the plan of the person asking. That got both of the team cases in the problem section wrong. Checking the owner's plan fixed both.
What happens when access changes
Downloading a provider writes its spec into your project, and projects get committed to git. At that point, the provider isn't just a record in our database anymore. It's software sitting on someone's machine.
That changes the question. "Can this account download provider X?" is easy, because we answer it on our server. "Can this copy, already on disk, run right now?" is harder, because running a call doesn't talk to our backend. Hiding the provider on our side does nothing to a copy that's already downloaded.
So we follow a private provider through its whole life.
Before download. Search, download and sync check the owner's plan. If it doesn't include private providers, the provider isn't offered.
After download. Each manifest entry records where it came from:
"[email protected]": {
"version": "1.4.0",
"sandbox_endpoint": "https://billing.staging.acme.internal",
"production_endpoint": "https://billing.acme.internal",
"methods": 42,
"library_uuid": "9f3c…",
"private": true
}When a call runs. Before a live call to a private provider, the CLI asks the backend whether this account can still use it:
- The answer is saved for a while, so most calls don't wait for the check.
- A "yes" is saved for longer, because it's the common case. A "no" is saved for much less time, so an upgrade takes effect quickly.
- Offline, a private provider keeps working for a limited time after the last "yes".
- When you're signed out, private providers don't run.
- Dry runs and
--explainaren't checked, because they don't send anything. - Public providers are never checked.
- Older CLI versions can't do this check, so they no longer receive private providers and are asked to update.
When access has ended, the call stops before anything is sent, with exit code 6:
{
"error": "acme is a private provider: your plan doesn't include private providers (Business and above) - upgrade at swytchcode.com/billing",
"category": "permission_denied"
}After a downgrade. When the owner's plan no longer includes private providers:
- the providers are hidden from search, download and sync for the whole team;
- copies already downloaded stop running, as described above;
- nothing is deleted, and the owner can still open and remove them in the dashboard;
- upgrading brings everything back straight away.
Summary
Most of this came from one vague word. "Custom" covered two features with different users and different costs. Once we wrote down the three ways someone can call an API, and whose plan should decide each one, the code was fairly straightforward.
The copies on disk took the most work. Anything you send to a customer's machine keeps working after you stop serving it. If access can end, plan for that early. We added it later, and it needed a manifest change, a version check and a careful rollout.
The lesson for us was that "custom" isn't a permission model. You have to say exactly what is custom, who owns it, who can use it, and what happens when that changes.
At Swytchcode, we want the first five minutes to be easy and the long term to be yours. Start on our OAuth app, move to your own app when you need your own name or your own limits, and bring your internal APIs in as private providers when your team is ready.
Related reading
More from the blog
We asked our Hermes agent if it was leaking API keys. It printed one into the chat.
Your Hermes agent keeps API keys in more places than you think, and some go to your AI provider with every message. Swytchcode's free API Key Leak Check finds them in seconds and explains the fix in plain words.
What did your Hermes agent install last week? Now you can check.
Your Hermes AI agent installs packages, pulls containers and clones repos on your behalf, and keeps no record. Swytchcode's free Agent Install Monitor keeps one, privately, on your own machine.
We connected Instinct to a flight API through Swytchcode. Here's how it went
Instinct has no way to plug in custom APIs, so we tried connecting it to Duffel's flight API through a Google Sheet, with Swytchcode holding the keys and the rules. How it works, and an honest look at how Swytchcode did.
