Skip to main content

Service JSON

A service is described by one JSON object. Use it with the Import JSON button on the Gateway dashboard (paste or upload a file) to create one or many services at once, or with Edit all (JSON) to bulk-edit a service's endpoints. You can pass a single object or an array of them.

Limits: each account may create up to 5 services, and each service up to 50 endpoints. Payments settle to the payTo you set in Settings (per account) unless a service sets its own payTo.

Full example

[
{
"name": "Weather API",
"upstreamBaseUrl": "https://api.weather.example.com",
"description": "Current conditions and forecast for any city.",
"tags": ["weather", "data"],
"enabled": true,
"auth": { "method": "bearer", "secret": "sk_live_your_upstream_key" },
"routes": [
{ "method": "GET", "path": "/v1/current/:city", "priceUSDC": "0.01", "capability": "current weather", "enabled": true },
{ "method": "GET", "path": "/v1/forecast/:city", "priceUSDC": "0.02", "capability": "7-day forecast" },
{ "method": "GET", "path": "/v1/health", "priceUSDC": "0", "capability": "free health check" }
]
}
]

Service fields

FieldTypeRequiredNotes
namestringyesDisplay name of the service.
upstreamBaseUrlstring (URL)yesYour API base URL. Endpoint paths are appended to this. Must be a public https host.
descriptionstringnoShown to agents. Max 2000 chars.
tagsstring[]noDiscovery tags. Max 20.
payTostring (0x address)noPer-service override of where USDC settles. Defaults to the payTo you set in Settings.
enabledbooleannoDefaults to true. A disabled service serves no endpoints (503).
isPublicbooleannoDefaults to false. When true, the service is listed in the public marketplace so agents can discover it (also toggled by Make public on the service page).
authobjectnoHow the platform authenticates to your upstream. Defaults to { "method": "none" }.
routesobject[]noThe charge endpoints. Can be empty and added later. Max 50.

Auth methods

The auth.method selects how your upstream credential is injected on every forwarded request. The secret is stored encrypted at rest and never returned by the API.

methodExtra fieldsInjected as
none-No credential.
bearersecretAuthorization: Bearer <secret>
api_key_headerheaderName, secret<headerName>: <secret>
api_key_queryqueryParam, secret?<queryParam>=<secret> on the upstream URL
basicusername, secretAuthorization: Basic base64(username:secret)
custom_headerheaderName, secret<headerName>: <secret> (fixed value)

Example (API key in a header):

"auth": { "method": "api_key_header", "headerName": "X-API-Key", "secret": "your_key" }

When editing an existing service, omit secret to keep the stored one.

Route fields

Each entry in routes is one charge endpoint.

FieldTypeRequiredNotes
methodstringyesOne of GET, POST, PUT, PATCH, DELETE.
pathstringyesIncoming path under the service, starting with /. Supports :param segments, e.g. /v1/node/:address/status.
priceUSDCstringyesPrice as a decimal string, e.g. "0.01". Use "0" for a free (unpaid) route.
capabilitystringnoShort label shown in the dashboard and on the 402 challenge.
upstreamPathstringnoUpstream path if it differs from path. Same :param names. Defaults to path.
enabledbooleannoDefaults to true. A disabled endpoint returns 404.

Calling an endpoint

Once created, an endpoint is reachable at:

https://api.xdcai.tech/x402/connect/<serviceId>/<path>

A paid endpoint returns HTTP 402 with a payment challenge; an x402 agent or the XDC AI CLI settles it in USDC, gaslessly. A free endpoint (priceUSDC of "0") is proxied straight through.