.nap Files (spec: nap-file)
A .nap file defines a single HTTP request with optional metadata, headers, body, assertions, and script hooks.
Minimal format (spec: nap-minimal)
The simplest possible .nap file is just a method and URL:
GET https://api.example.com/health
Full format (spec: nap-full)
[meta]
name = Get user by ID
description = Fetches a single user and validates the response
tags = users, smoke
[vars]
userId = 1
[request]
GET {{baseUrl}}/users/{{userId}}
[request.headers]
Authorization = Bearer {{token}}
Accept = application/json
[assert]
status = 200
body.id = {{userId}}
body.name exists
body.email exists
duration < 1000ms
[script]
post = ./scripts/log-response.fsx
Sections
[meta] (spec: nap-meta)
Optional metadata about the request.
| Field | Description |
|---|---|
name |
Human-readable name displayed in explorers |
description |
Longer description for documentation |
tags |
Comma-separated tags for filtering |
[vars] (spec: nap-vars)
Local variable defaults. These are overridden by environment files and CLI flags.
userId = 1
baseUrl = https://api.example.com
[request] (spec: nap-request)
The HTTP method and URL. This is the only required part of a .nap file.
GET {{baseUrl}}/users/{{userId}}
Supported methods: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS (spec: http-methods).
[request.headers] (spec: nap-headers)
Key-value pairs for HTTP headers. Variables are interpolated.
Authorization = Bearer {{token}}
Content-Type = application/json
X-Custom-Header = {{customValue}}
[request.body] (spec: nap-body)
Request body for POST, PUT, and PATCH requests. Content is wrapped in triple quotes:
[request.body]
"""
{
"name": "Ada Lovelace",
"email": "ada@example.com"
}
"""
[assert] (spec: nap-assert)
Declarative assertions on the response. See Assertions for the full reference.
[script] (spec: nap-script)
References to F# or C# scripts that run before or after the request.
[script]
pre = ./scripts/setup.fsx
post = ./scripts/validate.csx
See F# Scripting and C# Scripting for details.
Variable interpolation (spec: env-interpolation)
Use {{variableName}} anywhere in the request. Variables are resolved from (highest priority first):
- CLI
--var key=valueflags .napenv.local(gitignored secrets).napenv.<name>(named environment).napenv(base environment)[vars]in the.napfile
Comments (spec: nap-comments)
Lines starting with # are comments:
# This is a comment
[request]
GET https://api.example.com/health