{"openapi":"3.0.3","info":{"title":"Ledger","version":"2.1.0","summary":"Look up transactions, reverse them and read balances.","description":"Read-side companion to Collect and Payouts. Reconcile what happened, reverse a payment made in error and check your float."},"x-lango":{"slug":"ledger","auth":"oauth2_client_credentials","changelog":"Balance now returns the `reserved` amount separately from `available`."},"paths":{"/ledger/v2/transactions/{transactionId}":{"get":{"operationId":"getTransaction","summary":"Look up a transaction","parameters":[{"name":"transactionId","in":"path","required":true,"description":"The receipt number from a callback.","schema":{"type":"string"},"example":"RCT_5h1v9k2b"}],"responses":{"200":{"description":"The transaction.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transaction"}}}},"404":{"description":"No transaction with that receipt.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-sandbox-scenarios":[{"key":"found","title":"Found","default":true,"status":200,"delayMs":70,"response":{"transactionId":"{{path.transactionId}}","type":"COLLECTION","status":"COMPLETED","amount":1500,"currency":"KES","counterparty":"254712345678","reference":"INV-2041","completedAt":"{{now}}"}},{"key":"not_found","title":"Unknown receipt","match":{"field":"path.transactionId","equals":"RCT_missing"},"status":404,"delayMs":30,"response":{"error":"NOT_FOUND","message":"No transaction with that receipt number.","requestId":"{{id:req}}"}}]}},"/ledger/v2/transactions/{transactionId}/reversal":{"post":{"operationId":"reverseTransaction","summary":"Reverse a transaction","description":"Returns the money to the payer. Only completed collections can be reversed, once.","x-lango":{"destructive":true,"async":true},"parameters":[{"name":"transactionId","in":"path","required":true,"schema":{"type":"string"},"example":"RCT_5h1v9k2b"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReversalRequest"},"example":{"reason":"Customer paid twice","callbackUrl":"https://example.com/hooks/lango"}}}},"responses":{"202":{"description":"Reversal queued.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReversalAccepted"}}}}},"x-sandbox-scenarios":[{"key":"reversed","title":"Reversal succeeds","default":true,"status":202,"delayMs":140,"response":{"reversalId":"{{id:rev}}","status":"QUEUED"},"callback":{"delayMs":3000,"body":{"reversalId":"{{reversalId}}","transactionId":"{{path.transactionId}}","resultCode":0,"resultDescription":"Transaction reversed."}}}]}},"/ledger/v2/balance":{"get":{"operationId":"getBalance","summary":"Read your balances","parameters":[{"name":"shortCode","in":"query","required":true,"schema":{"type":"string"},"example":"600100"}],"responses":{"200":{"description":"Balances for the short code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Balance"}}}}},"x-sandbox-scenarios":[{"key":"ok","title":"Healthy float","default":true,"status":200,"delayMs":55,"response":{"shortCode":"{{query.shortCode}}","currency":"KES","available":1284500,"reserved":25000,"asOf":"{{now}}"}}]}}},"components":{"schemas":{"Transaction":{"type":"object","properties":{"transactionId":{"type":"string"},"type":{"type":"string","enum":["COLLECTION","PAYOUT","REVERSAL"]},"status":{"type":"string","enum":["COMPLETED","FAILED","REVERSED"]},"amount":{"type":"integer"},"currency":{"type":"string"},"counterparty":{"type":"string"},"reference":{"type":"string"},"completedAt":{"type":"string","format":"date-time"}}},"ReversalRequest":{"type":"object","required":["reason","callbackUrl"],"properties":{"reason":{"type":"string","maxLength":64},"callbackUrl":{"type":"string","format":"uri"}}},"ReversalAccepted":{"type":"object","properties":{"reversalId":{"type":"string"},"status":{"type":"string","enum":["QUEUED"]}}},"Balance":{"type":"object","properties":{"shortCode":{"type":"string"},"currency":{"type":"string"},"available":{"type":"integer"},"reserved":{"type":"integer"},"asOf":{"type":"string","format":"date-time"}}},"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"}}}}},"servers":[{"url":"https://devportal.softwaregroup.com/api/sandbox","description":"Sandbox"},{"url":"https://devportal.softwaregroup.com/api/live","description":"Production"}]}