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

# End Session

> End an existing session to cleanup resources and terminate conversation context.

<Warning>
  **Deprecated.** This endpoint is deprecated and will be **sunset on 2026-07-11**. It still works until then. Migrate to the V1 path -- see the [migration guide](/en/migrations/2026-06-outbound-api-v1) for the old -> new path table.
</Warning>

End an existing session when the conversation is complete. This is useful for cleanup and resource management.

## Base URL

```
https://api.pathors.com
```

## End Session

```bash theme={null}
DELETE https://api.pathors.com/project/{projectId}/session
```

### Path Parameters

<ParamField path="projectId" type="string" required>
  The ID of your project
</ParamField>

### Request Headers

<ParamField header="Authorization" type="string" required>
  Bearer token authentication using your Project API Key (starts with `sk_`). Format: `Bearer {your-api-key}`
</ParamField>

### Request Body

<ParamField body="session_id" type="string" required>
  The unique identifier of the session to end
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates whether the session was successfully ended
</ResponseField>

<ResponseField name="sessionId" type="string">
  The ID of the ended session
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message that the session has been ended
</ResponseField>

## Example

### Request

```bash theme={null}
curl -X DELETE https://api.pathors.com/project/{projectId}/session \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "session_id": "user-123-session-456"
  }'
```

### Response

```json theme={null}
{
  "success": true,
  "sessionId": "user-123-session-456",
  "message": "Session ended successfully"
}
```

## Usage Notes

* **Resource Cleanup**: Ending sessions helps free up server resources and should be done when conversations are complete
* **Session Variables**: All session variables and conversation context are permanently removed when a session is ended
* **Session Management**: The API will attempt to end the specified session. Success is returned regardless of whether the session was active

## Error Responses

| Status Code | Description                    |
| ----------- | ------------------------------ |
| 400         | Missing or invalid session\_id |
| 401         | Invalid authentication         |
| 500         | Internal server error          |

Example error responses:

**400 Bad Request:**

```json theme={null}
{
  "error": "session_id is required"
}
```

**401 Unauthorized:**

```json theme={null}
{
  "error": {
    "message": "Invalid authentication"
  }
}
```

## Best Practices

1. **Always End Sessions**: End sessions when conversations are complete to prevent resource leaks
2. **Error Handling**: Handle errors gracefully and implement appropriate retry logic for failed requests
3. **Session Tracking**: Keep track of active session IDs in your application to manage them properly
