/compute/capital-gains-za
Base URL
https://api.babylon.app/v1
POST /compute/capital-gains-za
Compute capital gains for a SARS tax year. The calculation excludes RA, TFSA, TFIA and SIPP accounts.
JSON request body
segmentLedger(required) — segment-ledger identifier.taxYear(required) — tax year such as2024/25or2024/2025.valueDate(optional) — valuation date inYYYY-MM-DDformat; defaults to the current date.target(optional) —CapitalGains(default),ExplainGainsorExcelExplain.
Example request
POST /compute/capital-gains-za
Content-Type: application/json
{
"segmentLedger": "MySASegment",
"taxYear": "2024/25",
"valueDate": "2025-02-28"
}
Example response — 200
The default CapitalGains target returns a table.
{
"name": "CapitalGains",
"description": "Capital gains on ledger MySASegment under SARS for tax year 2024/25.",
"columns": ["accountAlias", "accountType", "bourseSymbol", "isin", "securityType", "description", "tradeDate", "settleDate", "costBasis", "netProceeds", "capitalGain", "currency", "capitalGainInBase", "baseCurrency", "taxYear", "taxAuthority"],
"columnTypes": {
"costBasis": "Decimal",
"netProceeds": "Decimal",
"capitalGain": "Decimal",
"capitalGainInBase": "Decimal"
},
"rows": [
{
"accountAlias": "Broker-ZAR",
"accountType": "GIA",
"bourseSymbol": "JSE:NPN",
"isin": "ZAE000015889",
"securityType": "SHRS",
"description": "Naspers Limited",
"tradeDate": "2024-09-02",
"settleDate": "2024-09-05",
"costBasis": "30000.00",
"netProceeds": "34000.00",
"capitalGain": "4000.00",
"currency": "ZAR",
"capitalGainInBase": "4000.00",
"baseCurrency": "ZAR",
"taxYear": "2024/25",
"taxAuthority": "SARS"
}
]
}
ExplainGains returns a JSON array of per-security calculation tables. ExcelExplain returns a drill-down report in JSON, or an XLSX workbook when requested with Accept: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.
The default table can be requested as CSV with Accept: text/csv.
GET /compute/capital-gains-za
GET supplies the same operation parameters in the query string.
GET /compute/capital-gains-za?segmentLedger=MySASegment&taxYear=2024%2F25&valueDate=2025-02-28
The response depends on target in the same way as the POST response.