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

# Create ExtraServiceTimeSlot

> Create a new ExtraServiceTimeSlot record.

An **ExtraServiceTimeSlot** defines the days and times during which an `ExtraService` (resource pricing rule) is available for booking. Each time slot specifies a day of the week and a from/to time window.

The year, month, and day components of `FromTime` and `ToTime` are always `1976-01-01` — only the time-of-day portion is meaningful.

When no time slots are defined for an extra service, the price applies at all times. Adding time slots restricts the price to the specified windows only.

## Authentication

<Note>
  This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
  The authenticated user must be a full unrestricted administrator or have the **`ExtraServiceTimeSlot-Create`** role.
</Note>

## Request Body

### Required Fields

<ParamField body="ExtraServiceId" type="integer" required>
  Extra Service Id.
</ParamField>

<ParamField body="FromTime" type="string" required>
  Start time of the availability window. Only the time-of-day component is used; the date component is always 1976-01-01..
</ParamField>

<ParamField body="ToTime" type="string" required>
  End time of the availability window. Only the time-of-day component is used; the date component is always 1976-01-01..
</ParamField>

<ParamField body="DayOfWeek" type="integer" required>
  Day Of Week.
</ParamField>

### Optional Fields

<ParamField body="Available" type="boolean">
  Whether the extra service is available for booking during this time slot. When false, the slot acts as an explicit block..
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/billing/extraservicetimeslots" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "ExtraServiceId": 0,
      "FromTime": "2025-01-15T10:30:00Z",
      "ToTime": "2025-01-15T10:30:00Z",
      "DayOfWeek": 0
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/billing/extraservicetimeslots',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        ExtraServiceId: 0,
        FromTime: '2025-01-15T10:30:00Z',
        ToTime: '2025-01-15T10:30:00Z',
        DayOfWeek: 0
      })
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://spaces.nexudus.com/api/billing/extraservicetimeslots',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'ExtraServiceId': 0,
          'FromTime': '2025-01-15T10:30:00Z',
          'ToTime': '2025-01-15T10:30:00Z',
          'DayOfWeek': 0
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### 200

<ResponseField name="Status" type="integer">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="Message" type="string">
  A human-readable message confirming the creation.
</ResponseField>

<ResponseField name="Value" type="object">
  Contains the `Id` of the newly created record.
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `true` if the extraservicetimeslot was created successfully.
</ResponseField>

<ResponseField name="Errors" type="array">
  `null` on success.
</ResponseField>

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "ExtraServiceTimeSlot was successfully created.",
  "Value": {
    "Id": 87654321
  },
  "OpenInDialog": false,
  "OpenInWindow": false,
  "RedirectURL": null,
  "JavaScript": null,
  "UpdatedOn": "2025-01-15T10:30:00Z",
  "UpdatedBy": "admin@example.com",
  "Errors": null,
  "WasSuccessful": true
}
```

### 400

<ResponseField name="Message" type="string">
  A summary of the validation error(s), in the format `PropertyName: error message`.
</ResponseField>

<ResponseField name="Value" type="any">
  `null` on validation failure.
</ResponseField>

<ResponseField name="Errors" type="object[]">
  Array of validation errors.

  <Expandable>
    <ResponseField name="AttemptedValue" type="any">
      The value that was submitted for the field, or `null` if missing.
    </ResponseField>

    <ResponseField name="Message" type="string">
      The validation error message.
    </ResponseField>

    <ResponseField name="PropertyName" type="string">
      The name of the property that failed validation.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `false` when the request fails validation.
</ResponseField>

```json Example Response theme={null}
{
  "Message": "FromTime: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "FromTime"
    }
  ],
  "WasSuccessful": false
}
```
