Docs · Reference

HTTP API

Every route of the Mesa API with its parameters, request body and response fields, the error envelope, and the batch event stream.

The Mesa API serves what the chain shows of Mesa in a form a page or a script can read directly: markets, pools, perp markets, vaults and batches. It also serves the encrypted notes a client decrypts, relays transactions as fee payer, and takes watcher enrolments. It holds no key that opens an account.

Everything it serves can also be read from Solana and a Privacy Rings indexer. See Reading Mesa without Mesa.

Conventions

Paths are relative to https://api.mesa.markets. GET /openapi.json returns this contract as an OpenAPI 3.1 document, and GET /health returns the contract version the server speaks.

Kind of valueHow it is sent
AmountAn unsigned integer string in the asset's smallest unit. A change in a total is a signed integer string.
Price, rate, ratioA decimal string. Funding rates and percentage changes are signed.
Basis pointsAn integer from 0 to 10000. A rate that is not set yet is null.
TimeAn ISO 8601 timestamp in UTC.
Address, signatureBase58.
BytesBase64.
IdentifierA market, pool, perp market or vault id: letters, digits, _ and -.

Requests are strict: an unknown field or enum value is refused with VALIDATION_ERROR. Responses are open: a client ignores fields and enum values it does not know.

Paging. Lists of batches and opened orders take cursor and limit and return page.nextCursor and page.hasMore. Pass nextCursor back as cursor for the next page. Note routes page by slot, with paginationToken.

Idempotency. Every route that sends a transaction takes an idempotencyKey of 8 to 128 characters. Sending the same request again with the same key returns the first result and sends nothing twice.

Errors

Every failed response has one shape.

json
{
  "error": {
    "code": "BATCH_CLOSED",
    "message": "This batch is already closed and no longer accepts sealed actions.",
    "retryable": true,
    "stage": "validation"
  }
}
FieldTypeMeaning
codestringOne of the codes below
messagestringA sentence that can be shown to a person
retryablebooleanWhether sending the request again can succeed
stagestringWhere it failed: validation, auth, read, build, wallet, simulation, send, confirmation
fieldErrorsobject, optionalFor VALIDATION_ERROR: the messages per field
programErrorobject, optionalThe program that refused the transaction: programId, name and number. For the mesa program the name is one of the program's errors.
retryAfterSecondsinteger, optionalFor RATE_LIMITED
requestIdstring, optionalAn id to quote when reporting a failure
CodeStatusRaised when
VALIDATION_ERROR400A parameter or body field is missing, unknown or malformed
UNAUTHORIZED401The key sent with a watcher request does not match the position's enrolment
ORIGIN_NOT_ALLOWED403A browser calls from an origin the API does not serve
NOT_FOUND404No such market, pool, vault, batch or transaction
PROGRAM_UNAVAILABLE409The API is not connected to the program yet. Retryable.
CONFIGURATION_REQUIRED409The route needs a setting the deployment does not have
IDEMPOTENCY_CONFLICT409The same transaction was already submitted under another idempotency key
TRANSACTION_EXPIRED409The transaction's blockhash expired before it landed. Build it again.
STALE_BATCH409The action names a batch that has already passed. The message gives the current batch.
BATCH_CLOSED409The action names a batch that is closed. Place it into the current one.
WALLET_CHANGED409The signed transaction differs from the one built in a way the API cannot accept, or needs relay mode
PAYLOAD_TOO_LARGE413The body exceeds the size limit
UNSUPPORTED_MEDIA_TYPE415The body is not JSON
SIMULATION_FAILED422The transaction failed in simulation. programError names the refusal.
CHAIN_REFUSED422The transaction was sent and the chain refused it. programError names the refusal.
INVALID_PROOF422The proof does not verify
RATE_LIMITED429Too many requests. Wait retryAfterSeconds.
INTERNAL_ERROR500The API failed
UPSTREAM_UNAVAILABLE502The RPC or the indexer behind the API did not answer
PROVER_FAILED502The prover service did not answer. Retryable.

The batch event stream

GET /v1/events is a server-sent event stream. It sends an event each time a batch changes state, so a page or a script can follow the clock without polling.

ParameterTypeMeaning
marketidentifier, query, optionalOnly events for this market
batchinteger, query, optionalOnly events for this batch
EventSent when
readyThe stream is connected
batch.openedA new batch starts taking actions
batch.sealedA batch closes
batch.openingThe batch's actions are being opened
batch.clearedEvery target of the batch has its result
batch.settledEvery action of the batch is paid out
resyncEvents may have been missed. Read GET /v1/clock again.

Each event's data is a JSON object with type, id, timestamp and data. For a batch event data holds at least batchNumber and state.

ts
const apiUrl = 'https://api.mesa.markets'
const events = new EventSource(`${apiUrl}/v1/events`)
events.addEventListener('batch.settled', (e) => {
  const { data } = JSON.parse(e.data)
  console.log(data.batchNumber)
})

Sending a transaction

Two paths lead to the chain.

Relayed. POST /v1/relay takes a Mesa action that needs no wallet signature: everything except a deposit. The client proves the action, assembles the mesa instructions and sends them serialized in instructions. The API refuses instructions for any other program, signs as fee payer, sends the transaction and returns a receipt whose id is followed with GET /v1/transactions/{id}.

Wallet-signed. A deposit, and registering or moving funds in a Rings private wallet, are signed by the person's wallet. POST /v1/transactions/build returns the unsigned transaction, the wallet signs it, and POST /v1/transactions/submit sends it, in relay mode with the signed bytes or in wallet-sent mode with the signature of a transaction the wallet sent itself.

A transaction's status moves through pending, submitted, confirmed and finalized, or ends in failed or expired. A failed status carries error with the stage that failed and, where a program refused it, that program's address and error.

The SDK does all of this behind one call per action.

Service

GET /health

Service health and readiness state.

Response 200:

FieldType
statuslive | waiting | fixture
contractVersionstring
asOftimestamp

GET /v1/config

Protocol, Privacy Rings, drand and fee configuration.

Response 200:

FieldType
clusterlocalnet | devnet | mainnet
modefixture | live
sampleboolean
programIdstring or null
ringsProgramIdstring
ringsRegistryIdstring
ringsStateTreestring
mesaAuthoritystring or null
relayerstring or null (optional)
rpcUrlstring
indexerUrlstring or null (optional)
proverUrlstring or null
drandobject
drand.chainHashstring
drand.endpointstring
drand.periodSecondsinteger
drand.genesisTimeinteger
batchLengthSecondsinteger
heartbeatSecondsinteger
feesobject
fees.tradeFeeBpsinteger or null
fees.borrowReserveShareBpsinteger or null
fees.perpOpenFeeBpsinteger or null
fees.perpCloseFeeBpsinteger or null
fees.protocolShareBpsinteger or null
fees.treeFeeLamportsstring
feeRecipientstring or null
tokenMintstring or null
pausedboolean
assetsarray of object
assets[].mintstring
assets[].symbolstring
assets[].namestring
assets[].decimalsinteger
assets[].assetIdinteger (optional)
oraclesobject (optional)
asOftimestamp

GET /v1/clock

Current batch number, countdown and drand round.

Response 200:

FieldType
batchNumberinteger
stateopen | sealed | opening | cleared | settled
openedAttimestamp
closesAttimestamp
batchLengthSecondsinteger
drandRoundinteger
sealedActionCountinteger
serverTimetimestamp

Spot markets

GET /v1/markets

List spot markets.

Response 200:

FieldType
itemsarray of object
items[].idstring
items[].pairstring
items[].addressstring
items[].baseobject
items[].base.mintstring
items[].base.symbolstring
items[].base.namestring
items[].base.decimalsinteger
items[].base.assetIdinteger (optional)
items[].quoteobject
items[].quote.mintstring
items[].quote.symbolstring
items[].quote.namestring
items[].quote.decimalsinteger
items[].quote.assetIdinteger (optional)
items[].pricePrecisioninteger
items[].lastClearingPricedecimal string
items[].priceChange24hPctsigned decimal string
items[].volume24hBaseinteger string
items[].volume24hQuoteinteger string
items[].vaultIdstring
items[].vaultDepthobject
items[].vaultDepth.baseReserveinteger string
items[].vaultDepth.quoteReserveinteger string
items[].vaultDepth.totalValueQuoteinteger string
items[].feeBpsinteger or null
items[].nextBatchClosesAttimestamp
items[].lastBatchNumberinteger
items[].statusactive | paused
clockobject
clock.batchNumberinteger
clock.stateopen | sealed | opening | cleared | settled
clock.openedAttimestamp
clock.closesAttimestamp
clock.batchLengthSecondsinteger
clock.drandRoundinteger
clock.sealedActionCountinteger
clock.serverTimetimestamp
asOftimestamp

GET /v1/markets/{market}

Spot market details and recent opened orders.

ParameterType
marketstring, path

Response 200:

FieldType
marketobject
market.idstring
market.pairstring
market.addressstring
market.baseobject
market.base.mintstring
market.base.symbolstring
market.base.namestring
market.base.decimalsinteger
market.base.assetIdinteger (optional)
market.quoteobject
market.quote.mintstring
market.quote.symbolstring
market.quote.namestring
market.quote.decimalsinteger
market.quote.assetIdinteger (optional)
market.pricePrecisioninteger
market.lastClearingPricedecimal string
market.priceChange24hPctsigned decimal string
market.volume24hBaseinteger string
market.volume24hQuoteinteger string
market.vaultIdstring
market.vaultDepthobject
market.vaultDepth.baseReserveinteger string
market.vaultDepth.quoteReserveinteger string
market.vaultDepth.totalValueQuoteinteger string
market.feeBpsinteger or null
market.nextBatchClosesAttimestamp
market.lastBatchNumberinteger
market.statusactive | paused
clockobject
clock.batchNumberinteger
clock.stateopen | sealed | opening | cleared | settled
clock.openedAttimestamp
clock.closesAttimestamp
clock.batchLengthSecondsinteger
clock.drandRoundinteger
clock.sealedActionCountinteger
clock.serverTimetimestamp
recentOrdersarray of object
recentOrders[].idstring
recentOrders[].batchNumberinteger
recentOrders[].marketIdstring
recentOrders[].sidebuy | sell
recentOrders[].orderTypelimit | market
recentOrders[].amountBaseinteger string
recentOrders[].limitPricedecimal string or null
recentOrders[].filledBaseinteger string
recentOrders[].filledQuoteinteger string
recentOrders[].clearingPricedecimal string
recentOrders[].statusfilled | partially_filled | unfilled
recentOrders[].settledAttimestamp
asOftimestamp

GET /v1/markets/{market}/prices

Per-batch clearing price history.

ParameterType
marketstring, path
beforeBatchinteger, query, optional
limitinteger, query, optional, default 60

Response 200:

FieldType
marketIdstring
pricePrecisioninteger
pointsarray of object
points[].batchNumberinteger
points[].timestamptimestamp
points[].clearingPricedecimal string
points[].matchedVolumeBaseinteger string
points[].matchedVolumeQuoteinteger string
points[].orderCountinteger
asOftimestamp

GET /v1/markets/{market}/candles

OHLC candles from clearing prices.

ParameterType
marketstring, path
intervalM1 | M5 | M15 | H1 | H4 | D1, query, optional, default M5
fromtimestamp, query, optional
totimestamp, query, optional
limitinteger, query, optional, default 120

Response 200:

FieldType
marketIdstring
intervalM1 | M5 | M15 | H1 | H4 | D1
pricePrecisioninteger
candlesarray of object
candles[].startAttimestamp
candles[].opendecimal string
candles[].highdecimal string
candles[].lowdecimal string
candles[].closedecimal string
candles[].volumeBaseinteger string
candles[].volumeQuoteinteger string
candles[].batchCountinteger
asOftimestamp

GET /v1/markets/{market}/orders

Opened orders from recent batches (without owners).

ParameterType
marketstring, path
cursorstring, query, optional
limitinteger, query, optional, default 24
batchNumberinteger, query, optional

Response 200:

FieldType
itemsarray of object
items[].idstring
items[].batchNumberinteger
items[].marketIdstring
items[].sidebuy | sell
items[].orderTypelimit | market
items[].amountBaseinteger string
items[].limitPricedecimal string or null
items[].filledBaseinteger string
items[].filledQuoteinteger string
items[].clearingPricedecimal string
items[].statusfilled | partially_filled | unfilled
items[].settledAttimestamp
pageobject
page.nextCursorstring or null
page.hasMoreboolean
asOftimestamp

Lending pools

GET /v1/pools

List lending pools.

Response 200:

FieldType
itemsarray of object
items[].idstring
items[].addressstring
items[].vaultIdstring
items[].assetobject
items[].asset.mintstring
items[].asset.symbolstring
items[].asset.namestring
items[].asset.decimalsinteger
items[].asset.assetIdinteger (optional)
items[].oraclePriceUsddecimal string
items[].pricePrecisioninteger
items[].supplyAprPctdecimal string
items[].borrowAprPctdecimal string
items[].totalSuppliedinteger string
items[].totalBorrowedinteger string
items[].availableLiquidityinteger string
items[].utilizationPctdecimal string
items[].collateralFactorBpsinteger
items[].liquidationThresholdBpsinteger
items[].liquidationBonusBpsinteger
items[].reserveFactorBpsinteger or null
items[].sharePricedecimal string
items[].heartbeatSecondsinteger
items[].statusactive | paused
asOftimestamp

GET /v1/pools/{asset}

Lending pool details and rate history.

ParameterType
assetstring, path

Response 200:

FieldType
poolobject
pool.idstring
pool.addressstring
pool.vaultIdstring
pool.assetobject
pool.asset.mintstring
pool.asset.symbolstring
pool.asset.namestring
pool.asset.decimalsinteger
pool.asset.assetIdinteger (optional)
pool.oraclePriceUsddecimal string
pool.pricePrecisioninteger
pool.supplyAprPctdecimal string
pool.borrowAprPctdecimal string
pool.totalSuppliedinteger string
pool.totalBorrowedinteger string
pool.availableLiquidityinteger string
pool.utilizationPctdecimal string
pool.collateralFactorBpsinteger
pool.liquidationThresholdBpsinteger
pool.liquidationBonusBpsinteger
pool.reserveFactorBpsinteger or null
pool.sharePricedecimal string
pool.heartbeatSecondsinteger
pool.statusactive | paused
historyarray of object
history[].batchNumberinteger
history[].timestamptimestamp
history[].supplyAprPctdecimal string
history[].borrowAprPctdecimal string
history[].totalSuppliedinteger string
history[].totalBorrowedinteger string
history[].utilizationPctdecimal string
history[].sharePricedecimal string
asOftimestamp

GET /v1/pools/{asset}/history

Lending pool rate and total history.

ParameterType
assetstring, path
limitinteger, query, optional, default 48

Response 200:

FieldType
poolIdstring
assetobject
asset.mintstring
asset.symbolstring
asset.namestring
asset.decimalsinteger
asset.assetIdinteger (optional)
pointsarray of object
points[].batchNumberinteger
points[].timestamptimestamp
points[].supplyAprPctdecimal string
points[].borrowAprPctdecimal string
points[].totalSuppliedinteger string
points[].totalBorrowedinteger string
points[].utilizationPctdecimal string
points[].sharePricedecimal string
asOftimestamp

Perp markets

GET /v1/perps

List perp markets.

Response 200:

FieldType
itemsarray of object
items[].idstring
items[].namestring
items[].addressstring
items[].baseobject
items[].base.mintstring
items[].base.symbolstring
items[].base.namestring
items[].base.decimalsinteger
items[].base.assetIdinteger (optional)
items[].quoteobject
items[].quote.mintstring
items[].quote.symbolstring
items[].quote.namestring
items[].quote.decimalsinteger
items[].quote.assetIdinteger (optional)
items[].collateralobject
items[].collateral.mintstring
items[].collateral.symbolstring
items[].collateral.namestring
items[].collateral.decimalsinteger
items[].collateral.assetIdinteger (optional)
items[].vaultIdstring
items[].oracleAddressstring
items[].pricePrecisioninteger
items[].oraclePricedecimal string
items[].priceChange24hPctsigned decimal string
items[].fundingRateHourlyPctsigned decimal string
items[].fundingIndexsigned decimal string
items[].openInterestLongBaseinteger string
items[].openInterestShortBaseinteger string
items[].openInterestLongQuoteinteger string
items[].openInterestShortQuoteinteger string
items[].vaultSizeQuoteinteger string
items[].maxLeveragedecimal string
items[].maintenanceMarginBpsinteger
items[].liquidationBonusBpsinteger
items[].openFeeBpsinteger or null
items[].closeFeeBpsinteger or null
items[].heartbeatSecondsinteger
items[].volume24hQuoteinteger string
items[].statusactive | paused
asOftimestamp

GET /v1/perps/{market}

Perp market details.

ParameterType
marketstring, path

Response 200:

FieldType
marketobject
market.idstring
market.namestring
market.addressstring
market.baseobject
market.base.mintstring
market.base.symbolstring
market.base.namestring
market.base.decimalsinteger
market.base.assetIdinteger (optional)
market.quoteobject
market.quote.mintstring
market.quote.symbolstring
market.quote.namestring
market.quote.decimalsinteger
market.quote.assetIdinteger (optional)
market.collateralobject
market.collateral.mintstring
market.collateral.symbolstring
market.collateral.namestring
market.collateral.decimalsinteger
market.collateral.assetIdinteger (optional)
market.vaultIdstring
market.oracleAddressstring
market.pricePrecisioninteger
market.oraclePricedecimal string
market.priceChange24hPctsigned decimal string
market.fundingRateHourlyPctsigned decimal string
market.fundingIndexsigned decimal string
market.openInterestLongBaseinteger string
market.openInterestShortBaseinteger string
market.openInterestLongQuoteinteger string
market.openInterestShortQuoteinteger string
market.vaultSizeQuoteinteger string
market.maxLeveragedecimal string
market.maintenanceMarginBpsinteger
market.liquidationBonusBpsinteger
market.openFeeBpsinteger or null
market.closeFeeBpsinteger or null
market.heartbeatSecondsinteger
market.volume24hQuoteinteger string
market.statusactive | paused
asOftimestamp

GET /v1/perps/{market}/prices

Oracle price history and candles for a perp market.

ParameterType
marketstring, path
intervalM1 | M5 | M15 | H1 | H4 | D1, query, optional, default M5
limitinteger, query, optional, default 60

Response 200:

FieldType
marketIdstring
pricePrecisioninteger
pointsarray of object
points[].timestamptimestamp
points[].slotstring
points[].pricedecimal string
points[].confidencedecimal string
candlesarray of object
candles[].startAttimestamp
candles[].opendecimal string
candles[].highdecimal string
candles[].lowdecimal string
candles[].closedecimal string
candles[].volumeBaseinteger string
candles[].volumeQuoteinteger string
candles[].batchCountinteger
asOftimestamp

Vaults

GET /v1/vaults

List earn vaults.

Response 200:

FieldType
itemsarray of object
items[].idstring
items[].namestring
items[].addressstring
items[].kindspot_liquidity | lending_pool | perps_vault
items[].marketOrPoolIdstring
items[].assetsarray of object
items[].assets[].mintstring
items[].assets[].symbolstring
items[].assets[].namestring
items[].assets[].decimalsinteger
items[].assets[].assetIdinteger (optional)
items[].earnsFromstring
items[].apyPctdecimal string
items[].apy7dPctdecimal string
items[].totalValueQuoteinteger string
items[].totalSharesinteger string
items[].sharePricedecimal string
items[].compositionarray of object
items[].composition[].assetobject
items[].composition[].asset.mintstring
items[].composition[].asset.symbolstring
items[].composition[].asset.namestring
items[].composition[].asset.decimalsinteger
items[].composition[].asset.assetIdinteger (optional)
items[].composition[].amountinteger string
items[].composition[].valueQuoteinteger string
items[].composition[].weightPctdecimal string
items[].statusactive | paused
asOftimestamp

GET /v1/vaults/{vault}

Vault details, composition and earnings history.

ParameterType
vaultstring, path

Response 200:

FieldType
vaultobject
vault.idstring
vault.namestring
vault.addressstring
vault.kindspot_liquidity | lending_pool | perps_vault
vault.marketOrPoolIdstring
vault.assetsarray of object
vault.assets[].mintstring
vault.assets[].symbolstring
vault.assets[].namestring
vault.assets[].decimalsinteger
vault.assets[].assetIdinteger (optional)
vault.earnsFromstring
vault.apyPctdecimal string
vault.apy7dPctdecimal string
vault.totalValueQuoteinteger string
vault.totalSharesinteger string
vault.sharePricedecimal string
vault.compositionarray of object
vault.composition[].assetobject
vault.composition[].asset.mintstring
vault.composition[].asset.symbolstring
vault.composition[].asset.namestring
vault.composition[].asset.decimalsinteger
vault.composition[].asset.assetIdinteger (optional)
vault.composition[].amountinteger string
vault.composition[].valueQuoteinteger string
vault.composition[].weightPctdecimal string
vault.statusactive | paused
historyarray of object
history[].batchNumberinteger
history[].timestamptimestamp
history[].apyPctdecimal string
history[].totalValueQuoteinteger string
history[].sharePricedecimal string
asOftimestamp

Batches

GET /v1/batches

Paged stream of batches (open batch shows count and countdown only).

ParameterType
cursorstring, query, optional
limitinteger, query, optional, default 24
stateopen | sealed | opening | cleared | settled, query, optional

Response 200:

FieldType
itemsarray of object, one of 5 shapes
pageobject
page.nextCursorstring or null
page.hasMoreboolean
asOftimestamp

GET /v1/batches/{batch}

Single batch record (open batch shows sealed count and countdown only).

ParameterType
batchinteger, path

Response 200, by state:

When state is open:

FieldType
batchNumberinteger
openedAttimestamp
closesAttimestamp
batchLengthSecondsinteger
drandRoundinteger
sealedActionCountinteger
serverTimetimestamp

When state is sealed or opening:

FieldType
batchNumberinteger
openedAttimestamp
closesAttimestamp
batchLengthSecondsinteger
drandRoundinteger
sealedActionCountinteger
openedActionCountinteger
serverTimetimestamp

When state is cleared or settled:

FieldType
batchNumberinteger
openedAttimestamp
closesAttimestamp
clearedAttimestamp
settledAttimestamp or null
batchLengthSecondsinteger
drandRoundinteger
sealedActionCountinteger
openedActionCountinteger
totalVolumeQuoteinteger string
marketsarray of object
markets[].marketIdstring
markets[].pairstring
markets[].baseobject
markets[].base.mintstring
markets[].base.symbolstring
markets[].base.namestring
markets[].base.decimalsinteger
markets[].base.assetIdinteger (optional)
markets[].quoteobject
markets[].quote.mintstring
markets[].quote.symbolstring
markets[].quote.namestring
markets[].quote.decimalsinteger
markets[].quote.assetIdinteger (optional)
markets[].pricePrecisioninteger
markets[].clearingPricedecimal string
markets[].matchedVolumeBaseinteger string
markets[].matchedVolumeQuoteinteger string
markets[].vaultNetBaseDeltasigned integer string
markets[].vaultNetQuoteDeltasigned integer string
markets[].orderCountinteger
markets[].ordersarray of object
markets[].orders[].idstring
markets[].orders[].batchNumberinteger
markets[].orders[].marketIdstring
markets[].orders[].sidebuy | sell
markets[].orders[].orderTypelimit | market
markets[].orders[].amountBaseinteger string
markets[].orders[].limitPricedecimal string or null
markets[].orders[].filledBaseinteger string
markets[].orders[].filledQuoteinteger string
markets[].orders[].clearingPricedecimal string
markets[].orders[].statusfilled | partially_filled | unfilled
markets[].orders[].settledAttimestamp
poolChangesarray of object
poolChanges[].poolIdstring
poolChanges[].assetobject
poolChanges[].asset.mintstring
poolChanges[].asset.symbolstring
poolChanges[].asset.namestring
poolChanges[].asset.decimalsinteger
poolChanges[].asset.assetIdinteger (optional)
poolChanges[].suppliedDeltasigned integer string
poolChanges[].borrowedDeltasigned integer string
poolChanges[].totalSuppliedAfterinteger string
poolChanges[].totalBorrowedAfterinteger string
poolChanges[].sharePriceAfterdecimal string
vaultChangesarray of object
vaultChanges[].vaultIdstring
vaultChanges[].kindspot_liquidity | lending_pool | perps_vault
vaultChanges[].depositedDeltasigned integer string
vaultChanges[].withdrawnDeltasigned integer string
vaultChanges[].totalValueQuoteAfterinteger string
vaultChanges[].sharePriceAfterdecimal string
perpChangesarray of object
perpChanges[].marketIdstring
perpChanges[].oraclePricedecimal string
perpChanges[].openInterestLongDeltasigned integer string
perpChanges[].openInterestShortDeltasigned integer string
perpChanges[].fundingRateHourlyPctsigned decimal string
settlementSignaturesarray of string

Notes

GET /v1/notes

Encrypted Mesa notes by view tag, paged by slot cursor.

ParameterType
tagstring, query, optional
afterSlotstring, query, optional
beforeSlotstring, query, optional
paginationTokenstring, query, optional
limitinteger, query, optional, default 100

Response 200:

FieldType
contextobject
context.slotstring
context.blockTimeinteger
outputTreeIdinteger
viewTagstring
dataarray of object
data[].slotstring
data[].signaturestring
data[].blockTimeinteger or null
data[].outputsarray of object
data[].outputs[].slotstring
data[].outputs[].txSignaturestring
data[].outputs[].txViewingPkbase64 or null
data[].outputs[].saltbase64 or null
data[].outputs[].outputSlotobject
data[].outputs[].outputSlot.viewTagstring
data[].outputs[].outputSlot.outputContextobject
data[].outputs[].outputSlot.payloadbase64
paginationTokenstring or null
asOftimestamp

GET /v1/notes/transactions

Shielded Mesa transactions by view tag, paged by slot cursor.

ParameterType
tagstring, query, optional
afterSlotstring, query, optional
beforeSlotstring, query, optional
paginationTokenstring, query, optional
limitinteger, query, optional, default 100

Response 200:

FieldType
contextobject
context.slotstring
context.blockTimeinteger
outputTreeIdinteger
viewTagstring
dataarray of object
data[].slotstring
data[].signaturestring
data[].blockTimeinteger or null
data[].eventsarray of object
data[].events[].slotstring
data[].events[].txSignaturestring
data[].events[].eventIndexinteger
data[].events[].txViewingPkbase64 or null
data[].events[].saltbase64 or null
data[].events[].outputSlotsarray of object
data[].events[].outputSlots[].viewTagstring
data[].events[].outputSlots[].outputContextobject
data[].events[].outputSlots[].payloadbase64
data[].events[].messagesarray of object
data[].events[].messages[].viewTagstring
data[].events[].messages[].payloadbase64
data[].events[].nullifiersarray of string
data[].events[].prooflessboolean
data[].events[].ringConfigstring (optional)
data[].events[].ringProgramIdstring (optional)
paginationTokenstring or null
asOftimestamp

POST /v1/notes/merkle-proofs

Merkle inclusion proofs for note commitments.

Request body:

FieldType
treeAccountstring
leavesarray of string

Response 200:

FieldType
contextobject
context.slotstring
context.blockTimeinteger
proofsarray of object
proofs[].leafstring
proofs[].leafIndexstring
proofs[].merkleContextobject
proofs[].merkleContext.treestring
proofs[].merkleContext.treeTypeinteger
proofs[].patharray of string
proofs[].rootstring
proofs[].rootSeqstring
proofs[].rootIndexinteger
asOftimestamp

POST /v1/notes/nullifiers

Check which nullifiers have been spent.

Request body:

FieldType
nullifiersarray of string

Response 200:

FieldType
contextobject
context.slotstring
context.blockTimeinteger
spentarray of string
statusesobject
asOftimestamp

Transactions

POST /v1/relay

Relay a wallet-less Mesa action as fee payer.

Request body:

FieldType
actionplace_order | reclaim | supply | redeem | borrow | repay | renew | close_position | perp_open | perp_close | perp_add_collateral | perp_remove_collateral | vault_deposit | vault_withdraw | withdraw | consolidate | liquidate
batchNumberinteger (optional)
marketIdstring (optional)
proofBytesbase64 (optional)
sppTransactDatabase64 (optional)
publicInputsbase64 (optional)
timelockCiphertextbase64 (optional)
instructionsarray of object (optional)
instructions[].programIdstring
instructions[].accountsarray of object
instructions[].accounts[].pubkeystring
instructions[].accounts[].isSignerboolean
instructions[].accounts[].isWritableboolean
instructions[].dataBase64base64
computeUnitLimitinteger (optional)
priorityFeeMicroLamportsstring (optional)
idempotencyKeystring

Response 201:

FieldType
idstring
actionplace_order | reclaim | supply | redeem | borrow | repay | renew | close_position | perp_open | perp_close | perp_add_collateral | perp_remove_collateral | vault_deposit | vault_withdraw | withdraw | consolidate | liquidate
statuspending | submitted | unconfirmed | confirmed | finalized | failed | expired
signaturestring (optional)
batchNumberinteger or null
submittedAttimestamp

POST /v1/transactions/build

Build an unsigned v0 transaction for wallet-signed deposit or registration.

Request body:

FieldType
kindrings_register | rings_deposit | rings_withdraw | mesa_deposit
walletstring
assetMintstring (optional)
amountstring (optional)
proofBytesbase64 (optional)
sppTransactDatabase64 (optional)
publicInputsbase64 (optional)
instructionsarray of object (optional)
instructions[].programIdstring
instructions[].accountsarray of object
instructions[].accounts[].pubkeystring
instructions[].accounts[].isSignerboolean
instructions[].accounts[].isWritableboolean
instructions[].dataBase64base64
computeUnitLimitinteger (optional)
priorityFeeMicroLamportsstring (optional)
idempotencyKeystring

Response 200:

FieldType
idstring
transactionBase64base64
blockhashstring
lastValidBlockHeightinteger
cosignedboolean
expiresAttimestamp
kindrings_register | rings_deposit | rings_withdraw | mesa_deposit

POST /v1/transactions/submit

Submit a wallet-signed transaction (relay or wallet-sent).

Request body, by mode:

When mode is relay:

FieldType
buildIdstring
signedTransactionBase64base64
idempotencyKeystring

When mode is wallet-sent:

FieldType
buildIdstring
signaturestring
idempotencyKeystring

Response 200:

FieldType
idstring
statuspending | submitted | unconfirmed | confirmed | finalized | failed | expired
signaturestring (optional)
slotstring (optional)
batchNumberinteger or null (optional)
errorobject (optional)
error.stagebuild | wallet-rejected | wallet-changed | simulation | send | confirm
error.messagestring
error.nextStepstring (optional)
error.retryableboolean
error.programobject (optional)
error.program.addressstring
error.program.codeinteger or null
error.program.namestring or null
updatedAttimestamp

GET /v1/transactions/{id}

Poll transaction status by tracking id.

ParameterType
idstring, path

Response 200:

FieldType
idstring
statuspending | submitted | unconfirmed | confirmed | finalized | failed | expired
signaturestring (optional)
slotstring (optional)
batchNumberinteger or null (optional)
errorobject (optional)
error.stagebuild | wallet-rejected | wallet-changed | simulation | send | confirm
error.messagestring
error.nextStepstring (optional)
error.retryableboolean
error.programobject (optional)
error.program.addressstring
error.program.codeinteger or null
error.program.namestring or null
updatedAttimestamp

POST /v1/prove

Generate a Groth16 proof if browser proving is unavailable.

Request body:

FieldType
circuitdeposit | withdraw | place | reclaim | settle | renew | repay | close_position | liquidate | sweep
witnessBase64base64

Response 200:

FieldType
circuitdeposit | withdraw | place | reclaim | settle | renew | repay | close_position | liquidate | sweep
proofBase64base64
publicInputsBase64base64
provingMsinteger

Positions

GET /v1/positions/lapsed

List lapsed positions eligible for liquidation checks.

Response 200:

FieldType
itemsarray of object
items[].idstring
items[].kindborrow | perp
items[].marketIdstring or null
items[].targetAddressstring or null
items[].collateralIndexinteger
items[].slotstring
items[].deadlineAttimestamp or null
items[].deadlineSecondsstring or null
items[].tlockOpenboolean
items[].ciphertextBase64base64
items[].positionNoteHashstring or null
items[].positionAccountstring or null
asOftimestamp

Watcher

GET /v1/watcher/enrolments

List watcher enrolments for one or more position ids.

ParameterType
positionIdstring, query, optional
positionIdsstring, query, optional

Response 200:

FieldType
itemsarray of object
items[].idstring
items[].positionIdstring
items[].positionKindborrow | perp
items[].statusactive | renewing | lapsed | removed
items[].enrolledAttimestamp
items[].lastRenewedAttimestamp or null
items[].nextDeadlineAttimestamp
items[].renewCountinteger
asOftimestamp

POST /v1/watcher/enrolments

Enrol a sealed position with its read-only key.

Request body:

FieldType
positionIdstring
positionKindborrow | perp
readOnlyKeybase64
nextDeadlineAttimestamp (optional)

Response 201:

FieldType
idstring
positionIdstring
positionKindborrow | perp
statusactive | renewing | lapsed | removed
enrolledAttimestamp
lastRenewedAttimestamp or null
nextDeadlineAttimestamp
renewCountinteger

DELETE /v1/watcher/enrolments/{positionId}

Remove a watcher enrolment authorized by its read-only key.

ParameterType
positionIdstring, path

Request body:

FieldType
readOnlyKeybase64

Response 200:

FieldType
positionIdstring
removedboolean
removedAttimestamp