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

# Mark Disconnect Complete

Mark the domain disconnect as complete after Entri restores the original DNS records.

## When to Use

Call this endpoint after Entri successfully restores the user's original DNS records during the disconnect flow. This updates the proxy status to "DISCONNECTED" while preserving CloudFront and ACM for fast reconnection later.

## What This Does

1. Updates proxy\_status to "DISCONNECTED"
2. Preserves CloudFront distribution (no recreation needed on relink)
3. Preserves ACM certificate (continues auto-renewing)
4. Enables fast reconnection via the 2-step DNS flow

## Example Request

```bash theme={null}
curl -X POST https://searchcompany-main.up.railway.app/api/domain/mark-disconnect-complete/org_xxx \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## Example Response

```json theme={null}
{
  "status": "success",
  "proxy_status": "DISCONNECTED",
  "message": "Domain disconnected. CloudFront and SSL certificate preserved for fast reconnection.",
  "can_reconnect": true
}
```

## Response Fields

| Field          | Type    | Description                      |
| -------------- | ------- | -------------------------------- |
| status         | string  | success or error                 |
| proxy\_status  | string  | DISCONNECTED                     |
| message        | string  | Human-readable status message    |
| can\_reconnect | boolean | True if CloudFront/ACM preserved |

## Proxy Status Flow

```
PENDING_VALIDATION → SSL_VALIDATING → SSL_VALIDATED → DEPLOYED
                                                         ↓
                                                    DISCONNECTED
                                                         ↓
                                              (User clicks Reconnect)
                                                         ↓
                                              PENDING_VALIDATION → ...
```

## Frontend Integration

```typescript theme={null}
// After Entri completes the disconnect flow
const handleEntriClose = async (success: boolean) => {
  if (success) {
    // Mark disconnect complete
    const result = await markDisconnectComplete(orgId, token);
    
    if (result.status === "success") {
      // Show reconnect option to user
      showReconnectButton();
    }
  }
};
```

## Reconnection Flow

When a user wants to reconnect after disconnecting:

1. **No CloudFront setup needed** - distribution already exists
2. **Start certificate** - if SSL expired, or skip if still valid
3. **2-step DNS flow** - SSL CNAME → www CNAME
4. **Mark step 2 complete** - status becomes DEPLOYED

This is much faster than initial setup because CloudFront and ACM are preserved.

## Why Preserve Infrastructure?

| Resource        | Cost When Idle    | Benefit                             |
| --------------- | ----------------- | ----------------------------------- |
| CloudFront      | Free (no traffic) | Instant relink (no 15-min creation) |
| ACM Certificate | Free              | Auto-renews forever, no user action |

## Error Responses

### Organization Not Found

```json theme={null}
{
  "detail": "Organization not found"
}
```

### No Proxy Configuration

```json theme={null}
{
  "detail": "No proxy configuration found"
}
```
