> For the complete documentation index, see [llms.txt](https://docs.creditcoop.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.creditcoop.xyz/developer-api-docs/ledger.md).

# Ledger

Typed ledger endpoints: transfers, borrows, repays, cumulative cashflows

## List credit facility borrow events

> Get on-chain borrow events for an organization. Each row represents a single \`Borrow\` event emitted by a SecuredLine credit facility — the moment outstanding principal was drawn against the line.\
> \
> Results are sorted by \`occurredAt\` (descending — newest first). Ordering is not configurable from the query string.\
> \
> Supports three response formats via the \`format\` query parameter:\
> \- \*\*json\*\* (default) — paginated JSON (default limit 100, max 1000).\
> \- \*\*csv\*\* — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\
> \- \*\*event-stream\*\* — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named \`entry\` event with JSON data. A final \`done\` event carries \`{"total": N}\`. Connect with \`EventSource\` or \`fetch\`:\
> \
> \`\`\`js\
> const es = new EventSource('/v3/ledger/borrows?organizationId={id}\&format=event-stream', {\
> &#x20; headers: { 'x-api-key': 'cc\_...' },\
> });\
> es.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\
> es.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\
> \`\`\`\
> \
> Requires org membership or vault curator role (public orgs only).

````json
{"openapi":"3.0.3","info":{"title":"Credit Coop API","version":"3.0.0"},"tags":[{"name":"Ledger","description":"Typed ledger endpoints: transfers, borrows, repays, cumulative cashflows"}],"servers":[{"url":"https://api.creditcoop.xyz"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]},{"OAuth2":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key in the format: cc_xxx_yyy (for customer API routes)"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Clerk authentication token (session JWT or Clerk OAuth access token) used by Credit Coop"},"OAuth2":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://clerk.creditcoop.xyz/oauth/authorize","tokenUrl":"https://clerk.creditcoop.xyz/oauth/token","scopes":{"openid":"OpenID Connect","email":"User email","profile":"User profile"}}},"description":"Credit Coop OAuth"}},"schemas":{"Pagination":{"type":"object","required":["total","limit","offset"],"properties":{"total":{"type":"integer","description":"Total number of records matching the query"},"limit":{"type":"integer","description":"Maximum number of records returned per page"},"offset":{"type":"integer","description":"Number of records skipped from the start"}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"},"statusCode":{"type":"integer"}}}}},"paths":{"/v3/ledger/borrows":{"get":{"operationId":"listBorrows","summary":"List credit facility borrow events","tags":["Ledger"],"description":"Get on-chain borrow events for an organization. Each row represents a single `Borrow` event emitted by a SecuredLine credit facility — the moment outstanding principal was drawn against the line.\n\nResults are sorted by `occurredAt` (descending — newest first). Ordering is not configurable from the query string.\n\nSupports three response formats via the `format` query parameter:\n- **json** (default) — paginated JSON (default limit 100, max 1000).\n- **csv** — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\n- **event-stream** — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named `entry` event with JSON data. A final `done` event carries `{\"total\": N}`. Connect with `EventSource` or `fetch`:\n\n```js\nconst es = new EventSource('/v3/ledger/borrows?organizationId={id}&format=event-stream', {\n  headers: { 'x-api-key': 'cc_...' },\n});\nes.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\nes.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\n```\n\nRequires org membership or vault curator role (public orgs only).","parameters":[{"schema":{"type":"string","format":"uuid","maxLength":36},"in":"query","name":"organizationId","required":true,"description":"Organization ID (must be an org the caller is a member of, or a public org if caller is a vault curator)."},{"schema":{"type":"string","format":"date"},"in":"query","name":"startDate","required":false,"description":"Optional filter. Inclusive start date (YYYY-MM-DD); restricts results to `occurredAt >= startDate` (or `snapshotDate` for collateral-snapshots). Omit to leave the start unbounded."},{"schema":{"type":"string","format":"date"},"in":"query","name":"endDate","required":false,"description":"Optional filter. Inclusive end date (YYYY-MM-DD). Omit to leave the end unbounded."},{"schema":{"type":"integer","minimum":1},"in":"query","name":"limit","required":false,"description":"Maximum records returned. Format-dependent: `format=json` capped at 1000 (default 100); `format=csv|event-stream` capped at 1,000,000 (default 1,000,000). Values outside these caps are silently clamped server-side."},{"schema":{"type":"integer","minimum":0,"default":0},"in":"query","name":"offset","required":false,"description":"Number of records to skip from the start (JSON pagination only — ignored for csv/event-stream)."},{"schema":{"type":"string","enum":["json","csv","event-stream"],"default":"json"},"in":"query","name":"format","required":false,"description":"Response format. `json` returns paginated JSON. `csv` streams a CSV file download. `event-stream` returns Server-Sent Events: each row is a named `entry` event; a final `done` event carries `{\"total\": N}`."},{"schema":{"type":"string","maxLength":50},"in":"query","name":"networkId","required":false,"description":"Optional filter. CAIP-2 network identifier; restricts results to a single chain. Omit to return all networks."},{"schema":{"type":"string","maxLength":42,"pattern":"^0x[0-9a-fA-F]{40}$"},"in":"query","name":"facilityAddress","required":false,"description":"Optional filter. Credit facility (SecuredLine) contract address; restricts results to a single facility. Omit to return all facilities for the organization."}],"responses":{"200":{"description":"Credit facility borrow events.","content":{"application/json":{"schema":{"type":"object","required":["entries","pagination"],"properties":{"entries":{"type":"array","items":{"type":"object","required":["id","organizationId","evmLogId","facilityAddress","amount","currency","occurredAt","dataSource","networkId","transactionHash","logIndex","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"evmLogId":{"type":"string","format":"uuid"},"facilityAddress":{"type":"string","maxLength":42,"pattern":"^0x[0-9a-fA-F]{40}$","description":"Credit facility (SecuredLine) contract address."},"amount":{"type":"string","description":"Token amount with full decimal precision. Returned as a string to avoid floating-point precision loss."},"amountUsd":{"type":"string","nullable":true,"description":"USD value at time of entry. Returned as a string. May be `null` when no historical price is available for the currency."},"currency":{"type":"string","description":"Token symbol stored verbatim from source."},"occurredAt":{"type":"string","format":"date-time"},"dataSource":{"type":"string","description":"Origin of the data, e.g. `blockchain:ethereum`, `blockchain:base`."},"networkId":{"type":"string","description":"CAIP-2 network identifier."},"transactionHash":{"type":"string","description":"0x-prefixed transaction hash."},"logIndex":{"type":"integer","description":"Position of the log within the transaction."},"createdAt":{"type":"string","format":"date-time"},"organizationName":{"type":"string","nullable":true,"description":"Display name of the owning organization."},"organizationSlug":{"type":"string","nullable":true,"description":"URL-safe slug of the owning organization."}}}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}},"text/csv":{"schema":{"type":"string","description":"CSV file download. Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol."}},"text/event-stream":{"schema":{"type":"string","description":"SSE stream. Named `entry` events carry one row each; a final `done` event carries `{\"total\": N}`."}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
````

## List credit facility repayment events

> Get on-chain repayment events for an organization. Each row represents a \`RepayPrincipal\` or \`RepayInterest\` event emitted by a SecuredLine credit facility. Filter by \`repaymentType\` to restrict to one subtype.\
> \
> Results are sorted by \`occurredAt\` (descending — newest first). Ordering is not configurable from the query string.\
> \
> Supports three response formats via the \`format\` query parameter:\
> \- \*\*json\*\* (default) — paginated JSON (default limit 100, max 1000).\
> \- \*\*csv\*\* — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\
> \- \*\*event-stream\*\* — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named \`entry\` event with JSON data. A final \`done\` event carries \`{"total": N}\`. Connect with \`EventSource\` or \`fetch\`:\
> \
> \`\`\`js\
> const es = new EventSource('/v3/ledger/repays?organizationId={id}\&format=event-stream', {\
> &#x20; headers: { 'x-api-key': 'cc\_...' },\
> });\
> es.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\
> es.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\
> \`\`\`\
> \
> Requires org membership or vault curator role (public orgs only).

````json
{"openapi":"3.0.3","info":{"title":"Credit Coop API","version":"3.0.0"},"tags":[{"name":"Ledger","description":"Typed ledger endpoints: transfers, borrows, repays, cumulative cashflows"}],"servers":[{"url":"https://api.creditcoop.xyz"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]},{"OAuth2":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key in the format: cc_xxx_yyy (for customer API routes)"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Clerk authentication token (session JWT or Clerk OAuth access token) used by Credit Coop"},"OAuth2":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://clerk.creditcoop.xyz/oauth/authorize","tokenUrl":"https://clerk.creditcoop.xyz/oauth/token","scopes":{"openid":"OpenID Connect","email":"User email","profile":"User profile"}}},"description":"Credit Coop OAuth"}},"schemas":{"Pagination":{"type":"object","required":["total","limit","offset"],"properties":{"total":{"type":"integer","description":"Total number of records matching the query"},"limit":{"type":"integer","description":"Maximum number of records returned per page"},"offset":{"type":"integer","description":"Number of records skipped from the start"}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"},"statusCode":{"type":"integer"}}}}},"paths":{"/v3/ledger/repays":{"get":{"operationId":"listRepays","summary":"List credit facility repayment events","tags":["Ledger"],"description":"Get on-chain repayment events for an organization. Each row represents a `RepayPrincipal` or `RepayInterest` event emitted by a SecuredLine credit facility. Filter by `repaymentType` to restrict to one subtype.\n\nResults are sorted by `occurredAt` (descending — newest first). Ordering is not configurable from the query string.\n\nSupports three response formats via the `format` query parameter:\n- **json** (default) — paginated JSON (default limit 100, max 1000).\n- **csv** — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\n- **event-stream** — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named `entry` event with JSON data. A final `done` event carries `{\"total\": N}`. Connect with `EventSource` or `fetch`:\n\n```js\nconst es = new EventSource('/v3/ledger/repays?organizationId={id}&format=event-stream', {\n  headers: { 'x-api-key': 'cc_...' },\n});\nes.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\nes.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\n```\n\nRequires org membership or vault curator role (public orgs only).","parameters":[{"schema":{"type":"string","format":"uuid","maxLength":36},"in":"query","name":"organizationId","required":true,"description":"Organization ID (must be an org the caller is a member of, or a public org if caller is a vault curator)."},{"schema":{"type":"string","format":"date"},"in":"query","name":"startDate","required":false,"description":"Optional filter. Inclusive start date (YYYY-MM-DD); restricts results to `occurredAt >= startDate` (or `snapshotDate` for collateral-snapshots). Omit to leave the start unbounded."},{"schema":{"type":"string","format":"date"},"in":"query","name":"endDate","required":false,"description":"Optional filter. Inclusive end date (YYYY-MM-DD). Omit to leave the end unbounded."},{"schema":{"type":"integer","minimum":1},"in":"query","name":"limit","required":false,"description":"Maximum records returned. Format-dependent: `format=json` capped at 1000 (default 100); `format=csv|event-stream` capped at 1,000,000 (default 1,000,000). Values outside these caps are silently clamped server-side."},{"schema":{"type":"integer","minimum":0,"default":0},"in":"query","name":"offset","required":false,"description":"Number of records to skip from the start (JSON pagination only — ignored for csv/event-stream)."},{"schema":{"type":"string","enum":["json","csv","event-stream"],"default":"json"},"in":"query","name":"format","required":false,"description":"Response format. `json` returns paginated JSON. `csv` streams a CSV file download. `event-stream` returns Server-Sent Events: each row is a named `entry` event; a final `done` event carries `{\"total\": N}`."},{"schema":{"type":"string","enum":["principal","interest"]},"in":"query","name":"repaymentType","required":false,"description":"Optional filter. Restricts results to a single repayment subtype: `principal` (reduces outstanding principal) or `interest` (paid to depositors). Omit to return both."},{"schema":{"type":"string","maxLength":50},"in":"query","name":"networkId","required":false,"description":"Optional filter. CAIP-2 network identifier; restricts results to a single chain. Omit to return all networks."},{"schema":{"type":"string","maxLength":42,"pattern":"^0x[0-9a-fA-F]{40}$"},"in":"query","name":"facilityAddress","required":false,"description":"Optional filter. Credit facility (SecuredLine) contract address; restricts results to a single facility. Omit to return all facilities for the organization."}],"responses":{"200":{"description":"Credit facility repayment events.","content":{"application/json":{"schema":{"type":"object","required":["entries","pagination"],"properties":{"entries":{"type":"array","items":{"type":"object","required":["id","organizationId","evmLogId","repaymentType","facilityAddress","amount","currency","occurredAt","dataSource","networkId","transactionHash","logIndex","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"evmLogId":{"type":"string","format":"uuid"},"repaymentType":{"type":"string","enum":["principal","interest"],"description":"Repayment subtype: `principal` reduces outstanding principal; `interest` is paid to depositors."},"facilityAddress":{"type":"string","maxLength":42,"pattern":"^0x[0-9a-fA-F]{40}$","description":"Credit facility (SecuredLine) contract address."},"amount":{"type":"string","description":"Token amount with full decimal precision. Returned as a string to avoid floating-point precision loss."},"amountUsd":{"type":"string","nullable":true,"description":"USD value at time of entry. Returned as a string. May be `null` when no historical price is available for the currency."},"currency":{"type":"string"},"occurredAt":{"type":"string","format":"date-time"},"dataSource":{"type":"string"},"networkId":{"type":"string"},"transactionHash":{"type":"string"},"logIndex":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"organizationName":{"type":"string","nullable":true,"description":"Display name of the owning organization."},"organizationSlug":{"type":"string","nullable":true,"description":"URL-safe slug of the owning organization."}}}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}},"text/csv":{"schema":{"type":"string","description":"CSV file download. Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol."}},"text/event-stream":{"schema":{"type":"string","description":"SSE stream. Named `entry` events carry one row each; a final `done` event carries `{\"total\": N}`."}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
````

## List individual cashflow transfer events

> Get individual cashflow transfer events for an organization. Each row is a single movement of value (on-chain \`Transfer\`, off-chain wire/ACH, swap leg, etc.) classified by stage (\`external\` → \`in\_transit\` → \`secured\` → \`settled\`) and direction (inflow / outflow). Set \`excludeLinkedTransfers=true\` to drop transfers whose tx hash matches a known borrow/repay and avoid double-counting against \`/v3/ledger/borrows\` and \`/v3/ledger/repays\`.\
> \
> Results are sorted by \`occurredAt\` (descending — newest first). Ordering is not configurable from the query string.\
> \
> Supports three response formats via the \`format\` query parameter:\
> \- \*\*json\*\* (default) — paginated JSON (default limit 100, max 1000).\
> \- \*\*csv\*\* — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\
> \- \*\*event-stream\*\* — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named \`entry\` event with JSON data. A final \`done\` event carries \`{"total": N}\`. Connect with \`EventSource\` or \`fetch\`:\
> \
> \`\`\`js\
> const es = new EventSource('/v3/ledger/transfers?organizationId={id}\&format=event-stream', {\
> &#x20; headers: { 'x-api-key': 'cc\_...' },\
> });\
> es.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\
> es.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\
> \`\`\`\
> \
> Requires org membership or vault curator role (public orgs only).

````json
{"openapi":"3.0.3","info":{"title":"Credit Coop API","version":"3.0.0"},"tags":[{"name":"Ledger","description":"Typed ledger endpoints: transfers, borrows, repays, cumulative cashflows"}],"servers":[{"url":"https://api.creditcoop.xyz"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]},{"OAuth2":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key in the format: cc_xxx_yyy (for customer API routes)"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Clerk authentication token (session JWT or Clerk OAuth access token) used by Credit Coop"},"OAuth2":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://clerk.creditcoop.xyz/oauth/authorize","tokenUrl":"https://clerk.creditcoop.xyz/oauth/token","scopes":{"openid":"OpenID Connect","email":"User email","profile":"User profile"}}},"description":"Credit Coop OAuth"}},"schemas":{"Pagination":{"type":"object","required":["total","limit","offset"],"properties":{"total":{"type":"integer","description":"Total number of records matching the query"},"limit":{"type":"integer","description":"Maximum number of records returned per page"},"offset":{"type":"integer","description":"Number of records skipped from the start"}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"},"statusCode":{"type":"integer"}}}}},"paths":{"/v3/ledger/transfers":{"get":{"operationId":"listCashflowTransfers","summary":"List individual cashflow transfer events","tags":["Ledger"],"description":"Get individual cashflow transfer events for an organization. Each row is a single movement of value (on-chain `Transfer`, off-chain wire/ACH, swap leg, etc.) classified by stage (`external` → `in_transit` → `secured` → `settled`) and direction (inflow / outflow). Set `excludeLinkedTransfers=true` to drop transfers whose tx hash matches a known borrow/repay and avoid double-counting against `/v3/ledger/borrows` and `/v3/ledger/repays`.\n\nResults are sorted by `occurredAt` (descending — newest first). Ordering is not configurable from the query string.\n\nSupports three response formats via the `format` query parameter:\n- **json** (default) — paginated JSON (default limit 100, max 1000).\n- **csv** — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\n- **event-stream** — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named `entry` event with JSON data. A final `done` event carries `{\"total\": N}`. Connect with `EventSource` or `fetch`:\n\n```js\nconst es = new EventSource('/v3/ledger/transfers?organizationId={id}&format=event-stream', {\n  headers: { 'x-api-key': 'cc_...' },\n});\nes.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\nes.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\n```\n\nRequires org membership or vault curator role (public orgs only).","parameters":[{"schema":{"type":"string","format":"uuid","maxLength":36},"in":"query","name":"organizationId","required":true,"description":"Organization ID (must be an org the caller is a member of, or a public org if caller is a vault curator)."},{"schema":{"type":"string","format":"date"},"in":"query","name":"startDate","required":false,"description":"Optional filter. Inclusive start date (YYYY-MM-DD); restricts results to `occurredAt >= startDate` (or `snapshotDate` for collateral-snapshots). Omit to leave the start unbounded."},{"schema":{"type":"string","format":"date"},"in":"query","name":"endDate","required":false,"description":"Optional filter. Inclusive end date (YYYY-MM-DD). Omit to leave the end unbounded."},{"schema":{"type":"integer","minimum":1},"in":"query","name":"limit","required":false,"description":"Maximum records returned. Format-dependent: `format=json` capped at 1000 (default 100); `format=csv|event-stream` capped at 1,000,000 (default 1,000,000). Values outside these caps are silently clamped server-side."},{"schema":{"type":"integer","minimum":0,"default":0},"in":"query","name":"offset","required":false,"description":"Number of records to skip from the start (JSON pagination only — ignored for csv/event-stream)."},{"schema":{"type":"string","enum":["json","csv","event-stream"],"default":"json"},"in":"query","name":"format","required":false,"description":"Response format. `json` returns paginated JSON. `csv` streams a CSV file download. `event-stream` returns Server-Sent Events: each row is a named `entry` event; a final `done` event carries `{\"total\": N}`."},{"schema":{"type":"string","maxLength":50},"in":"query","name":"networkId","required":false,"description":"Optional filter. CAIP-2 network identifier; restricts results to a single chain. Omit to return all networks."},{"schema":{"type":"string","maxLength":255},"in":"query","name":"accountId","required":false,"description":"Optional filter. Wallet address (on-chain) or bank account identifier (off-chain); restricts results to a single account. Omit to return all accounts."},{"schema":{"type":"string","enum":["external","in_transit","secured","settled"]},"in":"query","name":"stage","required":false,"description":"Optional filter. Cash-flow stage (`external` → `in_transit` → `secured` → `settled`); restricts results to a single stage. Omit to return all stages."},{"schema":{"type":"string","maxLength":20},"in":"query","name":"type","required":false,"description":"Optional filter. Transfer mechanism; restricts results to a single mechanism (common values: `swap`, `bridge`, `onramp`, `wire`, `ach`, `direct`). Omit to return all mechanisms."},{"schema":{"type":"boolean"},"in":"query","name":"inflow","required":false,"description":"Optional filter. `true` = arriving only, `false` = leaving only. Omit to return both directions."},{"schema":{"type":"boolean","default":false},"in":"query","name":"excludeLinkedTransfers","required":false,"description":"Optional. When `true`, excludes transfers whose tx hash matches a known borrow/repay event, to avoid double-counting with /v3/ledger/borrows and /v3/ledger/repays. Defaults to `false`."}],"responses":{"200":{"description":"Individual cashflow transfer events.","content":{"application/json":{"schema":{"type":"object","required":["entries","pagination"],"properties":{"entries":{"type":"array","items":{"type":"object","required":["id","organizationId","inflow","stage","accountId","amount","currency","occurredAt","dataSource","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"webCaptureId":{"type":"string","format":"uuid","nullable":true},"evmLogId":{"type":"string","format":"uuid","nullable":true},"inflow":{"type":"boolean","description":"true = arriving, false = leaving."},"stage":{"type":"string","enum":["external","in_transit","secured","settled"],"description":"Cash-flow stage at time of capture (`external` → `in_transit` → `secured` → `settled`)."},"type":{"type":"string","nullable":true,"description":"Transfer mechanism (common values: `swap`, `bridge`, `onramp`, `wire`, `ach`, `direct`)."},"accountId":{"type":"string","description":"Wallet address (on-chain) or bank account identifier (off-chain)."},"institutionId":{"type":"string","nullable":true,"description":"Source institution that reported this transfer (e.g. `self_report`, `visa`)."},"externalTransactionId":{"type":"string","nullable":true,"description":"Source-system identifier for the transaction."},"amount":{"type":"string","description":"Token amount with full decimal precision. Returned as a string to avoid floating-point precision loss."},"amountUsd":{"type":"string","nullable":true,"description":"USD value at time of entry. Returned as a string. May be `null` when no historical price is available for the currency."},"currency":{"type":"string"},"occurredAt":{"type":"string","format":"date-time"},"dataSource":{"type":"string"},"networkId":{"type":"string","nullable":true},"transactionHash":{"type":"string","nullable":true},"logIndex":{"type":"integer","nullable":true},"createdAt":{"type":"string","format":"date-time"},"organizationName":{"type":"string","nullable":true,"description":"Display name of the owning organization."},"organizationSlug":{"type":"string","nullable":true,"description":"URL-safe slug of the owning organization."}}}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}},"text/csv":{"schema":{"type":"string","description":"CSV file download. Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol."}},"text/event-stream":{"schema":{"type":"string","description":"SSE stream. Named `entry` events carry one row each; a final `done` event carries `{\"total\": N}`."}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
````

## List aggregate daily cashflow snapshots

> Get daily aggregate cashflow snapshots reported by an institution (e.g. \`self\_report\`, \`visa\`) on behalf of an organization. Unlike \`/v3/ledger/transfers\`, each row is a \*period summary\* — typically one row per (institution, day, direction) — not an individual transaction. Use this endpoint when you want pre-aggregated totals; use \`/v3/ledger/transfers\` for line-item activity.\
> \
> Results are sorted by \`occurredAt\` (descending — newest first). Ordering is not configurable from the query string.\
> \
> Supports three response formats via the \`format\` query parameter:\
> \- \*\*json\*\* (default) — paginated JSON (default limit 100, max 1000).\
> \- \*\*csv\*\* — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\
> \- \*\*event-stream\*\* — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named \`entry\` event with JSON data. A final \`done\` event carries \`{"total": N}\`. Connect with \`EventSource\` or \`fetch\`:\
> \
> \`\`\`js\
> const es = new EventSource('/v3/ledger/cumulative-cashflows?organizationId={id}\&format=event-stream', {\
> &#x20; headers: { 'x-api-key': 'cc\_...' },\
> });\
> es.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\
> es.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\
> \`\`\`\
> \
> Requires org membership or vault curator role (public orgs only).

````json
{"openapi":"3.0.3","info":{"title":"Credit Coop API","version":"3.0.0"},"tags":[{"name":"Ledger","description":"Typed ledger endpoints: transfers, borrows, repays, cumulative cashflows"}],"servers":[{"url":"https://api.creditcoop.xyz"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]},{"OAuth2":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key in the format: cc_xxx_yyy (for customer API routes)"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Clerk authentication token (session JWT or Clerk OAuth access token) used by Credit Coop"},"OAuth2":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://clerk.creditcoop.xyz/oauth/authorize","tokenUrl":"https://clerk.creditcoop.xyz/oauth/token","scopes":{"openid":"OpenID Connect","email":"User email","profile":"User profile"}}},"description":"Credit Coop OAuth"}},"schemas":{"Pagination":{"type":"object","required":["total","limit","offset"],"properties":{"total":{"type":"integer","description":"Total number of records matching the query"},"limit":{"type":"integer","description":"Maximum number of records returned per page"},"offset":{"type":"integer","description":"Number of records skipped from the start"}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"},"statusCode":{"type":"integer"}}}}},"paths":{"/v3/ledger/cumulative-cashflows":{"get":{"operationId":"listCumulativeCashflows","summary":"List aggregate daily cashflow snapshots","tags":["Ledger"],"description":"Get daily aggregate cashflow snapshots reported by an institution (e.g. `self_report`, `visa`) on behalf of an organization. Unlike `/v3/ledger/transfers`, each row is a *period summary* — typically one row per (institution, day, direction) — not an individual transaction. Use this endpoint when you want pre-aggregated totals; use `/v3/ledger/transfers` for line-item activity.\n\nResults are sorted by `occurredAt` (descending — newest first). Ordering is not configurable from the query string.\n\nSupports three response formats via the `format` query parameter:\n- **json** (default) — paginated JSON (default limit 100, max 1000).\n- **csv** — streamed CSV file download (up to 1,000,000 rows). Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol.\n- **event-stream** — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named `entry` event with JSON data. A final `done` event carries `{\"total\": N}`. Connect with `EventSource` or `fetch`:\n\n```js\nconst es = new EventSource('/v3/ledger/cumulative-cashflows?organizationId={id}&format=event-stream', {\n  headers: { 'x-api-key': 'cc_...' },\n});\nes.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\nes.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\n```\n\nRequires org membership or vault curator role (public orgs only).","parameters":[{"schema":{"type":"string","format":"uuid","maxLength":36},"in":"query","name":"organizationId","required":true,"description":"Organization ID (must be an org the caller is a member of, or a public org if caller is a vault curator)."},{"schema":{"type":"string","format":"date"},"in":"query","name":"startDate","required":false,"description":"Optional filter. Inclusive start date (YYYY-MM-DD); restricts results to `occurredAt >= startDate` (or `snapshotDate` for collateral-snapshots). Omit to leave the start unbounded."},{"schema":{"type":"string","format":"date"},"in":"query","name":"endDate","required":false,"description":"Optional filter. Inclusive end date (YYYY-MM-DD). Omit to leave the end unbounded."},{"schema":{"type":"integer","minimum":1},"in":"query","name":"limit","required":false,"description":"Maximum records returned. Format-dependent: `format=json` capped at 1000 (default 100); `format=csv|event-stream` capped at 1,000,000 (default 1,000,000). Values outside these caps are silently clamped server-side."},{"schema":{"type":"integer","minimum":0,"default":0},"in":"query","name":"offset","required":false,"description":"Number of records to skip from the start (JSON pagination only — ignored for csv/event-stream)."},{"schema":{"type":"string","enum":["json","csv","event-stream"],"default":"json"},"in":"query","name":"format","required":false,"description":"Response format. `json` returns paginated JSON. `csv` streams a CSV file download. `event-stream` returns Server-Sent Events: each row is a named `entry` event; a final `done` event carries `{\"total\": N}`."},{"schema":{"type":"string","maxLength":100},"in":"query","name":"institutionId","required":false,"description":"Optional filter. Source institution that reported the aggregate (e.g. `self_report`, `visa`); restricts results to a single institution. Omit to return all institutions."},{"schema":{"type":"string","enum":["external","in_transit","secured","settled"]},"in":"query","name":"stage","required":false,"description":"Optional filter. Cash-flow stage (`external` → `in_transit` → `secured` → `settled`); restricts results to a single stage. Omit to return all stages."},{"schema":{"type":"boolean"},"in":"query","name":"inflow","required":false,"description":"Optional filter. `true` = arriving only, `false` = leaving only. Omit to return both directions."}],"responses":{"200":{"description":"Aggregate daily cashflow snapshots.","content":{"application/json":{"schema":{"type":"object","required":["entries","pagination"],"properties":{"entries":{"type":"array","items":{"type":"object","required":["id","organizationId","webCaptureId","inflow","stage","institutionId","externalTransactionId","amount","currency","occurredAt","dataSource","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"webCaptureId":{"type":"string","format":"uuid"},"inflow":{"type":"boolean"},"stage":{"type":"string","enum":["external","in_transit","secured","settled"],"description":"Cash-flow stage at time of capture (`external` → `in_transit` → `secured` → `settled`)."},"accountId":{"type":"string","nullable":true},"institutionId":{"type":"string","description":"Source institution that reported this aggregate (e.g. `self_report`, `visa`)."},"externalTransactionId":{"type":"string","description":"Source-system identifier for the aggregate."},"amount":{"type":"string","description":"Token amount with full decimal precision. Returned as a string to avoid floating-point precision loss."},"amountUsd":{"type":"string","nullable":true,"description":"USD value at time of entry. Returned as a string. May be `null` when no historical price is available for the currency."},"currency":{"type":"string"},"occurredAt":{"type":"string","format":"date-time"},"dataSource":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"organizationName":{"type":"string","nullable":true,"description":"Display name of the owning organization."},"organizationSlug":{"type":"string","nullable":true,"description":"URL-safe slug of the owning organization."}}}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}},"text/csv":{"schema":{"type":"string","description":"CSV file download. Columns: inflow, transaction, type, timestamp, amount, usdValue, tokenAddress, tokenIcon, tokenSymbol."}},"text/event-stream":{"schema":{"type":"string","description":"SSE stream. Named `entry` events carry one row each; a final `done` event carries `{\"total\": N}`."}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
````

## List point-in-time collateral USD snapshots

> Get daily collateral USD snapshots for an organization. Each row is the total USD value of collateral held on a given calendar day — one row per organization per day. Use this for time-series collateral charts and coverage ratios; combine with \`/v3/ledger/borrows\` + \`/v3/ledger/repays\` to compute net leverage over time.\
> \
> Results are sorted by \`snapshotDate\` (descending — newest first). Ordering is not configurable from the query string.\
> \
> Supports three response formats via the \`format\` query parameter:\
> \- \*\*json\*\* (default) — paginated JSON (default limit 100, max 1000).\
> \- \*\*csv\*\* — streamed CSV file download (up to 1,000,000 rows). Columns: snapshotDate, amountUsd, organizationId, organizationName, createdAt.\
> \- \*\*event-stream\*\* — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named \`entry\` event with JSON data. A final \`done\` event carries \`{"total": N}\`. Connect with \`EventSource\` or \`fetch\`:\
> \
> \`\`\`js\
> const es = new EventSource('/v3/ledger/cumulative-collateral?organizationId={id}\&format=event-stream', {\
> &#x20; headers: { 'x-api-key': 'cc\_...' },\
> });\
> es.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\
> es.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\
> \`\`\`\
> \
> Requires org membership or vault curator role (public orgs only).

````json
{"openapi":"3.0.3","info":{"title":"Credit Coop API","version":"3.0.0"},"tags":[{"name":"Ledger","description":"Typed ledger endpoints: transfers, borrows, repays, cumulative cashflows"}],"servers":[{"url":"https://api.creditcoop.xyz"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]},{"OAuth2":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key in the format: cc_xxx_yyy (for customer API routes)"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Clerk authentication token (session JWT or Clerk OAuth access token) used by Credit Coop"},"OAuth2":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://clerk.creditcoop.xyz/oauth/authorize","tokenUrl":"https://clerk.creditcoop.xyz/oauth/token","scopes":{"openid":"OpenID Connect","email":"User email","profile":"User profile"}}},"description":"Credit Coop OAuth"}},"schemas":{"Pagination":{"type":"object","required":["total","limit","offset"],"properties":{"total":{"type":"integer","description":"Total number of records matching the query"},"limit":{"type":"integer","description":"Maximum number of records returned per page"},"offset":{"type":"integer","description":"Number of records skipped from the start"}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"},"statusCode":{"type":"integer"}}}}},"paths":{"/v3/ledger/cumulative-collateral":{"get":{"operationId":"listCumulativeCollateral","summary":"List point-in-time collateral USD snapshots","tags":["Ledger"],"description":"Get daily collateral USD snapshots for an organization. Each row is the total USD value of collateral held on a given calendar day — one row per organization per day. Use this for time-series collateral charts and coverage ratios; combine with `/v3/ledger/borrows` + `/v3/ledger/repays` to compute net leverage over time.\n\nResults are sorted by `snapshotDate` (descending — newest first). Ordering is not configurable from the query string.\n\nSupports three response formats via the `format` query parameter:\n- **json** (default) — paginated JSON (default limit 100, max 1000).\n- **csv** — streamed CSV file download (up to 1,000,000 rows). Columns: snapshotDate, amountUsd, organizationId, organizationName, createdAt.\n- **event-stream** — Server-Sent Events stream (up to 1,000,000 rows). Each entry is emitted as a named `entry` event with JSON data. A final `done` event carries `{\"total\": N}`. Connect with `EventSource` or `fetch`:\n\n```js\nconst es = new EventSource('/v3/ledger/cumulative-collateral?organizationId={id}&format=event-stream', {\n  headers: { 'x-api-key': 'cc_...' },\n});\nes.addEventListener('entry', (e) => console.log(JSON.parse(e.data)));\nes.addEventListener('done', (e) => { console.log('total:', JSON.parse(e.data).total); es.close(); });\n```\n\nRequires org membership or vault curator role (public orgs only).","parameters":[{"schema":{"type":"string","format":"uuid","maxLength":36},"in":"query","name":"organizationId","required":true,"description":"Organization ID (must be an org the caller is a member of, or a public org if caller is a vault curator)."},{"schema":{"type":"string","format":"date"},"in":"query","name":"startDate","required":false,"description":"Optional filter. Inclusive start date (YYYY-MM-DD); restricts results to `occurredAt >= startDate` (or `snapshotDate` for collateral-snapshots). Omit to leave the start unbounded."},{"schema":{"type":"string","format":"date"},"in":"query","name":"endDate","required":false,"description":"Optional filter. Inclusive end date (YYYY-MM-DD). Omit to leave the end unbounded."},{"schema":{"type":"integer","minimum":1},"in":"query","name":"limit","required":false,"description":"Maximum records returned. Format-dependent: `format=json` capped at 1000 (default 100); `format=csv|event-stream` capped at 1,000,000 (default 1,000,000). Values outside these caps are silently clamped server-side."},{"schema":{"type":"integer","minimum":0,"default":0},"in":"query","name":"offset","required":false,"description":"Number of records to skip from the start (JSON pagination only — ignored for csv/event-stream)."},{"schema":{"type":"string","enum":["json","csv","event-stream"],"default":"json"},"in":"query","name":"format","required":false,"description":"Response format. `json` returns paginated JSON. `csv` streams a CSV file download. `event-stream` returns Server-Sent Events: each row is a named `entry` event; a final `done` event carries `{\"total\": N}`."}],"responses":{"200":{"description":"Point-in-time collateral USD snapshots (one row per org per day).","content":{"application/json":{"schema":{"type":"object","required":["entries","pagination"],"properties":{"entries":{"type":"array","items":{"type":"object","required":["id","organizationId","webCaptureId","amountUsd","snapshotDate","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"organizationName":{"type":"string","nullable":true},"webCaptureId":{"type":"string","format":"uuid"},"amountUsd":{"type":"string","description":"USD value (6 fractional digits). Returned as a string to avoid floating-point precision loss."},"snapshotDate":{"type":"string","format":"date"},"createdAt":{"type":"string","format":"date-time"}}}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}},"text/csv":{"schema":{"type":"string","description":"CSV file download. Columns: snapshotDate, amountUsd, organizationId, organizationName, createdAt."}},"text/event-stream":{"schema":{"type":"string","description":"SSE stream. Named `entry` events carry one row each; a final `done` event carries `{\"total\": N}`."}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Default Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.creditcoop.xyz/developer-api-docs/ledger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
