Getting started
Create and run your first mock API
This guide takes you from an empty account to a working local REST endpoint. You will create a cloud project and TypeScript resource, generate an API token, synchronize the project with the official npm CLI, and call the Express server running on your machine.
1. Create an account and project
Create a free account, verify your email, and open the Projects area. Add a project named Product catalog with the slug product-catalog. The slug becomes the stable identifier used by the CLI.
Choose a local mock port that does not conflict with another service. The default runtime port is 4000 and can be overridden when starting the CLI.
2. Define the TypeScript resource
Add a collection resource at /products and paste this response model. MockApiStudioResponse is required because it tells the generator which type forms the response and whether the endpoint is a collection.
interface Product {
id: string;
name: string;
price: number;
inStock: boolean;
}
type MockApiStudioResponse = Product[];3. Configure and validate the endpoint
Enable GET, POST, PUT, PATCH, and DELETE as needed. Set the generated record count, choose sortable fields, and configure pagination, latency, errors, or authentication for the states your application must handle.
Save the resource after the editor reports no TypeScript or mockability errors. The dashboard validates types before the definition becomes available to the local runtime.
4. Generate an API token
Open the Token area and create the token used by the CLI. Treat it like a password: do not commit it to source control or place it in client-side code. The interactive CLI can save the token in ~/.mock-api-studio/config.json for later runs.
5. Install and start the npm runtime
Node.js 20.19 or a compatible newer release is required. You can run the published package without a global install. On the first run, select a workspace and project when prompted, or start the project directly by slug.
# Interactive project picker
npx mock-api-studio-cli
# Direct start by project slug
npx mock-api-studio-cli start product-catalog
# Optional port override
npx mock-api-studio-cli start product-catalog --port 45006. Confirm the server output
A successful start reports that authentication completed, names the synchronized project, shows how many resources and relationships loaded, and prints the local server URL. It then lists the enabled routes and query parameter names.
✓ Authenticated
✓ Project: Product catalog (product-catalog)
✓ 1 mock resource(s) loaded
Mock server running at http://localhost:4000
GET http://localhost:4000/products
POST http://localhost:4000/products7. Call and change your first endpoint
Call the resource from a browser, curl, React, Angular, or any HTTP client. With pagination enabled, collection responses contain data and meta objects. A POST writes to SQLite, and a later GET includes the new record.
After changing the model or endpoint settings in the dashboard, restart the CLI to synchronize. A schema change may require regenerating the local database, so preserve any local test records you need before accepting a reset.
curl http://localhost:4000/products
curl -X POST http://localhost:4000/products \
-H 'content-type: application/json' \
-d '{"name":"Mechanical Keyboard","price":89.99,"inStock":true}'Troubleshooting
If the port is already in use, pass --port with a free port or change the project setting. If the token is invalid or expired, run npx mock-api-studio-cli logout and start again with a fresh token. If no resources load, confirm that the project has a valid endpoint response with a MockApiStudioResponse binding.
The CLI connects to https://api.mockapistudio.dev by default. MOCK_API_BASE_URL exists for local product development and should not normally be needed by users of the hosted service.
Related questions
Do I need to install the CLI globally?
No. npx mock-api-studio-cli runs the package directly. A global install is optional and exposes the mock-api-studio command.
Where does the local database live?
The runtime creates .mock-api-studio/<project-slug>.db under the directory where the CLI is launched.
How do I update a running project?
Save the changes in the dashboard and restart the CLI so it synchronizes the current project definition.
Keep exploring
Last updated September 17, 2026. Product behavior described here is verified against the current Mock API Studio runtime.