A mock server from your spec, or from your own code
Publish a mock from any commit of your repository and call it at its own URL on APIGit Cloud. Spec-based mocks answer from OpenAPI documents and GraphQL schemas with no scripts. Code-based mocks run your Express.js scripts when responses need logic and state.
Spec-based mocks are on every plan, including Free. Nothing to host.
$ curl https://petstore-sandbox.mockserver.apigit.com/api/v3/pet/1 \ -H 'api_key: anything'{"id":10,"name":"doggie","category":{"id":1,"name":"Dogs"}, "photoUrls":["string"],"tags":[{"id":0,"name":"string"}],"status":"available"} $ curl -i https://petstore-sandbox.mockserver.apigit.com/api/v3/pet/1 \ -H 'api_key: anything' -H 'Prefer: code=404'HTTP/2 404content-type: application/jsonTwo types, one way to publish
Start spec-based for a working mock with no code. Publish a code-based mock when responses depend on earlier requests. A mock server is one type or the other, and one repository can publish several of each, even from the same commit.
| Property | Spec-based | Code-based |
|---|---|---|
| Source | OpenAPI documents and complete GraphQL schemas | Your scripts in apigit-mock/ |
| You write | Nothing beyond the document | JavaScript, on Express.js |
| Responses | OpenAPI examples or generated bodies; GraphQL values shaped by the schema | Whatever your code returns |
| Request validation | OpenAPI checks you can switch; GraphQL queries checked against the schema | Your own code |
| Stays in step with the spec | Always: the document is the mock | Up to you: regenerate or edit the scripts |
| State between requests | No | Yes, in the state object |
| Several APIs on one mock | Yes, each document under its own base path | One Express app |
| Plans | Free, Team, Enterprise | Team, Enterprise |
Spec-based: the document is the mock
Pick the documents, deploy, and the mock is live. There is no generated code to maintain, so the mock cannot drift from the spec.
Answers from your OpenAPI document
Each request is matched to an operation. The answer is your example, or a body generated from the schema when there is none. The same document and the same request always give the same answer, so tests stay stable.
- OpenAPI 3.0 and 3.1 in YAML or JSON, and Swagger 2.0
- Split documents: local
$reffiles are collected with the document - Cross-origin requests from a browser work

Validation, and the response you ask for
The mock checks parameters, the request body and the presence of the credentials the document requires, and says exactly what is wrong. A Prefer header asks for a declared status, a named example or random realistic values, so your client's error handling gets tested too.
- Switch each check per document, or per request
- Errors are application/problem+json (RFC 9457), easy to tell from your API's own responses
- The Prefer conventions of Prism, so tests written for it carry over
$ curl https://petstore-sandbox.mockserver.apigit.com/api/v3/pet/abc \ -H 'api_key: anything'{ "type": "https://apigit.com/mock/problems/invalid-request", "title": "The request does not match the API description", "status": 422, "detail": "The request does not match getPetById: path petId: must be integer", "errors": [ { "in": "path", "name": "petId", "message": "must be integer" } ]}Several APIs on one mock server
Mount each document under its own base path, taken from its servers URL or set by you. Documents never share routes, so two APIs can both declare /pets. Add or remove documents, edit base paths and switch validation on the Setting page, without a republish.
- The longest matching base path wins
- One document on Free, up to 10 on Team and Enterprise
GET /apigit-mockserver-routeslists every document and operation
https://petstore-sandbox.mockserver.apigit.com
├── /pets/v3 openapi/petstore.yaml
├── /orders/v2 openapi/orders.yaml
└── /graphql schema.graphql
GraphQL, from a schema file
Select a complete SDL schema as one more document of the mock. It answers queries and mutations at /graphql, validates each query against the schema and returns values in the shape you selected. Repeating a request gives the same values.
- Introspection is supported
- An argument that matches a returned field is echoed
- Shares access control, quota and logs with the OpenAPI documents of the mock
$ curl https://catalog-sandbox.mockserver.apigit.com/graphql \ -H 'Content-Type: application/json' \ --data '{"query":"query Product($id: ID!) { product(id: $id) { id name price } }","variables":{"id":"42"},"operationName":"Product"}'{ "data": { "product": { "id": "42", "name": "Example", "price": 1.5 } }}Code-based: real logic in Express.js
When a response depends on earlier requests, write it. APIGit creates an Express.js 4 app, loads apigit-mock/main.js from the published commit and serves it at the mock's URL. Team and Enterprise plans.
Routes, middleware and state
mock is the Express app, so mock.get(), mock.post() and mock.use() work as documented by Express. JSON, URL-encoded and text bodies and cookies are parsed before your code runs. What you store in state is kept between requests.
- Multi-step scenarios: a checkout, an OAuth flow, a computed price
- Generate the routes from an API document, then edit them
- console.log output appears beside the request in the logs
mock.get('/users/:name', (req, res) => {
res.json({ name: req.params.name, createdAt: new Date().toISOString() });
});
mock.post('/users', (req, res) => {
state.users = state.users || [];
state.users.push(req.body);
res.status(201).json({ count: state.users.length });
});State
Plain JSON, up to 2 MB, kept when the mock is overwritten or follows a branch. Inspect it in the State view.
Libraries
Faker 9.9.0, lodash, jsonwebtoken, ajv, moment, uuid, validator and more are pre-installed. Load them with require.
Modules
Split handlers, models and helpers into files under apigit-mock/ and require them from main.js.
Sandbox
Each mock runs in its own isolated environment, with no network access and no cloud credentials.
Pin it to a commit, or follow a branch
A mock server always serves one commit. You decide how that commit changes, and who can call the mock.
An update strategy for each mock
Pin a mock to keep a release or a partner sandbox stable. Or follow a branch on a paid plan: a push, a merged pull request, a file saved in the editor or a mirror sync republishes it. Publish from the application, or from a terminal or CI with apigit mock publish.
- The URL, the access token and the state stay across updates
- If an update cannot be published, the mock keeps serving its last good commit
- Publish from a branch, from any commit in the history, or while editing

Access control and request logs
A mock is public, or requires an access token sent in the APIGIT-Token header or as a query parameter. The Logs view shows every request with its method, path, status and time, and the response. Credentials are removed from the logs.
- Change the access setting or regenerate the token at any time
- Republishing keeps the token
- Read the log from a terminal with
apigit mock logs

Try it on your machine first
The apigit CLI runs both types locally, offline and without a login, on the engines of the hosted mock servers. The mock listens on 127.0.0.1:4010 and follows your edits without a restart, so you or your coding agent can try a change before it is committed.
- Spec-based: the same routing, validation, examples and Prefer header
- Code-based: the same Express app, mock, state and library versions
- Local state starts empty, and there is no token, quota, log or sandbox
$ npm install -g @apigit/cli$ apigit mock serve openapi.yaml$ apigit mock serve schema.graphql$ apigit mock serve apigit-mockAn OpenAPI file, a GraphQL schema at /graphql (CLI 0.7.0 or later), and the folder of a code-based mock.
What each plan includes
Mock server counts and monthly calls belong to the account, not to a seat.
| Feature | Free | Team | Enterprise |
|---|---|---|---|
| Spec-based mocks | Yes | Yes | Yes |
| Code-based mocks | No | Yes | Yes |
| Follow a branch | No | Yes | Yes |
| Documents per mock server | 1 | 10 | 10 |
| Mock servers | 1 | Unlimited | Unlimited |
| Calls a month, for the account | 1,000 | 20,000 | 100,000 |
| Choose the mock server's name | No | No | Yes |
Paid plans can add call packs: $20 per 50,000 calls a month. AsyncAPI documents are not mock inputs. See pricing
Give your team an API to build against today
Create a free workspace and publish a mock server from an OpenAPI document or a GraphQL schema. No scripts to write.
Free for individuals. No credit card.
$ npm install -g @apigit/cli$ apigit auth login$ apigit doc publish