Back to Docs

Config Reference

Every yapi request file starts with yapi: v1. This page lists all available fields.

Project Layout

Place a yapi.config.yml at your project root to define environments and base URLs. Request files (.yapi.yml) can live anywhere beneath it — yapi walks up the directory tree to find the nearest config.

my-project/
ā”œā”€ā”€ yapi.config.yml          # project config (environments, base URLs)
└── yapi/
    ā”œā”€ā”€ homepage.yapi.yml    # GET /
    ā”œā”€ā”€ sitemap.yapi.yml     # GET /sitemap.xml
    └── health.yapi.yml      # GET /healthz

Example: yapi.config.yml

yapi: v1

default_environment: local

environments:
  local:
    url: http://localhost:3000
  prod:
    url: https://api.example.com

Example: yapi/homepage.yapi.yml

yapi: v1
path: /
method: GET

headers:
  User-Agent: yapi-cli

expect:
  status: 200

Because the request file uses path: / instead of a full url, yapi resolves it against the active environment's base URL. Running yapi run yapi/homepage.yapi.yml hits http://localhost:3000/ by default, or https://api.example.com/ with -e prod.

Request Fields

FieldTypeDescription
yapistringRequired. Version tag. Always v1.
urlstringFull request URL
pathstringPath appended to environment base URL
methodstringHTTP method: GET, POST, PUT, PATCH, DELETE
headersmapRequest headers
querymapQuery parameters
timeoutstringRequest timeout (e.g., "4s", "100ms")
delaystringWait before executing (e.g., "5s")
insecureboolSkip TLS verification

url and path are mutually exclusive. Use path when yapi.config.yml provides a base URL.

Body Fields

These are mutually exclusive — use only one:

FieldTypeDescription
bodymapJSON object body
jsonstringRaw JSON string body
formmapForm-encoded body

Response Processing

FieldTypeDescription
jq_filterstringJQ expression to transform response
output_filestringSave response body to file
content_typestringOverride content type

GraphQL Fields

FieldTypeDescription
graphqlstringGraphQL query or mutation
variablesmapGraphQL variables

gRPC Fields

FieldTypeDescription
servicestringgRPC service name
rpcstringRPC method name
protostringPath to .proto file
proto_pathstringProto import path
plaintextboolNo TLS for gRPC

TCP Fields

FieldTypeDescription
datastringRaw data to send
encodingstringtext (default), hex, base64
read_timeoutintSeconds to wait for response
idle_timeoutintMilliseconds before response is considered complete
close_after_sendboolClose connection after sending

Testing Fields

FieldTypeDescription
expectobjectStatus and assertion expectations
expect.statusint/[]intExpected status code(s)
expect.assertlist/mapBody and header assertions
wait_forobjectPolling configuration
chainlistMulti-step request chain

Environment Fields

FieldTypeDescription
env_files[]stringPaths to .env files to load

Project Config (yapi.config.yml)

FieldTypeDescription
default_environmentstringEnvironment used without -e
defaults.varsmapVariables for all environments
environmentsmapEnvironment definitions
environments.{name}.urlstringBase URL
environments.{name}.varsmapEnvironment-specific variables
environments.{name}.env_filestring.env file path

See Also

  • yapi docs protocols — Protocol-specific details and examples
  • yapi docs variables — Variable interpolation
  • yapi docs assert — Assertion syntax