moqapi.dev Documentation — Mock APIs, Functions & API Gateway
Everything you need to build, deploy, and manage serverless functions and mock APIs. Every code sample below is copy-paste ready.
// Quick Start
1. Create a function → paste the code below
2. Click "Test" with the test payload
3. Click "Publish" → create an API route for it
4. Call it via curl or from your frontend
// Paste this into a new function
export const handler = async (event) => {
const name = event.body?.name || 'World';
return {
statusCode: 200,
body: {
message: 'Hello, ' + name + '!',
timestamp: new Date().toISOString(),
method: event.httpMethod || 'INVOKE'
}
};
};{ "body": { "name": "Alice" } }# After publishing and binding to GET /hello
curl https://moqapi.dev/api/invoke/{projectId}/fn/hello// Mock API Quick Start
1. Create a Mock API → click "Import OpenAPI"
2. Paste the URL below (or any Swagger/OpenAPI URL)
3. All endpoints and resources are created automatically
4. Generate fake data → start calling your API
# Import Petstore spec (paste this URL in the Import dialog)
https://petstore3.swagger.io/api/v3/openapi.json
# Then call your mock API (replace with your project ID and base path)
curl https://moqapi.dev/api/invoke/{projectId}/pets-api/pets
curl https://moqapi.dev/api/invoke/{projectId}/pets-api/pets/1
curl -X POST https://moqapi.dev/api/invoke/{projectId}/pets-api/pets \
-H "Content-Type: application/json" \
-d '{"name":"Buddy","status":"available"}'Serverless Functions
Write, test, and deploy functions with a browser IDE. Stripe webhooks, CSV parsing, API proxies — all working examples inside.
API Gateway
Expose functions as REST endpoints. Full CRUD API example with route config, function code, and curl commands.
Import YAML (Spec Mocks)
Upload OpenAPI 3.x or Swagger 2.0 specs. Smart routing for parameterized paths, query filters, and spec-defined error responses.
Import Table (Resource Mocks)
Define resources visually with a table editor. Auto-generated CRUD endpoints with Faker.js data — no code needed.
Spec Versioning
Version-control specs with R2 storage. Rollback, inspect, and activate any version instantly.
AI Data Generation
Seed mock data with Gemini AI or Faker.js. Context-aware generation that understands your schema and business domain.
Layers (Dependencies)
Reusable code packages for functions. CSV parser, Stripe helpers, DB pool — full layer code + function usage examples.
Webhooks
Push notifications to Slack, Discord, or any API. Complete payload examples for each platform, ready to paste.
Cron Jobs
Schedule functions with cron expressions. DB cleanup, health checks, data sync, daily reports — all with working code.
Unified Logging
Monitor API calls, mock requests, webhook deliveries, cron executions, and function invocations in one log viewer.
Chaos Testing
Inject HTTP error responses to stress-test frontend resilience. Configure error rate, pick error codes, and use spec-defined error shapes for Import YAML APIs.
Teams & Access Control
Invite teammates, share projects with your team, set project and endpoint visibility (private/public/moqapi users), and authenticate external callers with API keys.
Contract Drift Detection
AI-powered comparison of your mock API responses against live production endpoints. Detect schema drift, missing fields, type mismatches, and breaking changes automatically.
Auth Sandbox
Test OAuth 2.0, PKCE, JWT, API Key, Basic Auth, and MFA flows without a real identity provider. Full OIDC discovery, token introspection, and configurable error simulation.