> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/azfar-imtiaz/PayPulse-Cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete account

> Permanently delete the authenticated user's account and all associated data.

<Warning>
  This action is irreversible. All data associated with the account is permanently deleted and cannot be recovered.
</Warning>

## Authentication

All requests to this endpoint must include a valid JWT in the `Authorization` header.

```
Authorization: Bearer <token>
```

## What gets deleted

Deleting an account removes the following data for the authenticated user:

* All rental invoices from the `RentalInvoices` DynamoDB table.
* All retail invoices from the `RetailInvoices` DynamoDB table, including records in all category detail tables (`FoodDeliveryInvoices`, `ClothingInvoices`, `TechnologyInvoices`, `SubscriptionInvoices`, `GroceryInvoices`, `MiscUtilityInvoices`, `MiscInvoices`).
* Gmail OAuth credentials stored in Secrets Manager.
* The user's folder in S3 (including all uploaded invoice files).
* The user record itself from the `Users` DynamoDB table.

## Response

<ResponseField name="message" type="string">
  A human-readable confirmation message. Example: `"All data for user <user_id> deleted successfully!"`
</ResponseField>

<ResponseField name="code" type="number">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="data" type="null">
  Always `null` for this endpoint.
</ResponseField>

## Error responses

| Status | Error code              | Description                                                                                   |
| ------ | ----------------------- | --------------------------------------------------------------------------------------------- |
| `401`  | `INVALID_CREDENTIALS`   | The `Authorization` header is missing or the token is invalid.                                |
| `401`  | `TOKEN_EXPIRED`         | The JWT has expired.                                                                          |
| `502`  | `DEPENDENCY_FAILURE`    | A downstream dependency (DynamoDB, Secrets Manager, or S3) returned an error during deletion. |
| `500`  | `INTERNAL_SERVER_ERROR` | An unexpected server-side error occurred.                                                     |

Error responses follow this structure:

```json theme={null}
{
  "error": {
    "code": "DEPENDENCY_FAILURE",
    "message": "Database error during user deletion"
  }
}
```

<RequestExample>
  ```bash cURL theme={null}
  curl --request DELETE \
    --url https://api.paypulse.io/v1/user/me \
    --header 'Authorization: Bearer <token>'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "message": "All data for user user_abc123 deleted successfully!",
    "code": 200,
    "data": null
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": "TOKEN_EXPIRED",
      "message": "Expired token."
    }
  }
  ```

  ```json 502 theme={null}
  {
    "error": {
      "code": "DEPENDENCY_FAILURE",
      "message": "Error deleting S3 folder"
    }
  }
  ```
</ResponseExample>
