web/docs/api/examples/marketplace.examples.md

174 lines
4.3 KiB
Markdown

# Marketplace API Examples (v1)
## `GET /marketplace/offers`
Success (`200`):
```json
{
"offers": [
{
"offer_id": "edut.governance.core",
"issuer_id": "edut.firstparty",
"title": "EDUT Governance Core",
"summary": "First paid runtime license.",
"status": "active",
"pricing": {
"currency": "USDC",
"amount_atomic": "499000000",
"decimals": 6,
"chain_id": 8453
},
"policies": {
"member_only": true,
"workspace_bound": true,
"transferable": false,
"internal_use_only": true,
"multi_tenant": false
}
}
]
}
```
## `POST /marketplace/checkout/quote`
Request:
```json
{
"wallet": "0x3ea6cbf98d23e2cf7b6f4f9bb1fb4f50b710f2d5",
"payer_wallet": "0x2299547f6fA9A8f9b6d9aEA9F9D8A4B53C8A0e11",
"offer_id": "edut.governance.core",
"org_root_id": "org.acme.root",
"principal_id": "human.joshua",
"principal_role": "org_root_owner",
"workspace_id": "workspace.work.acme.exec",
"ownership_proof": "0x9f20..."
}
```
Success (`200`):
```json
{
"quote_id": "cq_01HZZXFQ27ZP6MP0V2R9M6V3KX",
"wallet": "0x3ea6cbf98d23e2cf7b6f4f9bb1fb4f50b710f2d5",
"payer_wallet": "0x2299547f6fA9A8f9b6d9aEA9F9D8A4B53C8A0e11",
"offer_id": "edut.governance.core",
"org_root_id": "org.acme.root",
"principal_id": "human.joshua",
"principal_role": "org_root_owner",
"currency": "USDC",
"amount": "500.00",
"amount_atomic": "500000000",
"total_amount": "505.00",
"total_amount_atomic": "505000000",
"decimals": 6,
"membership_activation_included": true,
"line_items": [
{
"kind": "license",
"label": "Governance Core License",
"amount": "500.00",
"amount_atomic": "500000000",
"decimals": 6,
"currency": "USDC"
},
{
"kind": "membership",
"label": "EDUT Membership Activation",
"amount": "5.00",
"amount_atomic": "5000000",
"decimals": 6,
"currency": "USDC"
}
],
"policy_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"access_class": "connected",
"availability_state": "active",
"expires_at": "2026-02-17T07:44:30Z",
"tx": {
"to": "0x2222222222222222222222222222222222222222",
"data": "0xdeadbeef",
"value": "0x0"
}
}
```
### Notes
1. `amount`/`amount_atomic` represent the license component.
2. `total_amount`/`total_amount_atomic` represent the actual payable quote total.
3. First checkout can include membership activation as a separate line item.
Error (`403`):
```json
{
"error": "membership_required",
"message": "Active membership is required for checkout."
}
```
## `POST /marketplace/checkout/confirm`
Request:
```json
{
"quote_id": "cq_01HZZXFQ27ZP6MP0V2R9M6V3KX",
"wallet": "0x3ea6cbf98d23e2cf7b6f4f9bb1fb4f50b710f2d5",
"payer_wallet": "0x2299547f6fA9A8f9b6d9aEA9F9D8A4B53C8A0e11",
"offer_id": "edut.governance.core",
"org_root_id": "org.acme.root",
"principal_id": "human.joshua",
"principal_role": "org_root_owner",
"workspace_id": "workspace.work.acme.exec",
"tx_hash": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"chain_id": 8453
}
```
Success (`200`):
```json
{
"status": "entitlement_active",
"entitlement_id": "ent:8453:0x3ea6cbf98d23e2cf7b6f4f9bb1fb4f50b710f2d5:000001",
"offer_id": "edut.governance.core",
"org_root_id": "org.acme.root",
"principal_id": "human.joshua",
"principal_role": "org_root_owner",
"wallet": "0x3ea6cbf98d23e2cf7b6f4f9bb1fb4f50b710f2d5",
"tx_hash": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"policy_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"access_class": "connected",
"availability_state": "active",
"activated_at": "2026-02-17T07:46:02Z"
}
```
## `GET /marketplace/entitlements?wallet=...`
Success (`200`):
```json
{
"entitlements": [
{
"entitlement_id": "ent:8453:0x3ea6cbf98d23e2cf7b6f4f9bb1fb4f50b710f2d5:000001",
"offer_id": "edut.crm.pro.annual",
"wallet_address": "0x3ea6cbf98d23e2cf7b6f4f9bb1fb4f50b710f2d5",
"workspace_id": "workspace.work.acme",
"org_root_id": "org.acme.root",
"state": "active",
"access_class": "connected",
"availability_state": "grace",
"policy_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"issued_at": "2026-02-17T07:46:02Z"
}
]
}
```