ZuploZuplo
LoginSign Up
  • Documentation
  • API Reference
Introduction
Getting Started
    Develop using the Portal
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth4 - Deploy5 - Dynamic Rate LimitingMCP - Quick start
    Develop Locally
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth
Concepts
Development
Policies
Handlers
API Keys
MCP Server
MCP Gateway
AI Gateway
Developer Portal
Monetization
Deploying & Source Control
Observability
Networking & Infrastructure
Account Management
Programming API
    Overview
    Request & Context
    Configuration
    Caching APIs
    Data Management
    Extensions & Hooks
    Error Handling
    Logging & Observability
    Types and Interfaces
    Web Standards
    Advanced Topics
      Node ModulesCode ReuseRoute Custom DataClone Request/ResponseRuntime Behaviorszp-body-removedZuplo Identity TokenJWT Service PluginOAuth Protected Resource Plugin
Build with AI
Zuplo CLI
Migration Guides
Platform LimitsSecuritySupportTrust & ComplianceChangelog
powered by Zudoku
Advanced Topics

Route Custom Data

Each route in your OpenAPI file allows for specifying custom properties on your route that can be referenced in code. Because the OpenAPI document allows extensibility by adding x- properties, you can add custom data as needed to your operations and then read that data in code.

Custom Data in OpenAPI File

The example below shows how to add custom data and operation with a property x-custom.

/config/routes.oas.json
{ "/my-route": { "get": { // highlight-start "x-custom": { "hello": "world" }, // highlight-end "operationId": "c18da63b-bd4d-433f-a634-1da9913958c0", "x-zuplo-route": { "handler": { "module": "$import(@zuplo/runtime)", "export": "urlForwardHandler", "options": { "baseUrl": "https://echo.zuplo.io", "forwardSearch": true } } } } } }

Custom Data in Code

Custom data can be accessed through the context.route.raw() function. This gives you full access to the underlying data of the OpenAPI operation. By default this function returns unknown, but you can pass it a custom object or for the full OpenAPI operation, use OpenAPIV3_1.OperationObject exported from openapi-types

Code
import { ZuploContext, ZuploRequest } from "@zuplo/runtime"; export async function echo(request: ZuploRequest, context: ZuploContext) { const data = context.route.raw<{ "x-custom": { hello: string } }>(); context.log.info(`My custom data: ${data["x-custom"].hello}`); }
Edit this page
Last modified on August 8, 2025
Code ReuseClone Request/Response
On this page
  • Custom Data in OpenAPI File
  • Custom Data in Code
JSON
TypeScript