v2.4

VectorGate API Documentation

VectorGate is an edge configuration API for teams that manage routing rules, health checks, and traffic policies across distributed applications.

Edge Rule Control

Create ordered routing rules for regions, headers, methods, and weighted upstream targets.

Health Telemetry

Track upstream availability, regional latency, and policy decisions through event streams.

Scoped Access

Use per-environment keys, route-level permissions, audit logs, and signed webhook delivery.

Global Propagation

Configuration snapshots are versioned and propagated to edge locations with rollback support.

Authentication

All requests must include an API key in the Authorization header using the Bearer scheme. Keys are generated in the VectorGate workspace console.

i
Key scopes Keys can be restricted to environments, routes, and HTTP methods. Use restricted keys (vg_rk_) for read-only tooling and keep live secret keys server-side only.
HTTP
GET /v2/rules HTTP/1.1
Host: api.vectorgate.dev
Authorization: Bearer vg_live_sk_v2_Xk9mP3rQ2nL8wT5...
Content-Type: application/json

Key Types

TypePrefixDescription
Livevg_live_sk_Full access to production resources. Never expose publicly.
Testvg_test_sk_Sandbox environment only; no production routing changes are applied.
Restrictedvg_rk_Read-only or resource-scoped. Suitable for internal tooling.

Base URL & Versioning

The current stable version is v2. All endpoint paths are relative to:

URL
https://api.vectorgate.dev/v2

Breaking changes are released under a new version prefix. Deprecated versions remain available for a minimum of 12 months after the successor ships.

VersionStatusSunset
v2Current-
v1Deprecated2026-09-15

Request Format

All request and response bodies are JSON. Set Content-Type: application/json on every write request. Timestamps are Unix seconds (UTC).

*
Idempotency Supply an Idempotency-Key (UUID v4) on POST requests to safely retry without duplicate route or rule creation. Keys expire after 24 hours.
HeaderRequiredDescription
AuthorizationrequiredBearer <api_key>
Content-Typerequiredapplication/json on write requests
Idempotency-KeyoptionalUUID v4 for safe POST/PATCH retries
VectorGate-VersionoptionalPin a minor version, e.g. 2024-09-15

Rules

A rule describes how matching requests are evaluated at the edge. Active rules are applied in priority order and can be rolled back by snapshot version.

GET /v2/rules List rules

Returns a cursor-paginated list of rules for the authenticated workspace, sorted by priority ascending.

ParameterTypeDefaultDescription
limitinteger20Results per page. Range: 1-100.
cursorstring-Pagination cursor from a previous response.
route_idstring-Filter by route ID.
statusenum-draft | active | paused | archived
Request
cURL
curl https://api.vectorgate.dev/v2/rules \
  -H "Authorization: Bearer vg_live_sk_v2_Xk9mP3rQ2nL8wT5" \
  -G -d "limit=5" -d "status=active"
Response - 200 OK
JSON
{
  "object": "list",
  "data": [
    {
      "id":         "rule_01HX9K3M7PQ6RSTV2W4N8A",
      "object":     "rule",
      "route_id":   "rt_01HW2K1M6PC5RSTU1W3M7A",
      "name":       "EU read traffic",
      "priority":   40,
      "status":     "active",
      "created_at": 1714320000,
      "updated_at": 1714320047
    }
  ],
  "has_more":    true,
  "next_cursor": "cur_eyJpZCI6Im1zZ18wMUhYOUsifQ"
}
POST /v2/rules Create a rule

Creates a routing rule in draft mode. Publish the route snapshot when the rule set has been reviewed.

ParameterTypeRequiredDescription
route_idstringrequiredRoute that owns the rule.
namestringrequiredHuman-readable rule label.
priorityintegerrequiredEvaluation priority. Lower numbers run first.
matchobjectrequiredPath, method, header, or region criteria.
actionobjectrequiredForward, redirect, or fixed-response action.
metadataobjectoptionalArbitrary key-value pairs for audit and search.
Request
cURL
curl https://api.vectorgate.dev/v2/rules \
  -X POST \
  -H "Authorization: Bearer vg_live_sk_v2_Xk9mP3rQ2nL8wT5" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000" \
  -d '{
    "route_id": "rt_01HW2K1M6PC5RSTU1W3M7A",
    "name": "EU read traffic",
    "priority": 40,
    "match": { "region": ["eu-central-1"], "method": "GET" },
    "action": { "type": "forward", "upstream_id": "up_01J2A8K6" },
    "metadata": { "owner": "platform" }
  }'
Response - 201 Created
JSON
{
  "id":           "rule_01HY3K8M9PQ7RSUV3X5N9B",
  "object":       "rule",
  "route_id":     "rt_01HW2K1M6PC5RSTU1W3M7A",
  "name":         "EU read traffic",
  "priority":     40,
  "status":       "draft",
  "metadata":     { "owner": "platform" },
  "created_at":   1714330512,
  "updated_at":   null
}
GET /v2/rules/{id} Retrieve a rule

Returns the full rule object including version history and current publication status.

Response - 200 OK
JSON
{
  "id":      "rule_01HX9K3M7PQ6RSTV2W4N8A",
  "object": "rule",
  "status": "active",
  "events": [
    { "type": "created",   "at": 1714320000 },
    { "type": "validated", "at": 1714320008 },
    { "type": "published", "at": 1714320047 }
  ],
  "published_at": 1714321204,
  "created_at": 1714320000
}
DELETE /v2/rules/{id} Archive a rule

Archives a draft or paused rule. Returns 422 rule_published if the active snapshot still depends on it.

Response - 200 OK
JSON
{
  "id":          "rule_01HX9K3M7PQ6RSTV2W4N8A",
  "object":      "rule",
  "status":      "archived",
  "archived_at": 1714325000
}

Routes

Routes define public hostnames, upstream pools, and policy boundaries for edge traffic. Configure health checks, fallback targets, and TLS settings at the route level.

GET /v2/routes List routes

Returns all routes configured for the authenticated workspace.

Response - 200 OK
JSON
{
  "object": "list",
  "data": [
    {
      "id":         "rt_01HW2K1M6PC5RSTU1W3M7A",
      "object":     "route",
      "name":       "Public API",
      "hostname":   "api.example.net",
      "mode":       "balanced",
      "enabled":  true,
      "created_at": 1710000000
    },
    {
      "id":         "rt_01HW4N2P8RF7TUVW3X6Q9B",
      "object":     "route",
      "name":       "Asset Gateway",
      "hostname":   "assets.example.net",
      "mode":       "cache_first",
      "enabled":  true,
      "created_at": 1710100000
    }
  ]
}
POST /v2/routes Create a route

Creates a new route. Required fields in config depend on the chosen traffic mode and TLS policy.

ParameterTypeRequiredDescription
namestringrequiredHuman-readable label for this route.
hostnamestringrequiredPublic hostname handled by the route.
modeenumrequiredbalanced | cache_first | origin_first
configobjectrequiredHealth check, TLS, and fallback settings.
PATCH /v2/routes/{id} Update a route

Partially updates a route. Only supplied fields are changed and a new draft snapshot is created.

Request
cURL
curl https://api.vectorgate.dev/v2/routes/rt_01HW2K1M6PC5RSTU1W3M7A \
  -X PATCH \
  -H "Authorization: Bearer vg_live_sk_v2_Xk9mP3rQ2nL8wT5" \
  -H "Content-Type: application/json" \
  -d '{ "mode": "cache_first" }'

Webhooks

VectorGate sends a signed POST to your endpoint whenever a tracked configuration or route event occurs. Configure endpoints in the workspace console or via the Webhooks API.

!
Always verify signatures Compute HMAC-SHA256 over timestamp + "." + raw_body using your signing secret and compare to the VectorGate-Signature header. Reject requests that fail.

Signature Verification

Python
import hmac, hashlib

def verify_webhook(payload: bytes, signature: str, secret: str) -> bool:
    timestamp, received = signature.split(",", 1)
    msg = f"{timestamp}.{payload.decode()}"
    computed = hmac.new(secret.encode(), msg.encode(), hashlib.sha256).hexdigest()
    return hmac.compare_digest(computed, received)

Event Types

EventDescription
rule.createdRule accepted and stored in draft state.
rule.validatedRule passed syntax and policy checks.
route.publishedRoute snapshot published to the edge network.
route.rollbackRoute restored to an earlier snapshot.
upstream.failedHealth checks marked an upstream unavailable.
upstream.recoveredHealth checks marked an upstream healthy again.

Webhook Payload

All events share a common envelope with an event-specific data object.

JSON
{
  "id":         "evt_01HZ1K4N8PQ8RSUV4Y6O0C",
  "object":     "event",
  "type":       "route.published",
  "created_at": 1714320047,
  "data": {
    "route_id":    "rt_01HW2K1M6PC5RSTU1W3M7A",
    "snapshot_id": "snap_01HZ1K4N8PQ8RSUV4Y6O0C",
    "region":      "global",
    "published_at": 1714320047
  }
}
*
Retry policy Failed webhook deliveries are retried with exponential back-off: 1 s, 30 s, 5 min, 30 min, then 2 h. After 5 attempts the event is marked failed and remains available for manual replay from the console.

Error Codes

VectorGate uses standard HTTP status codes. Error responses always include a JSON body with a machine-readable code and a human-readable message.

Error Object

JSON
{
  "error": {
    "code":       "route_disabled",
    "message":    "The specified route is currently disabled.",
    "param":      "route_id",
    "request_id": "req_01HZ3P6Q9RF4STUW5Z8R1D"
  }
}

HTTP Status Codes

StatusMeaning
200 OKRequest succeeded.
201 CreatedResource created successfully.
400 Bad RequestMalformed JSON or missing required parameters.
401 UnauthorizedMissing or invalid API key.
403 ForbiddenKey does not have the required scope.
404 Not FoundResource does not exist or belongs to another org.
409 ConflictDuplicate idempotency key with a different body.
422 UnprocessableRequest is well-formed but semantically invalid.
429 Too Many RequestsRate limit exceeded. See Retry-After header.
500 Internal ErrorUnexpected server error. Retry with exponential back-off.

Application Error Codes

CodeHTTPDescription
invalid_api_key401Key format is invalid or has been revoked.
insufficient_scope403Key lacks the required permission for this operation.
resource_not_found404The requested resource ID does not exist.
route_disabled422The target route has been disabled.
rule_published422Rule cannot be archived while used by the active snapshot.
priority_conflict400A rule with the same priority already exists on the route.
rate_limit_exceeded429Request rate limit reached. Check Retry-After.

Rate Limits

Limits are enforced per API key using a sliding window. Responses always include current limit state in response headers.

HeaderDescription
X-RateLimit-LimitMaximum requests allowed in the current window.
X-RateLimit-RemainingRequests remaining in the current window.
X-RateLimit-ResetUnix timestamp when the window resets.
Retry-AfterSeconds to wait before retrying (on 429 only).

Limits by Plan

PlanRequests / minRoutes
Free603
Starter30025
Growth1 200250
EnterpriseCustomUnlimited
i
POST /v2/rules uses a separate per-route mutation limit in addition to the global API limit. Contact support to request higher thresholds.

SDKs & Libraries

Official client libraries are maintained for the most popular languages. Community libraries are listed in the GitHub org.

LanguageInstallVersion
Node.js / TypeScriptnpm install @vectorgate/sdk3.1.0
Pythonpip install vectorgate-sdk2.4.1
Gogo get github.com/vectorgate/vectorgate-go1.8.0
Rubygem install vectorgate-sdk1.3.2
PHPcomposer require vectorgate/sdk2.0.0

Node.js Quick Start

TypeScript
import VectorGate from "@vectorgate/sdk";

const client = new VectorGate({ apiKey: process.env.VECTORGATE_API_KEY! });

const rule = await client.rules.create({
  route_id: "rt_01HW2K1M6PC5RSTU1W3M7A",
  name:     "EU read traffic",
  priority: 40,
  match:    { region: ["eu-central-1"], method: "GET" },
});

console.log(rule.id); // "rule_01HY3K8M9PQ7RSUV3X5N9B"

Python Quick Start

Python
import vectorgate, os

client = vectorgate.Client(api_key=os.environ["VECTORGATE_API_KEY"])

rule = client.rules.create(
    route_id="rt_01HW2K1M6PC5RSTU1W3M7A",
    name="EU read traffic",
    priority=40,
    match={"region": ["eu-central-1"], "method": "GET"},
)

print(rule.id)  # "rule_01HY3K8M9PQ7RSUV3X5N9B"

Changelog

v2.4 - 2026-01-14

  • Added snapshot diffing for route publication workflows.
  • New webhook event: upstream.recovered for health check recovery.
  • Rate-limit headers now use the X-RateLimit-* naming convention.
  • Deprecated v1 API; sunset date 2026-09-15.

v2.3 - 2025-08-20

  • Weighted upstream support for gradual traffic migration.
  • Restricted API keys with per-resource and per-method scopes.
  • Improved webhook retry policy with 5 attempts and exponential back-off.

v2.2 - 2025-03-05

  • Cache-first route mode.
  • Added metadata field to rule objects.
  • New route.rollback webhook event.