Using mock servers
Use a contract mock server to try the published API shape before connecting to the real service. Responses come from the published contract's schemas and examples.
Enable and publish
Open the contract's Publishing step and enable Mock Server. Review the consumer-facing endpoints, response schemas, and example data, then publish the contract. Copy the returned mock base URL. The contract must be active and published.
The mock URL is public and does not require upstream credentials. Mock Server is a separate opt-in from public OpenAPI/Postman sharing. Turning off public artifacts alone does not disable an enabled mock server.
Call a templated endpoint
curl -i 'https://api.getelva.ai/api/public/contracts/CONTRACT_ID/mock/orders/test-order-123'
Use your copied base URL and an operation your contract exposes, such as GET /orders/{orderId}. Replace the template parameter with an example value. The x-mock-matched-path response header identifies the published template used for the request.
Choose a documented response
curl -i 'https://api.getelva.ai/api/public/contracts/CONTRACT_ID/mock/orders/test-order-123?__status=404'
curl -i 'https://api.getelva.ai/api/public/contracts/CONTRACT_ID/mock/orders/test-order-123' \
-H 'x-mock-status: 404'
A status override is honored only when that operation documents that exact response code. Otherwise the mock uses its normal response selection: the lowest documented success response, then default. If neither exists, it returns an empty 200 response. An unknown method or path returns 404.
Understand the result
Schema examples and defaults take precedence; otherwise the mock synthesizes representative values. It does not implement persistent state, business rules, upstream authentication, or tenant authorization. A successful mock call verifies a documented shape, not production behavior.
The mock serves the last published snapshot. Draft edits and source changes do not change responses until the contract is published again. Remove real credentials and private customer data from examples before enabling public access.
For a 404, check the contract ID, publication state, Mock Server setting, request method, and exact published path. To stop public mock responses, disable Mock Server for the contract.
On this page
- Using mock servers