# Using the Sandbox

The Xenia Connect API provides a sandbox environment for testing your integration without affecting production data. The sandbox environment includes special endpoints that allow you to simulate state changes and trigger webhook events for testing purposes.

## Sandbox Environment

- **Base URL**: `https://api-xenia-cisandbox.staysitu.com`
- **Authentication**: Use your sandbox API key (same authentication method as production)


## Sandbox-Specific Endpoints

The sandbox environment provides two special endpoints under the `/external-api/v1/sandbox` path that are **not available in production**. These endpoints are designed to help you test your integration thoroughly.

### 1. Change Enquiry State

**Endpoint**: `POST /external-api/v1/sandbox/enquiries/{id}/change-state`

This endpoint allows you to programmatically change the state of an enquiry to trigger relevant webhook events and test your integration's handling of different enquiry states.

#### Key Features

- **Progressive State Changes**: You cannot move backwards in states, only forward
- **Cascading State Triggers**: Specifying a later state (e.g., `QUOTED`) will automatically trigger all eligible intermediate states (e.g., `SHORTLISTING` then `QUOTED`)
- **Exception States**: Some states like `CLOSED` can occur at any point in the journey


#### Request Parameters

- **Path Parameter**:
  - `id` (required): Can be either the enquiry's `xeniaReference` or your `externalId`
- **Request Body**:

```json
{
  "enquiryState": "QUOTED",
  "closureReason": "PRICE"  // Optional, only for CLOSED state
}
```


For all available states, please refer to the [API specification](/xenia-connect/spec).

#### Example Usage

```bash
curl -X POST "https://api-xenia-cisandbox.staysitu.com/external-api/v1/sandbox/enquiries/R4E2F3A4/change-state" \
  -H "X-Api-Key: your-sandbox-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "enquiryState": "CLOSED",
    "closureReason": "PRICE"
  }'
```

### 2. Trigger Webhook Event

**Endpoint**: `POST /external-api/v1/sandbox/enquiries/{id}/trigger-webhook-event`

This endpoint allows you to manually trigger specific webhook events for an enquiry without changing its state. This is particularly useful for testing webhook handling and retry logic.

#### Request Parameters

- **Path Parameter**:
  - `id` (required): Can be either the enquiry's `xeniaReference` or your `externalId`
- **Request Body**:

```json
{
  "eventType": "ENQUIRY.CREATED"
}
```


For all available webhook event types, please refer to the [API specification](/xenia-connect/spec).

#### Example Usage

```bash
curl -X POST "https://api-xenia-cisandbox.staysitu.com/external-api/v1/sandbox/enquiries/R4E2F3A4/trigger-webhook-event" \
  -H "X-Api-Key: your-sandbox-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "eventType": "ENQUIRY.CREATED"
  }'
```