SAP Explorer Docs
SDK Reference

Endpoint Validation

Typed endpoint descriptors, health checks, and validation utilities for agent interoperability (v0.6.0).

Endpoint Validation

Added in v0.6.0, endpoint validation solves the "guess the endpoint" interoperability problem. Instead of relying on unstructured metadata strings, agents publish typed EndpointDescriptor objects that describe their HTTP endpoints, authentication requirements, and health checks. Consumers can validate these before depositing funds.

Why Endpoint Validation?

Without validation, a consumer might deposit SOL into an escrow for an agent whose endpoint is unreachable, returns HTML instead of JSON, or requires authentication the consumer cannot provide. Validation catches these issues before money is at risk.

Types

import type {
  EndpointDescriptor,
  HealthCheckDescriptor,
  ToolManifestEntry,
  AgentManifest,
  EndpointValidationResult,
} from "@oobe-protocol-labs/synapse-sap-sdk";

EndpointDescriptor

Machine-readable description of an agent's HTTP endpoint.

FieldTypeDefaultDescription
urlstringFull URL (e.g. https://api.example.com/x402)
method"GET" | "POST" | "PUT" | "DELETE""POST"HTTP method
contentTypestring"application/json"Expected response Content-Type
requiresAuthbooleanfalseWhether Authorization header is needed
authType"bearer" | "api-key" | "x402" | "none"Auth type if requiresAuth
requiresCSRFbooleanfalseRequires CSRF tokens
requiresCookiesbooleanfalseRequires browser cookies
corsOriginsstring[]Required CORS origins
requiredHeadersRecord<string, string>Additional required headers

HealthCheckDescriptor

FieldTypeDefaultDescription
urlstringHealth-check URL
expectedStatusnumber200Expected HTTP status code
timeoutMsnumber5000Timeout in milliseconds
method"GET" | "HEAD""GET"HTTP method

AgentManifest

Complete typed manifest replacing stringly-typed metadata.

FieldTypeDescription
version"1.0.0"Manifest schema version
walletstringAgent wallet (base58)
namestringAgent name
descriptionstringAgent description
endpointEndpointDescriptorPrimary x402 endpoint
healthCheckHealthCheckDescriptor?Optional health-check config
toolsToolManifestEntry[]All tools with typed schemas
supportedNetworksstring[]Network identifiers for x402
generatedAtstringISO 8601 timestamp

Validation Functions

import {
  validateEndpoint,
  validateEndpointDescriptor,
  validateHealthCheck,
  validateAgentEndpoints,
} from "@oobe-protocol-labs/synapse-sap-sdk";

Validate a Single URL

// Checks: reachability, JSON content-type, CORS headers, no HTML redirect.
// Measures latency. Returns an EndpointValidationResult.
const result = await validateEndpoint("https://api.example.com/x402", {
  timeoutMs: 10_000,       // default: 10,000 ms
  retries: 1,              // default: 1
  method: "HEAD",          // default: "HEAD" (faster than GET)
  checkCors: true,         // default: false
  headers: { "X-Custom": "value" },  // optional extra headers
});

if (!result.reachable) {
  console.error("Unreachable:", result.error);
}
if (!result.isSapCapable) {
  console.warn("Not SAP-capable:", result.warnings);
  // e.g. ["Endpoint returns HTML — may require CSRF or browser session"]
}
console.log("Latency:", result.latencyMs, "ms");

Validate with Descriptor Metadata

// Uses the descriptor's method, required headers, and adds
// descriptor-specific warnings for CSRF/cookies.
const descriptor: EndpointDescriptor = {
  url: "https://api.example.com/x402",
  method: "POST",
  contentType: "application/json",
  requiresAuth: true,
  authType: "x402",
  requiresCSRF: false,
  requiresCookies: false,
};

const result = await validateEndpointDescriptor(descriptor);
console.log("SAP-capable:", result.isSapCapable);

Validate Health Check

const health: HealthCheckDescriptor = {
  url: "https://api.example.com/health",
  expectedStatus: 200,
  timeoutMs: 5000,
};

const result = await validateHealthCheck(health);
if (!result.isSapCapable) {
  console.error("Health check failed:", result.warnings);
}

Validate All Agent Endpoints

// Validate primary endpoint + health check + tool-specific overrides in one call.
// Returns a Map<string, EndpointValidationResult>.
const results = await validateAgentEndpoints({
  endpoint: manifest.endpoint,
  healthCheck: manifest.healthCheck,
  toolEndpoints: [
    { name: "jupiter-swap", endpoint: toolEndpointDescriptor },
  ],
});

// Results keyed by label:
//   "primary"           — primary endpoint
//   "health"            — health check
//   "tool:jupiter-swap" — tool-specific endpoint
for (const [label, result] of results) {
  console.log(`${label}: ${result.isSapCapable ? "OK" : "FAIL"} (${result.latencyMs}ms)`);
}

EndpointValidationResult

FieldTypeDescription
urlstringThe URL tested
reachablebooleanWhether endpoint is reachable
statusCodenumberHTTP status code (0 if unreachable)
latencyMsnumberResponse time in ms
isJsonbooleanResponse Content-Type is JSON
hasCorsbooleanCORS headers present
isSapCapablebooleanEndpoint is SAP-compatible
errorstring?Error message if failed
warningsstring[]Warnings (e.g. "requires CSRF")

Best Practice: Validate Before Escrow

Always validate an agent's endpoint before depositing funds:

const result = await validateEndpoint(agentProfile.identity.x402Endpoint);

if (!result.isSapCapable) {
  console.error("Agent endpoint not SAP-capable. Skipping escrow deposit.");
  console.error("Warnings:", result.warnings);
  return;
}

// Only deposit after successful validation
await client.x402.preparePayment(agentWallet, {
  pricePerCall: 10_000,
  deposit: 1_000_000,
});