Quickstart
Connect a sandbox profile, publish a comment, and receive its events — in sandbox mode, with no approved app.
This walks through Koil end to end in sandbox mode: no approved app, no OAuth, no real account. You will connect an emulated 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. It starts with koil_sandbox_.
export KOIL_API_KEY=koil_sandbox_...2. Create a sandbox App
Every Connection belongs to an App, your OAuth client for a platform's issuer. Sandbox mode never sends an App's client anywhere, so any values will do:
curl -X POST "https://api.koil.co/v1/apps" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -d '{ "issuerId": "google", "displayName": "Sandbox YouTube", "clientId": "sandbox", "clientSecret": "sandbox"}'Keep the id it returns (sandbox_app_…).
3. Create a Connection from a magic grant
A magic grant stands in for a platform grant in a known state. sandbox_token_youtube_healthy is a healthy YouTube grant carrying every scope. Create a Connection from it for one of your users:
curl -X POST "https://api.koil.co/v1/connections" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "method": "oauth", "appId": "sandbox_app_123", "clientUserId": "quickstart-user", "grant": { "accessToken": "sandbox_token_youtube_healthy" }}'Then list the channels the Connection (sandbox_conn_…) reaches:
curl "https://api.koil.co/v1/connections/sandbox_conn_123/eligible-platform-profiles" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08"{ "data": [ { "platformId": "youtube", "platformProfileExternalId": "UCtest_yt_channel_1", "displayName": "Sandbox YouTube Channel", "username": "@testyoutubechannel", "avatarUrl": "https://emulator.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}4. Create a Profile
Everything Koil does for a platform account goes through a Profile. Create one from the channel:
curl -X POST "https://api.koil.co/v1/profiles" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "platformId": "youtube", "connectionId": "sandbox_conn_123", "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.
5. 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):
curl -X POST "https://api.koil.co/v1/event-destinations" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -d '{ "type": "webhook", "topics": [ "publish_request.*" ], "config": { "url": "https://example.com/koil/events" }}'6. Publish a comment
Comments, replies, posts, and messages are all publish requests. This one comments on a video:
curl -X POST "https://api.koil.co/v1/publish-requests" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -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:
curl "https://api.koil.co/v1/publish-requests/sandbox_pub_7GhQ2dLkP0aZ1xYc9VwN" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08"Next
- Create Connections from
sandbox_token_youtube_expiredandsandbox_token_youtube_missing_scopesto see how failures surface (Errors). - Verify webhook deliveries before trusting them.
- See everything a YouTube channel supports, and the
argsof every publish, on YouTube. - When your app is approved, register it and switch to a live key.
Overview
Koil is social infrastructure for SaaS products that serve brands: one API to receive the comments, DMs, mentions, and reviews across your customers' accounts as a single event stream, and to reply, moderate, and publish, all on your own apps.
Guides
Step-by-step guides for connecting platform accounts, publishing content, receiving events, and replying to platform content.