## POST /api/v2/me/actions/close-account

**Close the account**

Close your account for good. This cannot be undone. Only an account that holds nothing can be closed. Check `GET /api/v2/me/actions/close-account` first.

This call only works from a signed-in client-area session. An API key gets `403`. Contacts and delegated-access logins cannot use it either. Confirm with `currentPassword`. An account owner who signs in with BankID can confirm with BankID in the client area instead.

Closing stops all sign-in. Every session, API key and linked sign-in method is revoked, the caller's session included. The contacts and the personal details on the account are removed. Open support tickets are closed, except abuse cases. Issued invoices are kept. A confirmation goes to the e-mail address the account had.

### Related Endpoints

- `GET /api/v2/me/actions/close-account`: Check whether the account can be closed
- `GET /api/v2/me`: Get your account
- `PATCH /api/v2/me`: Update your account profile

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scope: `write:account`
- `Content-Type`: application/json

### Request Body

- `currentPassword` (string, optional): The current password. Needed unless the session has a fresh BankID confirmation.

### Request Examples

#### Close with the current password

```bash
curl -X POST "https://cloud.hostup.se/api/v2/me/actions/close-account" \
  -H "Authorization: Bearer $HOSTUP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "currentPassword": "current-account-password"
  }'
```

```json
{
  "currentPassword": "current-account-password"
}
```

### Response Schema

- `closedAt` (string, required): When the account was closed.

### Responses

#### 200 - The account is closed. Every session on it is signed out, the caller's included.
```json
{
  "closedAt": "2026-10-06T12:00:00.000Z"
}
```

#### 400 - The body is not a JSON object. `currentPassword` is also required unless the session has a BankID confirmation (`invalid_request`).

#### 401 - `unauthorized`: not signed in. `invalid_credentials`: the current password is wrong. `bankid_verification_required`: the BankID confirmation has expired or was already used.

#### 403 - API keys, contacts and delegated-access logins cannot close the account.

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 409 - Nothing was changed. `account_closure_blocked`: something is still on the account. The response carries the same fields as `GET /api/v2/me/actions/close-account`. `blockers` says what to resolve. `account_inactive`: the account is not active.

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Rate limit exceeded. Please try again later.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 502 - The account could not be checked or closed right now (`upstream_failed`). Nothing was changed. Try again later.

#### 503 - Another change to the account's sign-in details is in progress (`service_unavailable`). Try again shortly.
