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

> ## Agent Instructions
> These docs cover learner integrations through Hosted Lab Pages, the SDK, and the REST API. Content management is outside this integration scope.
> Read the setup page for the chosen approach before implementing it. Keep organization API keys and hosted mint secrets on the server.
> The public SDK is coming soon. Check the SDK quickstart for current availability. Do not invent installation commands or direct readers to a private package.
> Cybr provides completion tracking and CTF verification. The integrating platform decides whether to award points.

# Launching labs

> Launch, restore, and end a learner deployment.

## Launch configuration

```ts theme={null}
const deployment = await cybr.deployments.launch({
  labId,
  learnerId,
  membership: 'free'
})
```

The lab must be available and activated for your organization. The server resolves `learnerId` and membership from its session and access policy.

The optional `sourceIp` identifies the public IP of the learner. Some labs use it for firewall access.

If the lab requires `sourceIp`, read it from trusted request metadata on your server. Do not trust a browser-provided address.

## Save deployment ownership

Store the returned `deployment.id` with the learner session. Before later deployment requests, check that association.

The SDK can create a handle for a saved ID:

```ts theme={null}
const deployment = cybr.deployments.get(savedDeploymentId)
const status = await deployment.getStatus()
```

`deployments.get()` makes no request. It does not check ownership.

## Waiting for the environment to be ready

```ts theme={null}
const ready = await deployment.waitUntilReady()
```

For shorter server requests, poll with `getStatus()` through your own application flow. Both methods use the same status endpoint.

The [lifecycle guide](/guides/lab-lifecycle) describes states and deadlines.

## Show connection details

Outputs vary by lab. An output can be a bare value or a Terraform object with `value`, `type`, and `sensitive`.

```ts theme={null}
function readOutput(raw: unknown) {
  if (typeof raw === 'object' && raw !== null && 'value' in raw) {
    return {
      value: raw.value,
      sensitive: 'sensitive' in raw && raw.sensitive === true
    }
  }
  return { value: raw, sensitive: false }
}
```

Treat passwords, tokens, and keys as secrets even without the `sensitive` field. Show secret values only to the deployment owner.

## Open a terminal

For terminal-enabled labs, create a session through the server SDK:

```ts theme={null}
const session = await deployment.createTerminalSession()
```

The [terminal guide](/guides/terminals) connects this session to a browser terminal.

## End the environment

When the learner selects the end action, call `destroy()`:

```ts theme={null}
await deployment.destroy()
```

A closed page or terminal connection does not itself end the environment. Cybr also applies the lab time limit.
