Direct Response

Return a fixed HTTP response without contacting any upstream. Vrata answers immediately from the proxy itself — no backend is involved.

Configuration

{
  "name": "maintenance-page",
  "match": {"pathPrefix": "/"},
  "directResponse": {
    "status": 503,
    "body": "{\"error\": \"service unavailable\", \"message\": \"Down for maintenance\"}"
  }
}

All fields

FieldTypeDefaultDescription
statusnumberrequiredHTTP status code returned to the client
bodystring""Response body (any string — JSON, HTML, plain text)

directResponse is mutually exclusive with forward and redirect. Setting more than one is a validation error.

Examples

Health check endpoint

{
  "name": "healthz",
  "match": {"path": "/healthz"},
  "directResponse": {
    "status": 200,
    "body": "{\"status\": \"ok\"}"
  }
}

Answers health probes directly at the proxy without hitting any backend. No destination needed.

Maintenance page (JSON)

{
  "name": "maintenance",
  "match": {"pathPrefix": "/"},
  "directResponse": {
    "status": 503,
    "body": "{\"error\": \"maintenance\", \"message\": \"Back soon\"}"
  }
}

Block all traffic during a deployment window. Place this route in a group with low priority or activate it via a snapshot swap when maintenance starts.

Block a specific path

{
  "name": "block-admin",
  "match": {"pathPrefix": "/admin"},
  "directResponse": {
    "status": 403,
    "body": "{\"error\": \"forbidden\"}"
  }
}

Returns 403 before any middleware or backend is consulted. Useful to hard-block endpoints that should never be publicly accessible.

Static 404 for unknown routes

{
  "name": "catch-all",
  "match": {"pathPrefix": "/"},
  "directResponse": {
    "status": 404,
    "body": "{\"error\": \"not_found\", \"message\": \"The requested resource does not exist\"}"
  }
}

When placed last in the route group (lowest specificity), this catches any request that didn’t match a more specific route.

Deprecation notice

{
  "name": "deprecated-v1",
  "match": {"pathPrefix": "/api/v1"},
  "directResponse": {
    "status": 410,
    "body": "{\"error\": \"gone\", \"message\": \"API v1 is deprecated. Use /api/v2\"}"
  }
}

Returns 410 Gone to signal permanent removal. Clients that have cached the old endpoint get a clear actionable message.

When to use direct response

SituationUse
Health / readiness probesstatus: 200, no backend required
Maintenance windowsstatus: 503, swap in via snapshot
Hard-blocking sensitive pathsstatus: 403
API deprecationstatus: 410 with migration message
Catch-all 404status: 404, lowest-priority route
CORS preflight shortcutstatus: 204, avoid hitting backend for OPTIONS