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/transactionslook up the cap table fromissuerIdin 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/createandPOST /issuer/registertake 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/stockand the stakeholder wallet routes are not.
Errors
| Status | When |
|---|---|
| 400 | issuerId 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. |
| 404 | The issuer doesn’t exist, on /issuer/id, /issuer/full, /cap-table/holdings/stock, /issuer/reconcile, and /issuer/poller-catchup. |
| 500 | Everything 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/stockdivides 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
| Method | Route | Writes | Body | Returns |
|---|---|---|---|---|
| POST | /factory/register | MongoDB | factory_address, implementation_address | { factory } |
| POST | /issuer/create | Onchain + MongoDB | Issuer fields; see Create an Issuer | { issuer } |
| POST | /issuer/register | MongoDB | Issuer 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/:id | Read | None | The issuer document |
| GET | /issuer/total-number | Read | None | Issuer count |
| GET | /issuer/by-deployer/:address | Read | None | { issuers, count }: issuers whose deployed_by matches, case-insensitive |
| POST | /issuer/summaries | Read | { ids: [...] } | { summaries }: counts of people, classes, and issuances per issuer, plus readiness flags |
| POST | /issuer/reconcile | MongoDB | { issuerId } | Sync flags corrected from chain reads, and missing transaction hashes filled in |
| POST | /issuer/poller-catchup | MongoDB | { 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.
| Method | Route | Writes | Body | Returns |
|---|---|---|---|---|
| GET | /stakeholder/id/:id | Onchain read | issuerId | stakeholderId, type, role |
| GET | /stakeholder/wallet/:address | Onchain read | issuerId | { stakeholderId }, or a 500 if no stakeholder has the wallet |
| GET | /stakeholder/total-number | Onchain read | issuerId | Stakeholder count |
| GET | /stakeholder/issuer_assigned_id/:id | Read | issuerId | Stakeholders with that issuer_assigned_id across all issuers |
| GET | /stakeholder/issuer/:issuerId/issuer_assigned_id/:id | Read | issuerId | Stakeholders with that issuer_assigned_id in one issuer |
| POST | /stakeholder/create | Onchain + MongoDB | issuerId, data | { stakeholder } |
| POST | /stakeholder/register-onchain | MongoDB | issuerId, id (the UUID used onchain), data, optional tx_hash | { stakeholder }, saved as synced |
| POST | /stakeholder/add-wallet | Onchain | issuerId, id, wallet | "Success" or "Wallet already added" |
| POST | /stakeholder/remove-wallet | Onchain | issuerId, id, wallet | "Success" |
Stock classes
Every route here needs issuerId in the body.
| Method | Route | Writes | Body | Returns |
|---|---|---|---|---|
| GET | /stock-class/id/:id | Onchain read | issuerId | stockClassId (bytes16), classType, and pricePerShare, sharesIssued, sharesAuthorized as human-value strings |
| GET | /stock-class/total-number | Onchain read | issuerId | Stock class count |
| POST | /stock-class/create | Onchain + MongoDB | issuerId, data | { stockClass } |
| POST | /stock-class/register-onchain | MongoDB | issuerId, id (the UUID used onchain), data, optional tx_hash | { stockClass }, saved as synced |
Holdings and history
| Method | Route | Writes | Body | Returns |
|---|---|---|---|---|
| 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/:issuerId | Read | None | History 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.
| Route | Role | data fields | Returns |
|---|---|---|---|
POST /transactions/issuance/stock | OPERATOR | stakeholder_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/stock | OPERATOR | transferorId, transfereeId, stockClassId, quantity, sharePrice, isBuyerVerified | "success" |
POST /transactions/cancel/stock | OPERATOR | stakeholderId, stockClassId, security_id, quantity, reason_text (comments) | { stockCancellation } |
POST /transactions/retract/stock | OPERATOR | stakeholderId, stockClassId, security_id, reason_text (comments) | { stockRetraction } |
POST /transactions/reissue/stock | OPERATOR | stakeholderId, stockClassId, security_id, resulting_security_ids (reason_text, comments) | { stockReissuance } |
POST /transactions/repurchase/stock | OPERATOR | stakeholderId, stockClassId, security_id, quantity, price (consideration_text, comments) | { stockRepurchase } |
POST /transactions/accept/stock | OPERATOR | stakeholderId, stockClassId, security_id (comments) | { stockAcceptance } |
POST /transactions/adjust/issuer/authorized-shares | ADMIN | issuer_id, new_shares_authorized (board_approval_date, stockholder_approval_date, comments) | { issuerAuthorizedSharesAdj } |
POST /transactions/adjust/stock-class/authorized-shares | ADMIN | stock_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": { ... } }.
| Record | Create | Returns | Read by id | Count |
|---|---|---|---|---|
| Stock legend | POST /stock-legend/create | { stockLegend } | GET /stock-legend/id/:id | GET /stock-legend/total-number |
| Stock plan | POST /stock-plan/create | { stockPlan } | GET /stock-plan/id/:id | GET /stock-plan/total-number |
| Valuation | POST /valuation/create | { valuation } | GET /valuation/id/:id | GET /valuation/total-number |
| Vesting terms | POST /vesting-terms/create | { vestingTerms } | GET /vesting-terms/id/:id | GET /vesting-terms/total-number |
| Equity compensation | POST /transactions/issuance/equity-compensation | { equityCompensationIssuance } | None | None |
| Convertible | POST /transactions/issuance/convertible | { convertibleIssuance } | None | None |
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_authorizedsaved on the issuer and stock class records in MongoDB. Read current caps from the contract, or fromGET /stock-class/id/:id. - Records written by older server versions can be out of date: stakeholders and stock classes from
/stakeholder/createor/stock-class/createmay have a MongoDB_idthat doesn’t match their onchain id, so they stayis_onchain_synced: falseand revert in later server-signed writes (NoStakeholder,InvalidStockClass). Register each one again with/register-onchainunder its onchain id and delete the old record. Adjustment history rows from those versions holdnew_shares_authorized×1e10, an emptyissuer_id, and nostock_class_iduntil 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.