Service Gateway Setup
Hands-on guide to creating connectors, adding endpoints, configuring transforms, and publishing through the Service Gateway.
Overview#
This guide walks through setting up a new connector in the NaaP Service Gateway — from creating the connector to adding endpoints, configuring transforms, and publishing for consumers.
The Service Gateway exposes third-party APIs as managed connectors under /api/v1/gw/[connector]/*. For the conceptual overview, see Service Gateway.
Prerequisites#
- A running NaaP instance (local or deployed)
- An authenticated session with a valid JWT (or admin access)
- The upstream API's base URL and authentication credentials
Step 1: Create a Connector#
Create a new connector via the admin API:
The connector is created in draft status. Key fields:
| Field | Description |
|---|---|
slug | URL-safe identifier used in proxy paths |
upstreamBaseUrl | Where requests are forwarded to |
allowedHosts | Whitelist of allowed upstream hosts (SSRF protection) |
authType | How to authenticate to the upstream: bearer, basic, header, query, aws-s3, or none |
authConfig | Auth-specific config (e.g., { "tokenRef": "token" } for bearer) |
secretRefs | Names of secrets the connector needs (stored encrypted) |
responseWrapper | Whether to wrap responses in the NaaP envelope |
Step 2: Store Secrets#
Store the upstream API credentials in the gateway's encrypted secret vault:
Secrets are encrypted at rest. The key must match one of the values in secretRefs from the connector configuration.
Step 3: Add Endpoints#
Define the consumer-facing routes that map to upstream paths:
Endpoint Fields#
| Field | Description |
|---|---|
method | HTTP method: GET, POST, PUT, PATCH, DELETE |
path | Consumer-facing path (appended to /api/v1/gw/{slug}) |
upstreamPath | The actual path sent to the upstream service |
bodyTransform | How to transform the request body before forwarding |
responseBodyTransform | How to transform the upstream response |
policies.rateLimit | Requests per minute per key |
policies.timeout | Max upstream wait time in milliseconds |
policies.maxBodySize | Max request body size in bytes |
policies.cacheTtl | Cache duration in seconds (0 = no caching) |
policies.retries | Number of retry attempts on upstream failure |
Step 4: Choose Transforms#
Select the appropriate transform strategy for each endpoint based on the upstream API requirements.
Body Transforms#
| Strategy | When to Use |
|---|---|
passthrough | Default — forward JSON body unchanged (most APIs) |
static | Replace body with a pre-configured payload (e.g., fixed analytics queries) |
template | Reshape the consumer body using a template (e.g., wrapping in an upstream-specific format) |
extract | Pull a specific nested field from the consumer body |
binary | Forward raw binary data (file uploads, S3 objects) |
form-encode | Convert JSON to application/x-www-form-urlencoded (Stripe, Twilio) |
Response Transforms#
| Strategy | When to Use |
|---|---|
envelope | Wrap upstream response in the NaaP standard envelope ({ success, data }) |
raw | Return the upstream response unchanged |
streaming | Pass through SSE streams for LLM-style streaming responses |
field-map | Restructure the response using a field mapping config |
Step 5: Test Connectivity#
Verify the connector can reach the upstream:
The test endpoint attempts to connect to the upstream base URL and reports connectivity status, latency, and any errors.
Step 6: Publish#
Once testing passes, publish the connector to make it available for consumers:
Publishing changes the connector status from draft to published. You can also set visibility:
private: Only the owning team can access the connectorpublic: The connector appears in the catalog for all users
Step 7: Create API Keys#
Create API keys for external consumers:
The response includes a gw_-prefixed key. This key is only shown once — store it securely.
Using a Connector#
Once published, consumers can proxy requests through the gateway:
Using Connector Templates#
The gateway includes 19 pre-built connector templates for common APIs (OpenAI, Stripe, ClickHouse, etc.). To create a connector from a template:
- List available templates:
GET /api/v1/gw/admin/templates - Create a connector from a template — the template pre-fills the upstream URL, auth type, endpoints, and transform strategies
- You only need to provide your own secrets (API keys/credentials)
Agent Integration#
Published connectors are automatically available as agent-callable tools:
To enhance agent discoverability, add agent metadata to your connector:
agentDescription: A natural-language description for the LLMinputSchema/outputSchema: JSON Schema for endpoint request/response
Next Steps#
- Service Gateway Concept — Architecture and pipeline details
- Service Gateway API Reference — Full REST API reference