Skip to content

Close Account

Request URL

DELETE /accounts/:AFiAccountId

Description

This endpoint closes an account. The account is identified by the path parameter and must belong to the current user.

If the closed account was the main account, this will assign another account as the main. If the account has a balance, it will be transferred to the new main account. If the user has no other accounts, this API will mark the user as inactive and will fire an event with the message:

Account closed money needs to be returned.

Snippet Examples

javascript

const axios = require('axios');
const config = {
  method: 'DELETE',
  url: '${AMPLIFI_BASE_URL}/accounts/:AFiAccountId',
  headers: {
    'Content-Type': "application/json",
    'token': "A long random string token received from /token request"
  },
};

let result;
try {
  result = await axios.request(config);
  if (result.status === 200) {
    console.log(JSON.stringify(result.data));
  }
} catch (err) {
  console.log({
    errCode: err.code,
    responseStatus: err.response && err.response.status,
    data: err.response && JSON.stringify(err.response.data)
  });
}

cURL

curl --location "AMPLIFI_BASE_URL/accounts/:AFiAccountId"  --header "Content-Type: application/json" --header "token: A long random string token received from /token request"