---
title: "Create a new gateway"
method: POST
path: "/gateway"
tags: ["Gateways"]
---

# Create a new gateway

`POST /gateway`

## Request

- Base URL: `https://api.quiva.ai`
- URL: `https://api.quiva.ai/gateway`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`
- TypeScript: <https://skmtc.dev/quivaworks/apis/quiva-ai-gateway-4/docs/gateway/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates a new gateway with a unique topic and URL.

## Request body

- GatewayCreateRequest
  - `name` string, required: Name of the gateway
  - `description` string: Description of the gateway
  - `active` boolean, required: Whether the gateway is active
  - `middleware` Middleware[]: List of middleware to be applied to the gateway
    - `order` integer: Execution order of the middleware
    - `resource` string: Resource identifier for the middleware function
    - `resource_type` 'function' | 'service': Type of resource the middleware points to
    - `resource_version` string: Version of the middleware resource to use
    - `type` 'pre-request' | 'post-request': When the middleware should execute
  - `limit` Limit
    - `request` integer: Maximum number of requests allowed
    - `time` integer: Time window for rate limiting in milliseconds
  - `timeout` integer: Timeout in milliseconds for gateway requests

## Response `200`

Gateway created successfully

- GatewayResponseWrapper
  - `body` GatewayResponse
    - `name` string: Name of the gateway
    - `description` string: Description of the gateway
    - `url` string: URL of the gateway
    - `subject` string: Subject identifier of the gateway
    - `active` boolean: Whether the gateway is active
    - `timeout` integer: Timeout in milliseconds for gateway requests
    - `limit` Limit
      - `request` integer: Maximum number of requests allowed
      - `time` integer: Time window for rate limiting in milliseconds
    - `middleware` Middleware[]: List of middleware applied to the gateway
      - `order` integer: Execution order of the middleware
      - `resource` string: Resource identifier for the middleware function
      - `resource_type` 'function' | 'service': Type of resource the middleware points to
      - `resource_version` string: Version of the middleware resource to use
      - `type` 'pre-request' | 'post-request': When the middleware should execute
    - `modified` integer: Unix timestamp of when the gateway was last modified
    - `type` string: Type of the gateway record
  - `metadata` Metadata
    - `subject` string: Subject identifier for the resource

## Other responses

- `400`: Bad request

---

[API](https://skmtc.dev/quivaworks/apis/quiva-ai-gateway-4.md) - [All operations](https://skmtc.dev/quivaworks/apis/quiva-ai-gateway-4/llms.txt) - [OpenAPI document](https://skmtc.dev/quivaworks/apis/quiva-ai-gateway-4/revisions/4915bc3902b1?raw)
