PORTAL v2

API Reference

Portal relay exposes one control-plane API. Frontends, SDK clients, peer relays, and operators all talk to this API, but each group has a small owned surface. Local agent endpoints under /agent/* are not part of the relay API.

JSON Envelope

Matched JSON control endpoints return this envelope:

{
  "ok": true,
  "data": {}
}

Error responses use the same envelope with error instead of data:

{
  "ok": false,
  "error": {
    "code": "unauthorized",
    "message": "unauthorized"
  }
}

data is omitted on error. error is omitted on success.

The envelope does not apply to streaming or delegated endpoints:

PathFormat
/llms.txtMarkdown-formatted plain-text relay and tunnel connection guide
/sdk/connectHTTP/1.1 connection hijack
/v1/signkeyless TLS signer protocol
/api/x402/*relay-owned x402 facilitator response
/api/install.sh, /api/install.ps1, /api/install/bin/*script or binary bytes

Unknown routes may be handled by the frontend fallback or return a normal HTTP 404 outside the envelope.

Auth Schemes

NameUsed byHow it is sent
Nonepublic and challenge endpointsno credential
Admin beareradmin APIAuthorization: Bearer <access_token>
Lease token headerkeyless signer and static cacheX-Portal-Access-Token: <access_token>
Reverse capability headerreverse streamX-Portal-Reverse-Capability: <capability>
Lease token bodylease renew/reverse/unregisterJSON field access_token
Signed descriptorrelay discovery announcesigned RelayDescriptor body

The QUIC datagram backhaul carries the lease access token in a JSON message on its first stream, rather than an HTTP header. Cache endpoints can return plain-text HTTP errors for unsupported methods or exhausted request slots.

Admin auth and SDK lease auth issue different tokens and are not interchangeable. SDK lease registration uses SIWE; relay admin access uses the configured admin token.

Endpoint Groups

Public

MethodPathAuthResponse
GET/Noneselected SPA index.html
GET/HEAD/llms.txtNonerelay and tunnel connection guide
GET/api/healthzNone{ "status": "ok" }
GET/api/stateNonePublicStateResponse
GET/api/servicesNoneServiceDiscoveryResponse, optional identity filter
GET/api/services/comments?address=0x...&name=...NoneBounded, read-only remote comments
POST/api/reputation/voteNonereputation summary
GET/HEAD/api/install.sh, /api/install.ps1Noneinstall script
GET/HEAD/api/install/bin/{slug}Noneinstall binary or redirect

The reputation vote body is { "hostname": "...", "vote": "up" | "down" | "clear" }. clear removes the caller’s vote; repeating the same action is idempotent. The response includes vote counts and the caller’s viewer_vote.

Detailed contracts: SDK API and Admin and Policy API.

Public service locations

GET /api/services without query parameters browses observed public services. An optional EVM address limits results to one owner. With an address, optional name filters one normalized service identity; name= selects the unnamed service. Results group by both normalized name and address.

The response contains services (name, address, descriptive metadata, locations), partial, relays_checked, and relays_skipped. Each location contains relay_url, optional preferred url, alias_url, canonical_url, current_relay, reported_ready, observed_at, expires_at, and verification: "relay-reported". A remote location may include reputation: {up, down}; absence is unknown, not zero. Repeated voters across relays are not deduplicated. Readiness is a relay claim, not a live probe. Unavailable canonical certificates do not produce canonical links. A location can still appear without an HTTP URL, for example for a raw TCP service or an older HTTP lease with only a retired canonical hostname or no hostname at all.

Results are observed public services, never an exhaustive address inventory or cryptographic proof of ownership. Remote metadata is relay-reported; remote thumbnails are omitted. Hidden, expired, malformed, and ineligible entries are excluded. Remote visibility changes can take up to the observation TTL to appear.

Lookup reads the local directory directly, reuses valid eligible relay snapshots, and refreshes a rotating window of at most eight known, verified, eligible public HTTPS relays per request. It does not expand the relay graph. Repeated requests advance through the eligible set rather than always selecting its first entries; this is shared observation coverage, not exhaustive pagination for one search. There are at most four outbound requests across all service lookups, a two-second per-relay deadline starting after slot acquisition and five-second lookup deadline including queue waits, a 1 MiB decoded response limit, 1,000 leases per remote response, and 100 returned service identities. Overflow, failed requests, and expired lookup deadlines produce partial results. Busy request slots wait within the caller’s deadline. Concurrent requests for one relay share its in-flight lookup; pending work is never returned as a cached failure. Caller cancellation is not negative-cached as a remote failure. Observations are cached per relay for 30 seconds, failures for 10 seconds, with at most 32 cache entries. Expired observations are not served on failure; current eligibility is reapplied before returning cached locations. Requests use the Discovery public-IP dialer, disable proxies, and reject redirects.

This endpoint is additive: /discovery, its protocol version, and signed relay descriptors are unchanged. Older relays can contribute public /api/state entries through validated friendly aliases; legacy one-label canonical URLs are not promoted to links. A failed remote directory does not change Discovery health or block the existing local /api/state endpoint.

SDK

GET /sdk/domain keeps protocol_version as the default SDK tunnel contract for shipped clients with exact-version checks. The optional supported_protocol_versions array is authoritative for newer SDKs: an absent or null list falls back to exact equality; an empty list accepts no protocols. Feature support remains separate (namespaces, replicas, cache, and tenant_certificate_issuance). Additive fields do not change old defaults.

New SDKs send their selected protocol_version in POST /sdk/register/challenge; omission retains the default contract. Unsupported explicit selections return HTTP 426 with protocol_incompatible and instructions to upgrade the SDK or choose a compatible relay. A requested Local TLS namespace requires explicit support and is never silently downgraded. The current relay reports default 10 and supported ["10"], preserving main’s protocol negotiation behavior. SDK v2.7.3 and v2.7.4 pass the version check but require the removed canonical response field during registration. Their registration limitation remains; see the rollout instructions. Discovery protocol versions and signed descriptors have separate contracts.

MethodPathAuthBodyResponse
GET/sdk/domainNonenoneDomainResponse
POST/sdk/register/challengeNoneRegisterChallengeRequestRegisterChallengeResponse
POST/sdk/registerSIWE signature bodyRegisterRequestRegisterResponse
POST/sdk/renewlease token bodyRenewRequestRenewResponse
POST/sdk/reverselease token bodyReverseEndpointRequestReverseEndpoint
POST/sdk/unregisterlease token bodyUnregisterRequest{}
GET/sdk/connectreverse capability headernonehijacked stream
POST/sdk/cachelease token headerStaticCacheManifest JSONStaticCacheStatus
PUT/sdk/cachelease token headermanifest and file bytes as multipartStaticCacheStatus
DELETE/sdk/cachelease token headernoneStaticCacheStatus
POST/v1/tenant-certificatelease token headerTenantCertificateRequestTenantCertificateResponse

Admin

MethodPathAuthBodyResponse
POST/api/admin/auth/loginNoneAdminAuthLoginRequestAdminAuthLoginResponse
GET/api/admin/auth/statusOptional admin bearernoneAdminAuthStatusResponse
POST/api/admin/auth/logoutAdmin bearernone{}

/admin itself is a frontend route, not a relay API endpoint.

Payments

Relay /api/x402/* endpoints are optional relay-owned control-plane facilitator endpoints. Enable them with X402_ENABLED=true when a relay operator wants to reserve support for relay resources such as future tunnel registration fees, lease renewal fees, raw TCP/UDP port allocation, or premium capacity. They are served by the embedded gosuda/x402-facilitator handler and do not use the Portal JSON envelope. Portal selects Sui mainnet by default and Sui testnet when X402_TESTNET=true. Portal accepts only USDC gasless stablecoin address-balance payments. X402_PAY_TO is the relay-owned payment recipient.

Relay x402 settings do not affect tunnel paid routes. Tunnel payment recipients and payment networks are local tunnel configuration and are not part of the relay lease API.

Paid routed HTTP tunnels additionally expose /x402/prepare and /x402/client.js on the public tunnel origin. Those are tunnel-owned helper endpoints for app frontends, not relay API routes, and they do not use the /api prefix. /x402/client.js and the transaction-building prepare response are Sui-only. Casper clients consume the protected resource’s 402 requirements, sign with an external Casper x402 SDK, and retry with PAYMENT-SIGNATURE or X-PAYMENT; Portal then delegates verification and settlement to the configured Casper facilitator.

MethodPathAuthBodyResponse
GET/api/x402/supportedNonenonex402 supported kinds
POST/api/x402/verifyNonex402 verify requestx402 verify response
POST/api/x402/settleNonex402 settle requestx402 settle response

Policy

MethodPathAuthBodyResponse
GET/api/policyAdmin bearernonePolicySettings
POST/api/policyAdmin bearerPolicySettingsPolicySettings
GET/api/policy/stateAdmin bearernonePolicyStateResponse
POST/api/policy/leasesAdmin bearerLeasePolicyUpdate{}

Relay

MethodPathAuthResponse
GET/discoveryNoneDiscoveryResponse
POST/discovery/announceSigned descriptorDiscoveryAnnounceResponse
POST/v1/signLease token headerkeyless signer response

Observed remote comments

GET /api/services/comments?address=0x...&name=... reads public comments for one service identity. It observes at most eight eligible relays with fresh locations and returns one bounded sample of at most 20 recent rows per source, newest first. There is no pagination; each request is a new live observation, not a stable global snapshot. Each row contains relay_url, id, text, created_at and optional deleted. Treat IDs and timestamps as source claims. Partial coverage is explicit; the endpoint does not accept writes or forward visitor credentials. Origins return the service address and name alongside their comment list; the reader checks both against the requested identity. Legacy responses without identity are accepted only through an identity-bound canonical hostname. Alias comments from those origins are skipped with partial coverage because cached alias ownership cannot bind comments across an ownership change. The overall deadline is 22 seconds, including directory discovery and slot waits; each remote fetch has a two-second timeout after acquiring a slot.

Shared Types

Timestamps are JSON-encoded Go time.Time values.

Identity:

FieldTypeNotes
namestringDNS label used by the lease
addressstringEthereum address

LeaseMetadata:

FieldTypeNotes
descriptionstringoptional
ownerstringoptional
thumbnailstringoptional URL or data value
tagsstring[]optional
hidebooleanhidden leases are omitted from the public state

Lease:

FieldType
namestring
addressstring
expires_at, first_seen_at, last_seen_atstring
hostname, canonical_hostnamestring
namespacestring, optional; local-tls-v1 selects the new canonical policy
canonical_readyboolean, optional; Local TLS material availability, not reverse transport count
udp_enabled, tcp_enabledboolean
tcp_addrstring
metadataLeaseMetadata
readynumber

For local-tls-v1, only advertise the canonical as usable when canonical_ready is true and ready is positive. Otherwise use an available friendly URL as a separate origin. For legacy namespaces, ready retains its existing meaning. The hostname fields identify routes even while their endpoints are unavailable.

PolicyLease extends Lease with:

FieldType
lease_idstring
identity_keystring
bpsnumber
client_ip, reported_ipstring
is_approved, is_banned, is_deniedboolean
explicitly_approvedboolean (saved identity decision, independent of auto approval)

PublicStateResponse:

FieldType
leasesLease[]

PolicyStateResponse:

FieldType
policyPolicySettings
leasesPolicyLease[]
pendingOptional array of authenticated requests. Each contains identity_key, first_seen_at, last_seen_at, and expires_at.

PolicyPortSettings:

FieldTypeNotes
enabledbooleanenables the transport
max_leasesnumber0 means unlimited

PolicySettings:

FieldType
approval_mode"auto" or "manual"
udpPolicyPortSettings
tcp_portPolicyPortSettings

LeasePolicyUpdate:

FieldTypeNotes
identity_keystringnormalized name:address key
is_bannedbooleanoptional
is_approvedbooleanoptional
is_deniedbooleanoptional; true also revokes approval
bpsnumberoptional individual bytes/second override; 0 explicitly permits unlimited traffic; omission preserves the setting
reset_bpsbooleantrue removes the override and restores the relay default; cannot be combined with bps

DiscoveryResponse:

FieldTypeNotes
protocol_versionstringdiscovery protocol version of the serving relay
generated_atstringwhen the response was generated
relaysRelayDescriptor[]signed, routable relay descriptors
incompatible_relaysIncompatibleRelayEntry[]optional; relays contacted directly whose discovery protocol version differs
release_versionstringoptional; release of the serving relay itself
relay_release_versionsmap (peer URL → release)optional; releases directly observed from each peer’s own /discovery

release_version and relay_release_versions are optional, unsigned observation metadata: they never affect routing, trust, signature verification, or compatibility, and older relays omit them. Signed relay identity stays in RelayDescriptor.

Common Errors

CodeMeaning
invalid_jsonrequest body is not valid JSON
invalid_requestrequest shape or value is invalid
method_not_allowedendpoint does not accept the method
unauthorizedcredential is missing, expired, or invalid
feature_unavailablefeature is unavailable; automatic tenant ACME errors may be temporary
protocol_incompatibleexplicit SDK protocol selection is unsupported; HTTP 426, upgrade the SDK or choose a compatible relay
tenant_issuance_disabledthe relay does not offer automatic tenant certificate issuance
tenant_issuance_not_approvedthe service lacks explicit approval for automatic tenant certificate issuance
rate_limitedrequest was throttled
hostname_conflictcanonical hostname is inconsistently bound; routing fails closed
replica_conflicta replica cannot join a live exclusive lease or retained cache entry; retryable
lease_not_foundlease token or identity has no active lease
lease_rejectedlease is not approved to route yet
approval_queue_fullsigned registration could not be queued; retry after the supplied delay
lease_deniedrelay denied or banned the lease
source_not_allowedrelay does not accept tunnels from the caller’s network
invalid_addressaddress path or body value is invalid
invalid_modeapproval mode is not auto or manual
http11_onlyendpoint requires HTTP/1.1
hijack_unsupported, hijack_failedreverse stream setup failed
udp_disabled, udp_capacity_exceeded, udp_port_exhaustedUDP lease cannot be allocated
tcp_port_disabled, tcp_port_capacity_exceeded, tcp_port_exhaustedTCP port lease cannot be allocated
transport_mismatchrequest does not match the active lease transport
internalunexpected server failure

Go Tenant TLS API

sdk.WithAutomaticTLS(stateDir, requireLocal) opts into exact per-hostname CSR issuance, persistence, and renewal. stateDir is required at the SDK level; the CLI/agent resolve their identity-based defaults before calling it. Private leaf keys stay in that directory and are reused across restarts and renewals. Both automatic TLS modes require a namespace-capable relay. With requireLocal = false, a granted alias can satisfy WaitReady while issuance is pending. With it enabled, WaitReady waits for a usable canonical certificate. Public issuance needs relay opt-in, explicit service approval, and durable shared budgets; see the issuance endpoint contract.

sdk.WithTLSCertificate(certFile, keyFile) selects manual local signing for native, uncached HTTPS exposures. sdk.Expose reads and validates the pair before registering with any relay. Missing, malformed, mismatched, expired, or unsupported certificate material returns an error immediately. It never falls back to relay-backed signing.

Automatic and manual modes are mutually exclusive, require the native runtime, and reject raw TCP. The CLI/agent additionally reject UDP with Local TLS. At the lease-protocol level any cache opt-in remains on the separate friendly alias; the canonical is never cache eligible. Manual mode requires a namespace-capable relay. sdk.RunHTTP enables canonical HTTP/2 with an actual HTTP consumer; raw Expose/Proxy callers retain HTTP/1.1 and do not gain h2 translation.

The certificate must cover only the exact Local TLS canonical hostname assigned by a selected relay. Friendly URLs still use Keyless. A coverage failure stops that relay’s listener and appears in Exposure.Relays() with RelayFailureTerminal and an error wrapping localtls.ErrLocalCertificate; covered relays remain usable. Ordinary network failures remain retryable. Discovery applies its existing terminal-failure backoff policy and can select other relays.

Exposure.WaitReady reports when a relay can route traffic. With automatic TLS and no require-local option, a granted alias can be ready while the new canonical PublicURL remains empty. With require-local, WaitReady requires a usable canonical certificate. If every selected relay has failed terminally or refuses the required issuance, it returns the current errors. Issuance policy refusals are also available in RelayStatus.CertificateError, without disabling live aliases or an already valid canonical certificate. The exposure remains open for policy recovery or another compatible relay.

Certificate installation and expiry update the same SDK status used by Relays(), Updates(), WaitReady(), and JSON lifecycle records. The records include alias_url separately from the usable canonical public_url. For local-tls-v1 public leases, canonical_ready reports usable local material; ready continues to count reverse transport connections. The tunnel reports local_tls_not_after through authenticated lease renewal on certificate changes, and the relay withdraws canonical_ready at that expiry even without another renewal. This is an owner-reported availability hint, not certificate validation or identity proof. Friendly URLs remain separate compatibility origins.

Go source compatibility: direct users of portal/keyless.Client must replace RelayCertPool() with TenantCertPool(). The returned snapshot trusts the tenant certificate, not the relay control API. Use TenantTLSConfig() for tenant probes that must keep working across certificate rotation, and keep relay control-plane TLS trust separate. The old method name is not retained.