Calling Market
URL pattern
Section titled “URL pattern”https://market.pactnetwork.io/v1/<endpoint>/<upstream-path>v1 is a literal Pact-side prefix — the API version that the gate, the
signature middleware, and the proxy route all mount under. <endpoint>
is the identifier issued to private-beta users at access time.
<upstream-path> is the upstream path as-is: same segments, same query
string, same body.
Required headers
Section titled “Required headers”| Header | Value |
|---|---|
Authorization | Bearer pact_beta_… (your private-beta key) |
Content-Type | Match upstream’s expected content type. Usually application/json. |
A missing or invalid Authorization header returns 403 pact_auth_not_in_beta. See Applying for access.
Examples
Section titled “Examples”curl -X POST \ https://market.pactnetwork.io/v1/<endpoint>/<upstream-path> \ -H "Authorization: Bearer $PACT_BETA_KEY" \ -H "Content-Type: application/json" \ -d '{"limit": 10}'const url = new URL( `/v1/${endpoint}/${upstreamPath}`, 'https://market.pactnetwork.io',);
const res = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${process.env.PACT_BETA_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ limit: 10 }),});import osimport requests
res = requests.post( f"https://market.pactnetwork.io/v1/{endpoint}/{upstream_path}", headers={ "Authorization": f"Bearer {os.environ['PACT_BETA_KEY']}", "Content-Type": "application/json", }, json={"limit": 10},)Response shape
Section titled “Response shape”Market returns the upstream body unchanged. Headers it adds:
X-Pact-Classification—success,client_error, orserver_error.X-Pact-Call-Id— opaque ID. Use this when reporting issues.X-Pact-Premium-Microusd— premium charged for this call, in microUSDC.
Error responses
Section titled “Error responses”From Market itself
Section titled “From Market itself”Non-upstream errors (auth, rate limit, upstream failures) return JSON. The private-beta gate returns a flat shape:
{ "error": "pact_auth_not_in_beta" }Other Market errors use the nested envelope:
{ "error": { "code": "RATE_LIMIT", "message": "Per-key cap exceeded.", "call_id": "..." }}| Status | error / error.code | When |
|---|---|---|
| 403 | pact_auth_not_in_beta | Missing/invalid Bearer key, or key revoked. The private-beta gate is on. See Applying for access. |
| 401 | AUTH_FAILED | Request carries an x-pact-agent header and its ed25519 signature didn’t verify against that key. Unsigned requests skip this check. |
| 429 | RATE_LIMIT | You hit the per-key cap. |
| 502 | UPSTREAM_UNREACHABLE | Market couldn’t reach the upstream. Classifies as server_error, refund queued. |
| 504 | UPSTREAM_TIMEOUT | Read timeout from upstream. Classifies as server_error. |
From the upstream service
Section titled “From the upstream service”Upstream errors pass through as-is — same status, body, and headers. Market only adds its classification headers.
Refund expectations
Section titled “Refund expectations”If your call is classified server_error:
- The refund is queued; you don’t do anything.
- The next settler run posts it on-chain. Cadence: Status.
- Confirm by querying the indexer with
X-Pact-Call-Id.