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

# Sessions

> Host and manage BloxCord training/session events from in-game.

Session methods let a host start and run a session (training, raid, shift, etc.) entirely from inside the experience. All of them take an **actor** as the first argument (the host) and an **opts** table as the second.

<Note>
  A session is identified by its **session id** (`sid`), returned when you [start a session](#startsession). Pass that `sid` to every subsequent session method.
</Note>

## getSessionReservations

Returns the sessions currently reserved/scheduled for your organization.

```lua theme={null}
local reservations = BloxCord:Invoke("getSessionReservations", actor)
```

### Parameters

<ParamField body="actor" type="Player | table | number" required>
  The requesting host. See [the actor object](/gi-concepts#the-actor-object).
</ParamField>

### Returns

<ResponseField name="reservations" type="object[]">
  An array of reservation records. Empty if there are none or the request failed.
</ResponseField>

***

## startSession

Starts hosting a session.

```lua theme={null}
local result = BloxCord:Invoke("startSession", actor, opts)
```

### Parameters

<ParamField body="actor" type="Player | table | number" required>
  The host starting the session. See [the actor object](/gi-concepts#the-actor-object).
</ParamField>

<ParamField body="opts" type="table" required>
  Session options.

  <Expandable title="opts fields">
    <ParamField body="typeId" type="string">
      The id of the session type to host.
    </ParamField>

    <ParamField body="mode" default="on-demand" type="string">
      The session mode.
    </ParamField>

    <ParamField body="administration" type="table">
      Administration/config data for the session.
    </ParamField>

    <ParamField body="exclusive" default="false" type="boolean">
      Whether the session is exclusive.
    </ParamField>

    <ParamField body="timeWindow" type="table">
      Optional scheduled time window for the session.
    </ParamField>
  </Expandable>
</ParamField>

### Returns

<ResponseField name="result" type="table | nil">
  The started-session payload (including its `sid`) on success, or `nil` on failure.
</ResponseField>

### Example

```lua theme={null}
local BloxCord = game:WaitForChild("BloxCord")

local session = BloxCord:Invoke("startSession", host, {
    typeId = "training-basic",
    mode = "on-demand",
    exclusive = false,
})

local sid = session and session.sid
```

***

## sessionUpdateAttendees

Adds or removes attendees from a running session.

```lua theme={null}
local result = BloxCord:Invoke("sessionUpdateAttendees", actor, opts)
```

### Parameters

<ParamField body="actor" type="Player | table | number" required>
  The host performing the update.
</ParamField>

<ParamField body="opts" type="table" required>
  <Expandable title="opts fields">
    <ParamField body="sid" type="string" required>
      The session id.
    </ParamField>

    <ParamField body="add" type="table">
      Attendees to add.
    </ParamField>

    <ParamField body="remove" type="table">
      Attendees to remove.
    </ParamField>
  </Expandable>
</ParamField>

### Returns

<ResponseField name="result" type="table | nil">
  The update result on success, or `nil` on failure.
</ResponseField>

***

## sessionUpdateMark

Sets or clears a phase mark for a specific attendee (e.g. marking a checkpoint as passed).

```lua theme={null}
local result = BloxCord:Invoke("sessionUpdateMark", actor, opts)
```

### Parameters

<ParamField body="actor" type="Player | table | number" required>
  The host performing the update.
</ParamField>

<ParamField body="opts" type="table" required>
  <Expandable title="opts fields">
    <ParamField body="sid" type="string" required>
      The session id.
    </ParamField>

    <ParamField body="attendeeId" type="number | string" required>
      The attendee's id.
    </ParamField>

    <ParamField body="phaseId" type="string" required>
      The phase to mark.
    </ParamField>

    <ParamField body="value" default="false" type="boolean">
      The mark value.
    </ParamField>
  </Expandable>
</ParamField>

### Returns

<ResponseField name="result" type="table | nil">
  The update result on success, or `nil` on failure.
</ResponseField>

***

## sessionUpdateStrike

Adds or removes a strike against an attendee.

```lua theme={null}
local result = BloxCord:Invoke("sessionUpdateStrike", actor, opts)
```

### Parameters

<ParamField body="actor" type="Player | table | number" required>
  The host performing the update.
</ParamField>

<ParamField body="opts" type="table" required>
  <Expandable title="opts fields">
    <ParamField body="sid" type="string" required>
      The session id.
    </ParamField>

    <ParamField body="attendeeId" type="number | string" required>
      The attendee's id.
    </ParamField>

    <ParamField body="action" default="add" type="string">
      Either `"add"` or `"remove"`.
    </ParamField>

    <ParamField body="reason" type="string">
      Reason for the strike (when adding).
    </ParamField>

    <ParamField body="strikeId" type="string">
      The strike id (when removing).
    </ParamField>
  </Expandable>
</ParamField>

### Returns

<ResponseField name="result" type="table | nil">
  The update result on success, or `nil` on failure.
</ResponseField>

***

## sessionUpdatePhase

Adds, removes, or renames a phase within a session.

```lua theme={null}
local result = BloxCord:Invoke("sessionUpdatePhase", actor, opts)
```

### Parameters

<ParamField body="actor" type="Player | table | number" required>
  The host performing the update.
</ParamField>

<ParamField body="opts" type="table" required>
  <Expandable title="opts fields">
    <ParamField body="sid" type="string" required>
      The session id.
    </ParamField>

    <ParamField body="action" type="string" required>
      The phase action to perform.
    </ParamField>

    <ParamField body="phaseId" type="string">
      The target phase id.
    </ParamField>

    <ParamField body="name" type="string">
      The phase name (for add/rename).
    </ParamField>
  </Expandable>
</ParamField>

### Returns

<ResponseField name="result" type="table | nil">
  The update result on success, or `nil` on failure.
</ResponseField>

***

## sessionUpdateSession

Transitions the session's state (e.g. moving it to a new status).

```lua theme={null}
local result = BloxCord:Invoke("sessionUpdateSession", actor, opts)
```

### Parameters

<ParamField body="actor" type="Player | table | number" required>
  The host performing the update.
</ParamField>

<ParamField body="opts" type="table" required>
  <Expandable title="opts fields">
    <ParamField body="sid" type="string" required>
      The session id.
    </ParamField>

    <ParamField body="to" type="string" required>
      The target state to transition to.
    </ParamField>

    <ParamField body="reason" type="string">
      Optional reason for the transition.
    </ParamField>
  </Expandable>
</ParamField>

### Returns

<ResponseField name="result" type="table | nil">
  The update result on success, or `nil` on failure.
</ResponseField>

### Example

```lua theme={null}
local BloxCord = game:WaitForChild("BloxCord")

BloxCord:Invoke("sessionUpdateSession", host, {
    sid = sid,
    to = "ended",
    reason = "Training complete",
})
```
