# Embeds

3 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## A signed, expiring iframe URL for the sandbox's terminal or desktop[#]

POST`/v1/sandboxes/{id}/embed`scope sandboxes:write

The page posts {source: "kosa8", type} messages to the listed origins: ready, exited {code}, approval_requested {approval}, expired. See docs/guides/cloud-embed.

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

JSON body

`mode`"view" | "interact"

view (default): watch only, enforced by the server; interact: mouse and keyboard too

`ui`"terminal" | "desktop"

terminal (default), or desktop (the kosa8-desktop image's noVNC)

`ttl_s`integer

How long the URL works (default 3600), never past the sandbox's delete_after Min 60. Max 604800.

`origins`requiredarray of string

The origins that may frame it (CSP frame-ancestors) and receive its postMessage events, such as https://app.example.com

`command`array of string

Terminal only: the program to show instead of the default (a login shell; view mode: the sandbox's tmux session, read-only)

Responses

201400401403404409501

```
curl -s -X POST https://api.kosa8.com/v1/sandboxes/$SBX/embed \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## The sandbox's live embeds (no URLs)[#]

GET`/v1/sandboxes/{id}/embeds`scope sandboxes:read

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/sandboxes/$SBX/embeds \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## End an embed's URL before it expires[#]

DELETE`/v1/sandboxes/{id}/embeds/{embed_id}`scope sandboxes:write

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

`embed_id`requiredpath · string

Embed id (emb_…)

Responses

200401403404

```
curl -s -X DELETE https://api.kosa8.com/v1/sandboxes/$SBX/embeds/$EMBED_ID \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

---
Source: https://docs.kosa8.com/api/embeds/
