Mock Server

Create mock API endpoints with custom responses, status codes, and headers. Perfect for frontend development, API testing, and prototyping before backend implementation.

Quick Access: Manage your mock endpoints in the VerveKit Dashboard.

Features

  • All HTTP Methods: Support for GET, POST, PUT, DELETE, and PATCH
  • Custom Responses: Define exactly what your endpoint returns
  • Status Codes: Configure any HTTP status code (200, 404, 500, etc.)
  • Custom Headers: Add custom headers to responses
  • CDN Delivery: Responses served via Google Cloud Storage CDN
  • Usage Analytics: Track endpoint access counts
  • CORS Support: Built-in CORS headers for frontend integration

Use Cases

Use CaseDescriptionBest For
Frontend DevelopmentDevelop and test frontend applications before the backend is readyUI development, parallel development workflows
API TestingTest error handling and edge cases with different status codes and responsesQA testing, error scenarios, integration testing
Client DemosCreate demo endpoints to showcase API behavior and capabilities to clientsSales demos, proof of concepts, presentations
DocumentationProvide live, working examples in API documentation and tutorialsDeveloper docs, guides, interactive examples
API PrototypingQuickly prototype API endpoints to validate design and contractsAPI design, contract testing, stakeholder review
Third-Party SimulationSimulate third-party API responses for development and testingExternal API mocking, offline development

Creating a Mock Endpoint

Via Dashboard

  1. Sign in to your APIVerve Dashboard
  2. Navigate to VerveKit → Mock Server
  3. Click "Create New Endpoint"
  4. Configure your endpoint:
    • Name: Descriptive name for the endpoint
    • HTTP Method: GET, POST, PUT, DELETE, or PATCH
    • Status Code: HTTP status code to return (e.g., 200, 404, 500)
    • Response Body: JSON or text response
    • Headers: Optional custom headers
  5. Click "Save" to create your endpoint

Response Validation: If your response is JSON, it will be validated before saving. For non-JSON responses, it will be returned as plain text.

Configuration Options

HTTP Methods

Choose from the following HTTP methods:

  • GET: Retrieve data (most common for mock endpoints)
  • POST: Submit data (simulate resource creation)
  • PUT: Update data (simulate full resource update)
  • PATCH: Partial update (simulate partial resource update)
  • DELETE: Delete data (simulate resource deletion)

Method Validation: Requests must match the configured HTTP method. A GET endpoint will reject POST requests with 405 Method Not Allowed.

Status Codes

Common status codes you can configure:

  • 200: OK - Successful request
  • 201: Created - Resource created successfully
  • 400: Bad Request - Invalid request data
  • 401: Unauthorized - Authentication required
  • 403: Forbidden - Access denied
  • 404: Not Found - Resource doesn't exist
  • 500: Internal Server Error - Server error
  • 503: Service Unavailable - Service temporarily down

Custom Headers

Add custom headers to your responses:

Custom Headers
{
  "Content-Type": "application/json",
  "X-Custom-Header": "CustomValue",
  "Cache-Control": "no-cache"
}

CORS Headers: The following CORS headers are automatically added:Access-Control-Allow-Origin: *,Access-Control-Allow-Methods: [your method],Access-Control-Allow-Headers: Content-Type, Authorization, x-api-key

Accessing Your Endpoint

Once created, your mock endpoint is immediately available:

Endpoint URL
https://api.apiverve.com/v1/mockserver/{endpointId}

Finding Your Endpoint ID: The endpoint ID is displayed in your dashboard. You can copy the complete URL directly from there.

Authentication

Include your API key in the request header:

  • Header: x-api-key
  • Location: HTTP headers
  • Required: Yes
Authentication Header
x-api-key: YOUR_API_KEY

HTTP Method

The request must match the configured HTTP method for the endpoint.

Code Examples

GET Request (cURL)

cURL GET Request
curl "https://api.apiverve.com/v1/mockserver/abc123" \
  -H "x-api-key: YOUR_API_KEY"

POST Request (cURL)

cURL POST Request
curl -X POST "https://api.apiverve.com/v1/mockserver/abc123" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"key": "value"}'

JavaScript (Fetch API)

JavaScript Fetch API
const apiKey = 'YOUR_API_KEY';
const endpointId = 'abc123';

fetch(`https://api.apiverve.com/v1/mockserver/${endpointId}`, {
  headers: {
    'x-api-key': apiKey
  }
})
  .then(response => {
    console.log('Status:', response.status);
    return response.json();
  })
  .then(data => {
    console.log('Response:', data);
  })
  .catch(error => {
    console.error('Error:', error);
  });

JavaScript (POST with Fetch)

JavaScript POST with Fetch
const apiKey = 'YOUR_API_KEY';
const endpointId = 'abc123';

fetch(`https://api.apiverve.com/v1/mockserver/${endpointId}`, {
  method: 'POST',
  headers: {
    'x-api-key': apiKey,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ key: 'value' })
})
  .then(response => response.json())
  .then(data => console.log('Response:', data))
  .catch(error => console.error('Error:', error));

Python (requests)

Python with requests
import requests

api_key = 'YOUR_API_KEY'
endpoint_id = 'abc123'
url = f'https://api.apiverve.com/v1/mockserver/{endpoint_id}'
headers = {'x-api-key': api_key}

# GET request
response = requests.get(url, headers=headers)
print(f'Status: {response.status_code}')
print(f'Response: {response.json()}')

# POST request
response = requests.post(
    url,
    headers=headers,
    json={'key': 'value'}
)
print(f'Response: {response.json()}')

Node.js (axios)

Node.js with axios
const axios = require('axios');

const apiKey = 'YOUR_API_KEY';
const endpointId = 'abc123';
const url = `https://api.apiverve.com/v1/mockserver/${endpointId}`;
const headers = { 'x-api-key': apiKey };

// GET request
axios.get(url, { headers })
  .then(response => {
    console.log('Status:', response.status);
    console.log('Data:', response.data);
  })
  .catch(error => console.error('Error:', error));

// POST request
axios.post(url, { key: 'value' }, { headers })
  .then(response => console.log('Data:', response.data))
  .catch(error => console.error('Error:', error));

Example Scenarios

Success Response (200)

Mock a successful API response:

Success Response Example
{
  "status": "success",
  "data": {
    "id": 123,
    "name": "Product Name",
    "price": 29.99,
    "inStock": true
  },
  "message": "Product retrieved successfully"
}

Error Response (404)

Mock a resource not found error:

404 Not Found Example
{
  "status": "error",
  "code": "NOT_FOUND",
  "message": "The requested resource was not found",
  "timestamp": "2024-01-01T12:00:00Z"
}

Validation Error (400)

Mock a validation error:

Validation Error Example
{
  "status": "error",
  "code": "VALIDATION_ERROR",
  "message": "Invalid request data",
  "errors": [
    {
      "field": "email",
      "message": "Email is required"
    },
    {
      "field": "password",
      "message": "Password must be at least 8 characters"
    }
  ]
}

Server Error (500)

Mock a server error:

Server Error Example
{
  "status": "error",
  "code": "INTERNAL_ERROR",
  "message": "An unexpected error occurred",
  "requestId": "abc-123-def"
}

Rate Limits & Pricing

Free Plan

  • Daily Limit: 100 requests per endpoint per day
  • Reset: Daily at midnight UTC
  • Endpoints: Unlimited endpoints, 1MB per response max

Paid Plans

  • Requests: Unlimited (based on your API token balance)
  • Token Cost: Requests do NOT consume tokens
  • Endpoints: Unlimited endpoints, 1MB per response max

Managing Your Endpoints

Edit Endpoint

Update your mock endpoint configuration:

  1. Navigate to Mock Server in your dashboard
  2. Click Edit next to your endpoint
  3. Modify method, status code, response, or headers
  4. Click Save

URL Persistence: Editing an endpoint does NOT change its URL. Existing integrations will automatically receive the updated configuration.

Delete Endpoint

  1. Navigate to Mock Server in your dashboard
  2. Click Delete next to your endpoint
  3. Confirm the deletion

Permanent Action: Deleting an endpoint is permanent. The URL will no longer be accessible.

View Analytics

Track usage for each endpoint:

  • Total Access Count: Total number of requests
  • Daily Access Count: Requests today (for free plan tracking)
  • HTTP Method: Configured method
  • Status Code: Configured status code

Error Responses

400 Bad Request

400 Bad Request Response
{
  "status": "error",
  "error": "Endpoint ID is required"
}

404 Not Found

404 Not Found Response
{
  "status": "error",
  "error": "Mock endpoint not found"
}

405 Method Not Allowed

405 Method Not Allowed Response
{
  "status": "error",
  "error": "Method not allowed. Expected POST, got GET"
}

429 Too Many Requests

429 Too Many Requests Response
{
  "status": "error",
  "error": "Daily access limit exceeded (100 requests per day for free plan)",
  "requiresUpgrade": true
}

500 Internal Server Error

500 Internal Server Error Response
{
  "status": "error",
  "error": "Failed to fetch mock response"
}

Best Practices

  • Realistic Responses: Create responses that match your actual API structure
  • Status Codes: Use appropriate status codes for different scenarios
  • Headers: Include relevant headers (Content-Type, Cache-Control, etc.)
  • Error Testing: Create endpoints with error responses to test error handling
  • Documentation: Use descriptive names to document the purpose of each endpoint
  • Size Limit: Keep responses under 1MB for optimal performance
  • Method Matching: Ensure your client uses the correct HTTP method

Testing Tip: Create multiple endpoints with different status codes to thoroughly test your application's error handling.

Need Help?

Was this page helpful?

Help us improve our documentation