> ## Documentation Index
> Fetch the complete documentation index at: https://docs.juicyway.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Customer

> Permanently remove a customer record from your integration

<Warning>
  Customer deletion is a permanent, irreversible action. Make sure to confirm the deletion intent and understand the implications before proceeding.
</Warning>

## Delete a Customer

```http theme={null}
DELETE /customers/{customer_id}
```

Delete a customer and all associated data. This action cannot be undone.

### Parameters

<ParamField path="customer_id" type="string" required>
  The unique identifier of the customer to delete
</ParamField>

### Cascade Deletion Behavior

When you delete a customer, the following associated data will also be permanently removed:

* Customer profile information
* Saved payment methods
* Billing addresses
* Transaction history references
* Subscription associations

<Note>
  Transaction records themselves are preserved for compliance and audit purposes, even after customer deletion.
</Note>

### Data Retention Policy

After deletion:

* Customer data is immediately removed from active systems
* Backups are retained for 30 days as per our data retention policy
* Transaction records are maintained in compliance with financial regulations
* Anonymized analytics data may be retained

## Request Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.spendjuice.com/v1/customers/cus_12345" \
    -H "Authorization:  YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const response = await juice.customers.delete('cus_12345');
  ```

  ```python Python theme={null}
  response = juice.Customer.delete('cus_12345')
  ```

  ```php PHP theme={null}
  $response = $juice->customers->delete('cus_12345');
  ```
</CodeGroup>

## Response

A successful deletion returns an HTTP `204 No Content` response with no response body.

## Error Scenarios

<AccordionGroup>
  <Accordion title="404 - Customer Not Found">
    ```json theme={null}
    {
      "error": {
        "code": "customer_not_found",
        "message": "No customer found with ID: cus_12345",
        "type": "not_found_error"
      }
    }
    ```
  </Accordion>

  <Accordion title="403 - Deletion Restricted">
    ```json theme={null}
    {
      "error": {
        "code": "deletion_restricted",
        "message": "Cannot delete customer with active subscriptions",
        "type": "authorization_error"
      }
    }
    ```
  </Accordion>

  <Accordion title="409 - Deletion Conflict">
    ```json theme={null}
    {
      "error": {
        "code": "deletion_conflict",
        "message": "Customer has pending transactions",
        "type": "conflict_error"
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Recommended Deletion Workflow

<Steps>
  <Step title="Verify Customer Status">
    Check for any active subscriptions, pending transactions, or other dependencies that might prevent deletion.
  </Step>

  <Step title="Backup Data">
    Consider exporting customer data before deletion if needed for records.
  </Step>

  <Step title="Request Confirmation">
    Implement a confirmation step in your interface to prevent accidental deletions.
  </Step>

  <Step title="Execute Deletion">
    Perform the deletion API call with proper error handling.
  </Step>

  <Step title="Verify Deletion">
    Confirm the customer record has been removed by attempting to fetch it.
  </Step>
</Steps>

## Best Practices

<Card title="Deletion Guidelines">
  * Implement confirmation workflows for deletion requests
  * Handle cascade deletion effects in your application
  * Maintain audit logs of deletion operations
  * Consider soft deletion for recoverable data
  * Respect data privacy regulations (GDPR, CCPA)
</Card>

<Warning>
  If you need to preserve customer data for compliance or business purposes, consider implementing a soft delete mechanism instead of permanent deletion.
</Warning>
