Guides

Seed a Mock Library

Import a HAR, Postman collection, or OpenAPI spec to start a service's mock library before you record traffic through Gostly. Seeding imports HTTP request and response examples. Review the imported routes, switch the service to MOCK mode, and check representative requests with your application.

Import one example by format

Choose a walkthrough for a downloadable synthetic input, target-service setup, format-specific warnings and a reader-owned replay assertion. Use the shared procedures and data-handling contract below for all three formats.

The empty-library problem

Recording in LEARN mode needs traffic you can send to an upstream. Seeding gives you a starting library when you already have captures or examples. Imported rows use the same mock library as recorded traffic and carry a source tag of seed_har, seed_postman, or seed_openapi. That common storage format does not establish response accuracy or coverage.

HAR

Captured HTTP exchanges

HAR 1.2 JSON with request URLs, textual request bodies, response statuses, headers, and captured response text. A capture may include sign-in pages, throttling, or unrelated hosts. Import does not preserve timings, WebSocket frames or streaming behavior. Binary response content needs a separate replay check.

Postman

Saved examples

Collection v2.0 or v2.1 JSON. Each saved response example becomes a candidate mock. A request with no saved response gets an empty 200 response and a warning. Import does not execute requests, scripts, tests, or authentication flows.

OpenAPI

Examples and representative responses

OpenAPI 3.x JSON or YAML. Response examples take precedence over response schema synthesis. An operation that declares requestBody needs an explicit supported JSON example; otherwise the entire operation is omitted with a warning.

Postman folders are flattened. Collection variables, the API's environment overlay, and nested folder variables resolve placeholders in request URLs and bodies. Folder variables can override the inherited scope. Unresolved variables remain literal and are reported. Response bodies and headers are not variable-interpolated, and auth blocks do not generate request authentication. Form and multipart request bodies receive a best-effort textual representation; attached files are not migrated.

OpenAPI selects one response media type per response code, preferring common JSON media types. Within that media type, it tries the first named examples entry in sorted order, then a media-level example, then the response schema. The schema walk uses literal examples or defaults before representative values, merges allOf, and selects one oneOf / anyOf branch. It does not import every named example or prove realistic values, distributions, or complete schema validation. Only local references are resolved; external reference URLs are not fetched. A default response is stored as status 500, and a wildcard such as 2XX becomes 250. Check these representative statuses before relying on them in a test.

For a declared OpenAPI request body, the selected JSON media type must provide a named example value, a media-level example, or a schema-level example. The value must encode as valid, finite JSON in at most 8 KiB of canonical UTF-8 JSON. Request schema shapes, defaults, enums, and property-level examples do not generate a request body. An unusable selected named example does not fall through to another example. Missing, unsupported, invalid, oversized, or unresolved request examples omit every response row for that operation. Operations without requestBody use an empty request body.

OpenAPI path substitution reads operation-level path parameters, using a parameter example or its schema example/default. Path-item-level parameters are not applied by this substitution. Unresolved {parameter} placeholders remain in the URI. The optional prepend_basepath setting adds the path from the first top-level servers URL; check that it matches the path your client sends. Callbacks are not imported.

Seeding from the dashboard

Open /seed in your local operator dashboard. Select an existing service and import one file:

Drop a file

Drag a .har, .json, .yaml, or .yml file onto the drop zone, or browse for it. The staged view shows its name and size; it is not a dry run of the imported operations.

Pick a service

Choose the service whose library will receive the mocks. Create it first if needed. For HAR imports, check its upstream host before committing.

Pick a format

Choose HAR, Postman, or OpenAPI 3.x. The dashboard labels Postman as v2.1; the parser also accepts v2.0. JSON shape detection runs only when no format is selected and the file is at most 5 MiB. Choose YAML and larger files manually.

Commit seed

The dashboard uploads the file and shows the added count, duplicate count, parser warnings, and sample routes. Inspect warnings before checking the imported behavior in MOCK mode.

An Advanced options drawer exposes the deduplication setting, plus OpenAPI 2xx only and prepend basePath toggles. Deduplication defaults on; both OpenAPI toggles default off. Postman environment overlays, HAR method/status filters, and the options to retain other hosts or flagged responses are API-only.

The seeding endpoint

The dashboard uses the same authenticated control-plane endpoint you can call directly:

POST /v1/seed/{format}?service_id=<id>&dedup=true
# format: har, postman, or openapi

Use an authenticated member session or an API key in X-API-Key. Send a multipart file field, an inline JSON document with Content-Type: application/json, or raw file bytes. For YAML OpenAPI, use application/yaml. The application/octet-stream transport does not add support for binary mock response fidelity. This endpoint imports an uploaded document; it does not fetch a source URL.

# Seed a service's library from a HAR export
curl -X POST 'http://localhost:8000/v1/seed/har?service_id=svc-payments' \
  -H "X-API-Key: $GHOST_API_KEY" \
  -F 'file=@session.har'

# Seed from an OpenAPI spec, keeping only 2xx responses
curl -X POST 'http://localhost:8000/v1/seed/openapi?service_id=svc-payments&success_only=true' \
  -H "X-API-Key: $GHOST_API_KEY" \
  -H 'Content-Type: application/yaml' \
  --data-binary @openapi.yaml

The response reports stored rows, duplicate rows dropped within this upload, warnings, up to five sample routes, and a flagged list for the captured-response screen. For example:

For a named import source, also review the added, updated, removed and kept rows. Reimporting synchronizes the rows owned by that source; it does not replace the whole service library. Inspect those changes before reloading or repeating an import.

{
  "format": "har",
  "count": 2,
  "deduped": 1,
  "service_id": "svc-payments",
  "warnings": [],
  "errors": [],
  "sample_uris": ["GET /v1/charges", "GET /v1/customers/42"],
  "flagged": []
}

On the OSS proxy

These instructions describe the licensed self-hosted product's dashboard and control-plane API. The separate open-source proxy has its own CLI and documentation.

Per-format options

All formats require service_id. Use options for their documented format; a valid option for another format has no effect on its parser, though malformed query values can still be rejected.

dedupAll formats

Default true. Keep the first row with each combination of method, exact URI, response status, and response-body text within this request. The key ignores request bodies and all headers, so distinct request examples can collapse. Different JSON whitespace can prevent collapse. Existing stored rows are not checked; importing the same file again can add rows.

methods / statusesHAR only

Comma-separated allow-lists, such as methods=GET,POST or statuses=200,201,204.

keep_other_hostsHAR only · API-only

Default false. Retain the service's upstream host; if it has no readable host, use the most frequent host in the file, with first-seen order breaking a tie. No subdomain wildcard is applied; a configured upstream port is also checked. Relative URLs and reserved .invalid hosts remain eligible. Other hosts are reported in warnings. true retains them for response screening too.

keep_flaggedHAR / Postman · API-only

Default false. Skip detected bot challenges, sign-in pages/redirects, rate limits, and errors carried in a 2xx body. Ordinary error fixtures such as JSON 401, 404, or 500 responses can remain. Flagged exchanges are listed with the reason and action; true retains them before deduplication. This screen does not apply to OpenAPI rows and is not a general content-safety check.

environmentPostman only

A URL-encoded JSON object such as {"baseUrl":"https://api.example.invalid"}, overlaid on collection variables before nested folder variables are applied. This is not a Postman environment-file upload.

success_onlyOpenAPI only

Default false. Omit non-2xx response rows. One response media/example is selected for each retained response code; all named examples are not imported.

prepend_basepathOpenAPI only

Default false. Prefix imported URIs with the path component of the first top-level servers[0].url.

What happens on import

Import prepares the rows, applies the format's filters, and stores them before asking the proxy to reload:

Parse and filter

Convert source examples to method, URI, request body, response status, response headers, and response body. HAR host filtering runs before HAR/Postman response screening. Recoverable entry-level issues produce warnings; invalid documents can reject the upload. HAR timing is not replayed, and seeded latency is zero. Source request headers are not persisted as matching rules.

Dedup

Unless dedup=false, collapse later duplicate rows within the parsed upload. First-occurrence order is preserved. This parsing step is separate from synchronizing the rows owned by a named import source.

Redact and persist

Apply structural credential redaction and the sensitive response-header floor before writing the mock rows and their content revisions to Postgres. The serving JSONL is derived from those redacted rows. Rows are bound to the selected service and tagged source=seed_{format}.

Reload

Ask the proxy to reload. A network or timeout failure is logged without rolling back stored rows. If the proxy explicitly rejects the reload, the API returns 502: the rows are stored but the current serving library was retained. Restore connectivity or resolve the rejection and reload before checking the new mocks.

A stored-row count does not prove the mocks are live. After a successful reload, switch the service to MOCK mode and verify representative requests, including their status, body, and any headers your client depends on. Multiple response examples do not automatically become an ordered scenario or migrated assertion suite.

Errors and warnings

Request and reload errors have different implications for stored rows:

400

Unsupported format, unreadable upload, or malformed query values such as a non-integer statuses value.

413

OpenAPI document exceeds the admission byte limit.

422

Unknown service for the current tenant, empty/malformed input, or OpenAPI content rejected by the parser/admission policy. OpenAPI uploads accept absent Content-Encoding or one identity encoding, not compressed documents.

502

Rows were stored, but the proxy explicitly rejected the reload. Check the import-source changes and current serving state before rerunning; this response does not roll back stored rows.

503

OpenAPI parsing capacity or parser isolation is unavailable; the response includes Retry-After.

Warnings describe omitted or approximated content: skipped HAR WebSocket entries, other hosts, flagged responses, unresolved Postman variables, selected OpenAPI branches, unsupported external references, or omitted request-body operations. A successful import can contain fewer routes than the source document. Inspect the warnings and the resulting library.

A note on the data you import

Review the source file before upload. Source files, including HAR and Postman exports, can contain sensitive request headers, query parameters, request bodies, response headers, and response bodies. The authenticated API receives that file before persistence redaction runs. Remove credentials and personal data you do not want submitted, including values outside the imported fields.

Before persistence, structural rules replace detected credential values in URI queries/fragments, request and response bodies, and response header values. The response-header floor also replaces sensitive named headers such as Authorization, Cookie, Set-Cookie, and API-key headers with [REDACTED]. Cookie evidence and, for HAR, response-to-later-request relationships help identify credentials. Request headers are not stored as mock matching rules.

This is not a general PII scrubber or pre-upload sanitizer. Names, emails, IDs, path segments, short secrets, and values outside the credential rules can remain. Import results and warnings are not a privacy review or a redaction receipt. Inspect the file before upload and the stored library before sharing or using it with another service.

Self-hosted, single-tenant

The self-hosted deployment stores seeded rows in its configured Postgres database and serving volume. Storage location alone does not describe every external connection: review upstream routing, model integrations, telemetry settings, and your own export/sharing workflow. See the redaction reference for the separate capture settings and header rules.

Next steps