# End a preview

Source: https://docs.vlayers.ai/reference/hosting/end-endpoint-preview

`DELETE /v1/endpoints/{endpoint}/previews/{preview}` · scope `workspace:write`

Ends a preview now: its address stops answering, its sessions stop working and its room (if awake) is drained. The record stays, with the reason, in the list.

Requires an API key with the `workspace:write` scope.

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `endpoint` | path | string | yes | The endpoint id: the first segment of its `run.vlayers.ai` URL. Example: `"x7k2p4q9m3vd"` |
| `preview` | path | string | yes | The preview id from `GET /v1/endpoints/{endpoint}/previews`. Example: `"0192f5c1-5e6f-7a8b-9c0d-1e2f3a4b5c67"` |

## Request

cURL:

```bash
curl -X DELETE "https://api.vlayers.ai/v1/endpoints/$ENDPOINT_ID/previews/$PREVIEW_ID" \
  -H "Authorization: Bearer $VOICELAYER_API_KEY"
```

TypeScript:

```ts
import { VoiceLayer } from '@voicelayer/api';

const voicelayer = new VoiceLayer();

const { state } = await voicelayer.hosting.endEndpointPreview('<endpoint-id>', '<preview-id>');
console.log(state);
```

Python:

```python
from voicelayer import VoiceLayer

vl = VoiceLayer()

result = vl.hosting.end_endpoint_preview("<endpoint-id>", "<preview-id>")
print(result.state)
```

## Response `200`

```json
{
  "id": "0192f5c1-5e6f-7a8b-9c0d-1e2f3a4b5c67",
  "endpointId": "x7k2p4q9m3vd",
  "agentId": "0192f5c2-6f7a-7b9c-8d1e-2f3a4b5c6d78",
  "environment": "dev",
  "versionId": "0192f5c2-6f7a-7b9c-8d1e-2f3a4b5c6d78",
  "state": "ended",
  "createdAt": "2026-10-20T15:04:05.000Z",
  "expiresAt": "2026-10-20T15:04:05.000Z",
  "lastRequestAt": "2026-10-20T15:04:05.000Z",
  "sleepsAt": null,
  "endedAt": "2026-10-20T15:04:05.000Z",
  "endedReason": "customer",
  "endedMessage": "This preview was ended.",
  "routes": [
    {
      "kind": "api",
      "url": "https://run.vlayers.ai/x7k2p4q9m3vd--0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b/api"
    }
  ]
}
```
