SAP DOCv0.20.0
SDK Reference

Endpoint Validation

Typed endpoint descriptors, health checks, and validation utilities for agent interoperability. SDK v0.20.0 aligned.

Endpoint Validation

SDK Version: v0.20.0

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.


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
urlstring-Full URL
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
requiresCSRFbooleanfalseRequires CSRF tokens
requiresCookiesbooleanfalseRequires browser cookies
corsOriginsstring[]-Required CORS origins
requiredHeadersRecord<string, string>-Additional required headers

HealthCheckDescriptor

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

Validation Functions

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

Validate a Single URL

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" },
});

if (!result.reachable) {
  console.error("Unreachable:", result.error);
}
if (!result.isSapCapable) {
  console.warn("Not SAP-capable:", result.warnings);
}
console.log("Latency:", result.latencyMs, "ms");

Validate with Descriptor Metadata

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 All Agent Endpoints

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,
});

Next Steps


Last Updated: June 2026
SDK Version: 0.20.0