Skip to Content
API ReferenceAPI Reference

API Reference

Base URL: http://localhost:8293. Requests and responses are JSON.

The product app under /app sends onchain writes from the issuer’s wallet and uses the API for reads and metadata. Every route below can also be called directly, including the server-signed routes that write onchain with the server’s key.

Server-signed routes

Routes marked Onchain send a transaction from the server. They sign with PRIVATE_KEY from the root .env, and that wallet needs a role on the cap table:

  • OPERATOR or ADMIN for the stakeholder, stock class, wallet, and stock transaction routes.
  • ADMIN for the two authorized-share adjustments.

A cap table created with POST /issuer/create makes the server key its ADMIN. For a cap table minted in the app, set NEXT_PUBLIC_OPERATOR_ADDRESS to the server key’s address before minting, or have the issuer admin grant the role later with addOperator. Without a role, the transaction reverts with Does not have operator role or Does not have admin role.

With PRIVATE_KEY unset or left as UPDATE_ME, the server is read-only: reads and the event poller still work, and server-signed routes fail.

The API doesn’t authenticate callers. Anyone who can reach it can make the server sign transactions, so never expose it with a funded key.

Request conventions

  • Routes under /stakeholder, /stock-class, and /transactions look up the cap table from issuerId in the JSON body. That includes their GET routes, so send a body and set the method explicitly:

    curl -s -X GET "$API/stakeholder/id/$STAKEHOLDER_ID" \ -H "Content-Type: application/json" \ -d @- <<JSON { "issuerId": "$ISSUER_ID" } JSON
  • Most create routes take { "issuerId": "...", "data": { ... } }. POST /issuer/create and POST /issuer/register take the issuer fields at the top level.

  • Create routes, stock issuance, cancel, retract, reissue, repurchase, acceptance, and both share adjustments are validated against the pinned OCF schemas, which reject unknown fields. POST /transactions/transfer/stock and the stakeholder wallet routes are not.

Errors

StatusWhen
400issuerId is missing (issuerId is required) or unknown (Issuer not found) on a route that needs it, deployed_to or tx_hash is missing on /issuer/register, an issuance sends more than one share_numbers_issued range, or the app’s issuance check finds too few authorized shares or a stock class that isn’t onchain.
404The issuer doesn’t exist, on /issuer/id, /issuer/full, /cap-table/holdings/stock, /issuer/reconcile, and /issuer/poller-catchup.
500Everything else, including OCF validation failures and contract reverts. The body is the error message as text.

Scaling

The contract stores quantities, prices, and authorized-share counts as integers scaled by 1e10 (10,000,000,000).

  • Send human values as strings, such as "100000" shares at "4.20". Server-signed routes scale them before calling the contract.
  • The event poller divides by 1e10 before it writes history, and /cap-table/holdings/stock divides the chain reads it returns.
  • If you read the contract directly, divide by 1e10 yourself. A price of 4.20 is stored as 42000000000.

Health checks

Each router answers GET at its root with a short text reply: /, /factory, /issuer, /cap-table, /stock-legend, /stock-plan, /valuation, and /vesting-terms. /stakeholder and /stock-class answer too, but need an issuerId body like their other routes.

Issuer and factory

MethodRouteWritesBodyReturns
POST/factory/registerMongoDBfactory_address, implementation_address{ factory }
POST/issuer/createOnchain + MongoDBIssuer fields; see Create an Issuer{ issuer }
POST/issuer/registerMongoDBIssuer fields, plus deployed_to and tx_hash (required), id (the bytes16 sent to createCapTable; its UUID form becomes the record’s _id), and deployed_by (the admin wallet){ issuer }
GET/issuer/id/:id, /issuer/full/:idReadNoneThe issuer document
GET/issuer/total-numberReadNoneIssuer count
GET/issuer/by-deployer/:addressReadNone{ issuers, count }: issuers whose deployed_by matches, case-insensitive
POST/issuer/summariesRead{ ids: [...] }{ summaries }: counts of people, classes, and issuances per issuer, plus readiness flags
POST/issuer/reconcileMongoDB{ issuerId }Sync flags corrected from chain reads, and missing transaction hashes filled in
POST/issuer/poller-catchupMongoDB{ issuerId, mode }Resets the poller cursor. reindex (the default) replays events from the deploy block; head skips to the chain head.

Stakeholders

Every route here needs issuerId in the body.

MethodRouteWritesBodyReturns
GET/stakeholder/id/:idOnchain readissuerIdstakeholderId, type, role
GET/stakeholder/wallet/:addressOnchain readissuerId{ stakeholderId }, or a 500 if no stakeholder has the wallet
GET/stakeholder/total-numberOnchain readissuerIdStakeholder count
GET/stakeholder/issuer_assigned_id/:idReadissuerIdStakeholders with that issuer_assigned_id across all issuers
GET/stakeholder/issuer/:issuerId/issuer_assigned_id/:idReadissuerIdStakeholders with that issuer_assigned_id in one issuer
POST/stakeholder/createOnchain + MongoDBissuerId, data{ stakeholder }
POST/stakeholder/register-onchainMongoDBissuerId, id (the UUID used onchain), data, optional tx_hash{ stakeholder }, saved as synced
POST/stakeholder/add-walletOnchainissuerId, id, wallet"Success" or "Wallet already added"
POST/stakeholder/remove-walletOnchainissuerId, id, wallet"Success"

Stock classes

Every route here needs issuerId in the body.

MethodRouteWritesBodyReturns
GET/stock-class/id/:idOnchain readissuerIdstockClassId (bytes16), classType, and pricePerShare, sharesIssued, sharesAuthorized as human-value strings
GET/stock-class/total-numberOnchain readissuerIdStock class count
POST/stock-class/createOnchain + MongoDBissuerId, data{ stockClass }
POST/stock-class/register-onchainMongoDBissuerId, id (the UUID used onchain), data, optional tx_hash{ stockClass }, saved as synced

Holdings and history

MethodRouteWritesBodyReturns
GET/cap-table/holdings/stock?issuerId=...Read (chain and MongoDB)None{ holdings, stockClasses, stakeholders, issuer, meta }; see View Cap Table
GET/historical-transactions/issuer-id/:issuerIdReadNoneHistory rows; see Historical Transactions

Stock transactions

All of these write onchain, add history rows, and take { "issuerId": "...", "data": { ... } }. Fields in parentheses are optional. Except for transfers, each returns the OCF object it validated: its id is a placeholder and date is the server’s UTC date, because the contract assigns the real ids.

RouteRoledata fieldsReturns
POST /transactions/issuance/stockOPERATORstakeholder_id, stock_class_id, quantity, share_price, stock_legend_ids, custom_id, security_law_exemptions (comments, issuance_type, stock_plan_id, vesting_terms_id, board_approval_date, stockholder_approval_date, consideration_text, cost_basis, one share_numbers_issued range){ stockIssuance }
POST /transactions/transfer/stockOPERATORtransferorId, transfereeId, stockClassId, quantity, sharePrice, isBuyerVerified"success"
POST /transactions/cancel/stockOPERATORstakeholderId, stockClassId, security_id, quantity, reason_text (comments){ stockCancellation }
POST /transactions/retract/stockOPERATORstakeholderId, stockClassId, security_id, reason_text (comments){ stockRetraction }
POST /transactions/reissue/stockOPERATORstakeholderId, stockClassId, security_id, resulting_security_ids (reason_text, comments){ stockReissuance }
POST /transactions/repurchase/stockOPERATORstakeholderId, stockClassId, security_id, quantity, price (consideration_text, comments){ stockRepurchase }
POST /transactions/accept/stockOPERATORstakeholderId, stockClassId, security_id (comments){ stockAcceptance }
POST /transactions/adjust/issuer/authorized-sharesADMINissuer_id, new_shares_authorized (board_approval_date, stockholder_approval_date, comments){ issuerAuthorizedSharesAdj }
POST /transactions/adjust/stock-class/authorized-sharesADMINstock_class_id, new_shares_authorized (board_approval_date, stockholder_approval_date, comments){ stockClassAdjustment }

OPERATOR means OPERATOR or ADMIN. The contract assigns balance and resulting security ids, so leave balance_security_id and split_transaction_id out. On the routes that validate, balance_security_id is accepted only on cancel and repurchase, and split_transaction_id only on reissue. A field the schema does not list returns 500. For worked examples, see Transfer, Cancel, and Reissue Stock.

POST /transactions/issuance/stock/register-onchain is the check the app runs before the wallet sends issueStock. It validates an issuance body, reads the remaining authorized shares from the contract, and saves nothing. It returns 400 when the shares don’t fit or the stock class isn’t onchain.

Records stored only in MongoDB

These routes write nothing onchain and add no history rows. The create routes take { "issuerId": "...", "data": { ... } }.

RecordCreateReturnsRead by idCount
Stock legendPOST /stock-legend/create{ stockLegend }GET /stock-legend/id/:idGET /stock-legend/total-number
Stock planPOST /stock-plan/create{ stockPlan }GET /stock-plan/id/:idGET /stock-plan/total-number
ValuationPOST /valuation/create{ valuation }GET /valuation/id/:idGET /valuation/total-number
Vesting termsPOST /vesting-terms/create{ vestingTerms }GET /vesting-terms/id/:idGET /vesting-terms/total-number
Equity compensationPOST /transactions/issuance/equity-compensation{ equityCompensationIssuance }NoneNone
ConvertiblePOST /transactions/issuance/convertible{ convertibleIssuance }NoneNone

The last two live under /transactions, so they also need issuerId to pass the cap table lookup. See Supporting Records, Equity Compensation and Convertibles, and Valuations and Terms.

Known issues

  • Authorized-share adjustments change the contract but not the initial_shares_authorized saved on the issuer and stock class records in MongoDB. Read current caps from the contract, or from GET /stock-class/id/:id.
  • Records written by older server versions can be out of date: stakeholders and stock classes from /stakeholder/create or /stock-class/create may have a MongoDB _id that doesn’t match their onchain id, so they stay is_onchain_synced: false and revert in later server-signed writes (NoStakeholder, InvalidStockClass). Register each one again with /register-onchain under its onchain id and delete the old record. Adjustment history rows from those versions hold new_shares_authorized ×1e10, an empty issuer_id, and no stock_class_id until a poller reindex (POST /issuer/poller-catchup) rewrites them.
  • The contract doesn’t enforce every share-cap relationship; see Security.

Controllers behind these routes: Controllers.

Last updated on