Make a project private
Before you begin
- Plan
- Included in Pro and Team. How plans and limits work
- Role
- Admin or higher.
- You need
- A project on a domain that serves HTTPS
A private project checks requests over HTTPS using the policy you choose under Gateway access. Require both needs a valid access key and, when the allow-list is nonempty, an allowed source address. Allow either accepts a valid key from any address or an allowed source address without a key. Signing in and managing the project use separate permissions.
-
Open the project and select Settings.
-
Under Gateway access, enter a name in New key name, such as
ci, and select Create key. -
Select Copy, store the key as a secret in the tool that calls the project, such as a CI secret named
MOCKHUB_KEY, and select I have stored it. The key is shown this once. -
Select Private. Private access policy and Allowed source addresses appear below it.
-
To also restrict where requests come from, enter each address or range in Allowed source addresses, such as
203.0.113.0/24or2001:db8::/32, and press Enter after each. -
Select Save access, and confirm with Make private.
-
Send the key with every request to the project:
Terminal window curl -H "X-MockHub-Key: $MOCKHUB_KEY" https://orders-api.mockhub.dev/orders
Result
Section titled “Result”With a nonempty list, Gateway access says Private: use an access key and an allowed source address. for Require both, or Private: use an access key or an allowed source address. for Allow either. Lists mark the second choice Private · Key or IP. Requests failing the policy get 404 Project not found, the same answer as an unknown project.
With Allow either and a nonempty allow-list, allowed addresses work even when no keys exist. With Require both, or an empty list, no keys means every request is refused. An empty list never means everyone is allowed.
Choose how requests qualify
Section titled “Choose how requests qualify”Under Private access policy, shown while Private is selected, choose Require both or Allow either, then select Save access and confirm. Require both is the default for new and existing projects.
For example, add your office’s fixed public address and select Allow either. Calls from that address need no key; CI and remote developers can send a key from elsewhere. You can skip creating a key when only the allowed addresses need access. Anyone sharing an allowed address, including people behind the same office router, receives the same access.
With an empty list, both policies require a key. Adding 0.0.0.0/0 or ::/0 under Allow either permits every address of that family without a key.
Rotate a key
Section titled “Rotate a key”Create the new key, move your clients to it, then select Revoke beside the old key. Revocation stops that key granting access immediately. With Allow either, allowed source addresses still work, including after the last key is revoked. To close the project completely, select Require both and revoke all keys, or remove all allowed addresses and revoke all keys.
A lost key cannot be shown again: revoke it and create another.
What else changes
Section titled “What else changes”- The project answers over HTTPS only and lists only its
https://URL. A request over HTTP is refused, not redirected, and a private project cannot move to a domain without HTTPS. - Every path uses the project’s access policy, including the webhook inbox. Own-inbox webhooks and alerts send no project key. Once you choose Private, Gateway access explains whether the policy prevents their delivery.
- A browser’s CORS preflight is answered without a key, because a browser never sends one on it. The request that follows must satisfy the access policy like any other.
- Refused requests are not logged, do not count against your request allowance and trigger nothing: no mock, no webhook, no recording.
- A refused request gets the same
404as an address MockHub does not serve, with no CORS headers even for an allowed origin, so the answer does not reveal that a project is there. A browser shows it as a CORS error. - A key is not an API token. It opens this project’s gateway and nothing else, never the dashboard, the API or an AI assistant.
- A configuration document or a pack never changes access by accident: a document that leaves
accessModeout keeps the project’s value, and a pack never carries it. See the configuration document.
Limits
Section titled “Limits”- After repeated refused requests from one address, across all projects, that address is refused for the rest of the minute, even with a valid key. A client that retries with a wrong key locks itself out briefly.
- The allow-list takes literal addresses and CIDR ranges only, no hostnames. An address behind a NAT or a corporate proxy is the shared one the proxy uses, and hosted CI runners change addresses from run to run, so an allow-list suits fixed egress addresses.
- The hostname stays visible to anyone who can see DNS or certificate logs. Only the answers are private.
- Call your mock leads with Copy curl, whose command reads the key from
$MOCKHUB_KEY, and offers no link to open. Its Preview in sandbox and the editor’s preview go through the sandbox, which checks neither the key nor the allow-list. - On a plan without private endpoints, a private project stays private and refuses every request; it never turns public by itself. You can still make it public or shorten its allow-list, and upgrading serves it again with the same keys.