---
title: Close Ledger Account
slug: api/close-ledger-account
docTags: 
createdAt: 2026-08-20T02:00:14.436Z
---

{
  "id": "yIGQFblRiWQMfzqdUXg57",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.mpay.com.au/ledger/v1/close",
    "servers": [
      {
        "url": "https://api.mpay.com.au/ledger/v1/close",
        "description": "Production URL"
      },
      {
        "url": "https://api.m-pay.com.au/ledger/v1/close",
        "description": "Sandbox URL"
      }
    ],
    "name": "Close Ledger Account",
    "description": "<p>Close a ledger when it's no longer required. For this endpoint to be used the ledger account balance must be $0, otherwise an error will be returned.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "ledgerCloseBody_V1",
          "schema": [
            {
              "name": "ledgerAccountNumber",
              "kind": "optional",
              "type": "string",
              "description": "The unique account number of the ledger to be closed.",
              "example": "200000001",
              "default": "200000001",
              "pattern": "^[0-9]{6,12}$"
            },
            {
              "name": "forcedClose",
              "kind": "optional",
              "type": "string",
              "description": "<p><strong>Optional</strong>. Setting this to true will close the attached automatcher and PayID. By default, this will be false.</p>",
              "example": "false",
              "default": "false",
              "pattern": "^(true|false)$"
            }
          ],
          "modelRef": "#/components/schemas/ledgerCloseBody_V1",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "basicAuth",
          "name": "basicAuth",
          "kind": "optional",
          "type": "http",
          "description": "<p>To authenticate using basic authentication, generate an API key and pass it as the username. No password is required.</p>",
          "scheme": "basic"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful response.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "ledgerCloseResponse_V1",
            "schema": [
              {
                "name": "durationMs",
                "kind": "optional",
                "type": "string",
                "description": "The total time in milliseconds that the Platform took to process the request.",
                "example": "42",
                "default": "42",
                "pattern": "^[0-9]+$"
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "string",
                "description": "This is the status of the request. A code of 'Ok' indicates no errors.",
                "example": "Ok",
                "default": "Ok",
                "pattern": "^.{1,50}$"
              },
              {
                "name": "statusDescription",
                "kind": "optional",
                "type": "string",
                "description": "<p>This is a description of the status. If an 'Ok' status is returned, then this will be 'Operation completed successfully'.</p>",
                "example": "Operation completed successfully",
                "default": "Operation completed successfully",
                "pattern": "^.{1,255}$"
              }
            ],
            "modelRef": "#/components/schemas/ledgerCloseResponse_V1",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "<p>Bad Request - the request was malformed or contained invalid parameters.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "errorResponse_V1",
            "schema": [
              {
                "name": "status",
                "kind": "optional",
                "type": "string",
                "description": "The status of the request. A value other than 'Ok' indicates that the request failed.",
                "example": "Error",
                "default": "Error",
                "pattern": "^.{1,50}$"
              },
              {
                "name": "statusDescription",
                "kind": "optional",
                "type": "string",
                "description": "<p>A human-readable description of the error that occurred.</p>",
                "example": "Invalid ledger account number.",
                "default": "Invalid ledger account number.",
                "pattern": "^.{1,255}$"
              },
              {
                "name": "errorCode",
                "kind": "optional",
                "type": "string",
                "description": "<p><strong>Conditional</strong>. The error code returned by the platform. Present only when the request fails.</p>",
                "example": "400",
                "default": "400",
                "pattern": "^[0-9]{3,5}$"
              },
              {
                "name": "errorMessage",
                "kind": "optional",
                "type": "string",
                "description": "<p><strong>Conditional</strong>. Detailed error message describing the cause of the failure. Present only when the request fails.</p>",
                "example": "The supplied ledger account number could not be found.",
                "default": "The supplied ledger account number could not be found.",
                "pattern": "^.{1,255}$"
              },
              {
                "name": "durationMs",
                "kind": "optional",
                "type": "string",
                "description": "The total time in milliseconds that the Platform took to process the request.",
                "example": "42",
                "default": "42",
                "pattern": "^[0-9]+$"
              }
            ],
            "modelRef": "#/components/schemas/errorResponse_V1",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "<p>Unauthorized - authentication failed, or the API key was missing or invalid.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "errorResponse_V1",
            "schema": [
              {
                "name": "status",
                "kind": "optional",
                "type": "string",
                "description": "The status of the request. A value other than 'Ok' indicates that the request failed.",
                "example": "Error",
                "default": "Error",
                "pattern": "^.{1,50}$"
              },
              {
                "name": "statusDescription",
                "kind": "optional",
                "type": "string",
                "description": "<p>A human-readable description of the error that occurred.</p>",
                "example": "Invalid ledger account number.",
                "default": "Invalid ledger account number.",
                "pattern": "^.{1,255}$"
              },
              {
                "name": "errorCode",
                "kind": "optional",
                "type": "string",
                "description": "<p><strong>Conditional</strong>. The error code returned by the platform. Present only when the request fails.</p>",
                "example": "400",
                "default": "400",
                "pattern": "^[0-9]{3,5}$"
              },
              {
                "name": "errorMessage",
                "kind": "optional",
                "type": "string",
                "description": "<p><strong>Conditional</strong>. Detailed error message describing the cause of the failure. Present only when the request fails.</p>",
                "example": "The supplied ledger account number could not be found.",
                "default": "The supplied ledger account number could not be found.",
                "pattern": "^.{1,255}$"
              },
              {
                "name": "durationMs",
                "kind": "optional",
                "type": "string",
                "description": "The total time in milliseconds that the Platform took to process the request.",
                "example": "42",
                "default": "42",
                "pattern": "^[0-9]+$"
              }
            ],
            "modelRef": "#/components/schemas/errorResponse_V1",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "500",
        "description": "<p>Internal Server Error - an unexpected error occurred while processing the request.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "errorResponse_V1",
            "schema": [
              {
                "name": "status",
                "kind": "optional",
                "type": "string",
                "description": "The status of the request. A value other than 'Ok' indicates that the request failed.",
                "example": "Error",
                "default": "Error",
                "pattern": "^.{1,50}$"
              },
              {
                "name": "statusDescription",
                "kind": "optional",
                "type": "string",
                "description": "<p>A human-readable description of the error that occurred.</p>",
                "example": "Invalid ledger account number.",
                "default": "Invalid ledger account number.",
                "pattern": "^.{1,255}$"
              },
              {
                "name": "errorCode",
                "kind": "optional",
                "type": "string",
                "description": "<p><strong>Conditional</strong>. The error code returned by the platform. Present only when the request fails.</p>",
                "example": "400",
                "default": "400",
                "pattern": "^[0-9]{3,5}$"
              },
              {
                "name": "errorMessage",
                "kind": "optional",
                "type": "string",
                "description": "<p><strong>Conditional</strong>. Detailed error message describing the cause of the failure. Present only when the request fails.</p>",
                "example": "The supplied ledger account number could not be found.",
                "default": "The supplied ledger account number could not be found.",
                "pattern": "^.{1,255}$"
              },
              {
                "name": "durationMs",
                "kind": "optional",
                "type": "string",
                "description": "The total time in milliseconds that the Platform took to process the request.",
                "example": "42",
                "default": "42",
                "pattern": "^[0-9]+$"
              }
            ],
            "modelRef": "#/components/schemas/errorResponse_V1",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "B3ijaWXRRuTfYGRDAuEcc",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.mpay.com.au/ledger/v1/close \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"ledgerAccountNumber\": \"200000001\",\n     \"forcedClose\": \"false\"\n     }'"
        },
        {
          "id": "S3AQI-gEChD4DjGkJzrlB",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"ledgerAccountNumber\": \"200000001\",\n   \"forcedClose\": \"false\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.mpay.com.au/ledger/v1/close\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "oB55KfAv3qJaPWtYjcbPf",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.mpay.com.au/ledger/v1/close\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"ledgerAccountNumber\": \"200000001\",\n   \"forcedClose\": \"false\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "VQHyi2RyEW4eJr85Dq-AG",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.mpay.com.au/ledger/v1/close\"\n\npayload = json.dumps({\n   \"ledgerAccountNumber\": \"200000001\",\n   \"forcedClose\": \"false\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "B3ijaWXRRuTfYGRDAuEcc"
    },
    "results": {
      "languages": [
        {
          "id": "ZjQhd5bJAOMBOup1u-YV0",
          "language": "200",
          "code": "// Successful response.\n{\n  \"durationMs\": \"42\",\n  \"status\": \"Ok\",\n  \"statusDescription\": \"Operation completed successfully\"\n}"
        },
        {
          "id": "fYyZDW-Le-TyDFkthIf-u",
          "language": "400",
          "code": "// Bad Request - the request was malformed or contained invalid parameters.\n{\n  \"status\": \"Error\",\n  \"statusDescription\": \"Invalid ledger account number.\",\n  \"errorCode\": \"400\",\n  \"errorMessage\": \"The supplied ledger account number could not be found.\",\n  \"durationMs\": \"42\"\n}"
        },
        {
          "id": "nyWRe4cge9Qe6WbiCPhWO",
          "language": "401",
          "code": "// Unauthorized - authentication failed, or the API key was missing or invalid.\n{\n  \"status\": \"Error\",\n  \"statusDescription\": \"Invalid ledger account number.\",\n  \"errorCode\": \"400\",\n  \"errorMessage\": \"The supplied ledger account number could not be found.\",\n  \"durationMs\": \"42\"\n}"
        },
        {
          "id": "_czVF-zefBC21h_4iFKZD",
          "language": "500",
          "code": "// Internal Server Error - an unexpected error occurred while processing the request.\n{\n  \"status\": \"Error\",\n  \"statusDescription\": \"Invalid ledger account number.\",\n  \"errorCode\": \"400\",\n  \"errorMessage\": \"The supplied ledger account number could not be found.\",\n  \"durationMs\": \"42\"\n}"
        }
      ],
      "selectedLanguageId": "ZjQhd5bJAOMBOup1u-YV0"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}