Skip to main content

Use the API to close an account

If the account's legal representative requests account closure, start the process with the API.

Suspended accounts

Only Swan can act on Suspended accounts. If the status is Suspended, you can't use the API to close the account.

Guide​

  1. Call the closeAccount mutation with the legal representative's user access token.
  2. The API returns a consentUrl.
  3. Send the consentUrl to the account's legal representative so they can complete Strong Customer Authentication.
  4. As soon as the legal representative consents, the account status changes to Closing.
Account statuses

Refer to the account statuses section for an overview of what happens while an account is Closing.

Mutation​

🔎 Open the mutation in API Explorer

Mutation
mutation closeAccount {
closeAccount(
input: {
accountId: "$YOUR_ACCOUNT_ID"
reason: { type: ClosingRequested }
consentRedirectUrl: "$YOUR_REDIRECT_URL"
}
) {
... on CloseAccountSuccessPayload {
__typename
consent {
consentUrl
}
}
}
}

Payload​

Payload
{
"data": {
"closeAccount": {
"__typename": "CloseAccountSuccessPayload",
"consent": {
"consentUrl": "https://identity.swan.io/consent?consentId=$YOUR_CONSENT_ID&env=Sandbox"
}
}
}
}