# Quickstart

> Connect a sandbox profile, publish a comment, and receive its events — in sandbox mode, with no app.

This walks through Koil end to end in [sandbox mode](https://docs.koil.co/sandbox): no app, no OAuth, no real account. You will connect a simulated YouTube channel, subscribe to events, and publish a comment through it. Every step below is also run by Koil's own test suite against sandbox mode, so it stays accurate.

## 1\. Get a sandbox key

Create a sandbox API key in the [admin console](https://admin.koil.co/). It starts with `koil_sandbox_`.

```bash
export KOIL_API_KEY=koil_sandbox_...
```

## 2\. Pick a profile from a magic connection

Magic connections stand in for real Connections in sandbox mode. `sandbox_conn_youtube_healthy` is a healthy YouTube Connection carrying every scope. List the channels it reaches:

```bash
curl "https://api.koil.co/v1/connections/sandbox_conn_youtube_healthy/eligible-platform-profiles" \
  -H "Authorization: Bearer $KOIL_API_KEY" \
  -H "Koil-Version: 2026-12-01"
```

200 response

```json
{
  "data": [
    {
      "platformId": "youtube",
      "platformProfileExternalId": "UCtest_yt_channel_1",
      "displayName": "Sandbox YouTube Channel",
      "username": "@testyoutubechannel",
      "avatarUrl": "https://fixture.invalid/sandbox_yt_avatar.jpg",
      "accountKind": "channel",
      "supportedOperations": [
        "videos.comments.delete",
        "videos.comments.get",
        "videos.comments.list",
        "videos.comments.perform_action",
        "videos.comments.publish",
        "videos.comments.update",
        "videos.posts.delete",
        "videos.posts.get",
        "videos.posts.list",
        "videos.posts.perform_action",
        "videos.posts.publish",
        "videos.posts.update"
      ],
      "platformDetails": {
        "followersCount": 0,
        "postsCount": 0,
        "madeForKids": false
      }
    }
  ],
  "hasMore": false
}
```

## 3\. Create a Profile

Everything Koil does for a platform account goes through a Profile. Create one from the channel:

```bash
curl -X POST "https://api.koil.co/v1/profiles" \
  -H "Authorization: Bearer $KOIL_API_KEY" \
  -H "Koil-Version: 2026-12-01" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "platformId": "youtube",
  "connectionId": "sandbox_conn_youtube_healthy",
  "platformProfileExternalId": "UCtest_yt_channel_1"
}'
```

Keep the `id` it returns (`sandbox_prof_…`): the requests below send it as `profileId`, with an example id where yours goes.

## 4\. Subscribe to events

Point an Event Destination at an HTTPS endpoint you control — a request inspector is fine for trying this out — and subscribe it to publish lifecycle events (a webhook is the quickest to try; queues and streams [work the same way](https://docs.koil.co/guides/subscribe-to-events#choose-a-destination-type)):

```bash
curl -X POST "https://api.koil.co/v1/event-destinations" \
  -H "Authorization: Bearer $KOIL_API_KEY" \
  -H "Koil-Version: 2026-12-01" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "webhook",
  "topics": [
    "publish_request.*"
  ],
  "config": {
    "url": "https://example.com/koil/events"
  }
}'
```

## 5\. Publish a comment

Comments, replies, posts, and messages are all publish requests. This one comments on a video:

```bash
curl -X POST "https://api.koil.co/v1/publish-requests" \
  -H "Authorization: Bearer $KOIL_API_KEY" \
  -H "Koil-Version: 2026-12-01" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "publishRequests": [
    {
      "collection": "youtube.videos.comments",
      "profileId": "sandbox_prof_4T2cgH9gnSqEb9DrntKA",
      "args": {
        "target": {
          "kind": "youtube.videos.posts",
          "externalId": "sandbox_video_1"
        },
        "text": "Hello from Koil"
      }
    }
  ]
}'
```

Koil answers `202 Accepted` with the publish request in `publishRequests`: its `id` (`sandbox_pub_…`, used below in place of the example's) and `status: "created"`. As the publish runs, your endpoint receives its `publish_request.*` events, ending in `publish_request.succeeded`. Each carries the publish request exactly as this read, which you can also poll, returns it:

```bash
curl "https://api.koil.co/v1/publish-requests/sandbox_pub_7GhQ2dLkP0aZ1xYc9VwN" \
  -H "Authorization: Bearer $KOIL_API_KEY" \
  -H "Koil-Version: 2026-12-01"
```

## Next

-   Try `sandbox_conn_youtube_expired` and `sandbox_conn_youtube_missing_scopes` to see how failures surface ([Errors](https://docs.koil.co/concepts/errors)).
-   [Verify webhook deliveries](https://docs.koil.co/guides/verify-webhooks) before trusting them.
-   See everything a YouTube channel supports, and the `args` of every publish, on [YouTube](https://docs.koil.co/platforms/youtube).
-   When your app is approved, [register it](https://docs.koil.co/byo-apps) and switch to a live key.
