Sandbox
Build and verify a full Koil integration with sandbox keys and magic grants, before any app is approved.
Every Organization has a sandbox: a sandbox API key uses the same /v1 endpoints, schemas, event topics, idempotency rules, pagination, and error envelopes as a live key, against fully isolated infrastructure and emulated platforms. Nothing a sandbox key does can reach a real platform or live data.
Keys
Every API key belongs to exactly one mode, and the mode is visible in the key itself: koil_live_… or koil_sandbox_…. Send the full value as the bearer token:
Authorization: Bearer koil_sandbox_...The prefix makes a key's environment obvious in an env file and lets leak scanners match it, but it is not what decides the mode: Koil checks the prefix against the key's own mode and rejects a mismatch, and an unprefixed value is rejected outright. Both modes belong to the same Organization and users; switching to the sandbox means using a sandbox key, not a separate account. Create keys in the Koil admin console.
Apps and magic grants
Sandbox mode keeps Apps and Connections exactly as live mode does: records you create, list, update and delete, with the same connection.* events. What it emulates is the platform, so nothing you store in sandbox mode is ever sent to one.
-
Create an App for the platform's issuer with
POST /v1/apps. Any client id and secret will do: Koil stores the secret sealed, as in live mode, and never presents it to a platform. -
Create a Connection from a magic grant with
POST /v1/connections(method: "oauth"), as you would from a grant you already hold. A magic grant is an access token that stands for a platform grant in a known state — the equivalent of a test card number:healthy— an active grant carrying every scope any operation needs.missing_scopes— an active grant carrying only what profile discovery needs, so the profile can be listed and connected and every other operation is refused withscope_insufficient.expired— a grant the platform reports dead: the create is refused withconnection_invalid, as a live create from a revoked grant is.publish_rejected—healthy's grant, except that the platform refuses the content: a publish request through a Profile on it endsfailedwithvalidation_errorwhen the call that creates the content runs, its message naming the scenario.publish_outcome_unknown—healthy's grant, except that the call that creates the content fails ambiguously, as a timeout or a platform server error does: a publish request through it endsoutcome_unknown, with theinternalerror a live one carries.
Every platform that publishes has both publish scenarios, so you can test how you handle a failed publish and an unknown outcome before going live. Apart from publishing, each behaves exactly like
healthy: discovery, connect, reads, edits and actions succeed. Neither fails a YouTube video upload or a reaction on LinkedIn or in a Facebook or Instagram conversation, which succeed through both: Koil retries those calls, since a retry resumes the upload or sets the reaction again, so in live mode they never endoutcome_unknowneither. Each stands for the issuer's one emulated account, as every magic grant does (below), so create a publish scenario's Connection with its ownclientUserIdto keep it beside ahealthyone.
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 Connection's eligible profiles and create a Profile from one, as in live mode. The Quickstart walks through it.
An issuer's magic grants all stand for one emulated account, whatever their platform or scenario (one Google account holds both a channel and a business profile), so they follow live mode's rule for one account: a second Connection for it under the same App and clientUserId is refused with conflict. Create one for each of your own users with its own clientUserId (and metadata), and move a Connection to another scenario by replacing its credential with that scenario's magic grant (PUT /v1/connections/{connectionId}/credential). LinkedIn names no account for a grant, so every LinkedIn create makes a new Connection, and its credential can't be replaced.
The emulated platforms know no other token, so no real one is ever stored in sandbox mode: any other accessToken, or a magic grant through an App of another issuer, is refused with connection_invalid, as a platform refuses a token it never issued. A magic grant renews into itself, so its Connection keeps its scenario.
The catalog below is generated from the same declarations the sandbox serves, so every token listed is one sandbox mode takes, through an App of the issuer it names.
| Access token | App issuer | Platform | Status | Scopes |
|---|---|---|---|---|
sandbox_token_instagram_healthy | facebook | instagram | active | instagram_basic, instagram_content_publish, instagram_manage_comments, instagram_manage_contents, instagram_manage_messages, pages_manage_metadata, pages_read_engagement, pages_show_list |
sandbox_token_instagram_expired | facebook | instagram | invalid | instagram_basic, instagram_content_publish, instagram_manage_comments, instagram_manage_contents, instagram_manage_messages, pages_manage_metadata, pages_read_engagement, pages_show_list |
sandbox_token_instagram_missing_scopes | facebook | instagram | active | instagram_basic, pages_show_list |
sandbox_token_instagram_publish_rejected | facebook | instagram | active | instagram_basic, instagram_content_publish, instagram_manage_comments, instagram_manage_contents, instagram_manage_messages, pages_manage_metadata, pages_read_engagement, pages_show_list |
sandbox_token_instagram_publish_outcome_unknown | facebook | instagram | active | instagram_basic, instagram_content_publish, instagram_manage_comments, instagram_manage_contents, instagram_manage_messages, pages_manage_metadata, pages_read_engagement, pages_show_list |
sandbox_token_facebook_healthy | facebook | facebook | active | pages_manage_engagement, pages_manage_metadata, pages_manage_posts, pages_messaging, pages_read_engagement, pages_read_user_content, pages_show_list, publish_video |
sandbox_token_facebook_expired | facebook | facebook | invalid | pages_manage_engagement, pages_manage_metadata, pages_manage_posts, pages_messaging, pages_read_engagement, pages_read_user_content, pages_show_list, publish_video |
sandbox_token_facebook_missing_scopes | facebook | facebook | active | pages_show_list |
sandbox_token_facebook_publish_rejected | facebook | facebook | active | pages_manage_engagement, pages_manage_metadata, pages_manage_posts, pages_messaging, pages_read_engagement, pages_read_user_content, pages_show_list, publish_video |
sandbox_token_facebook_publish_outcome_unknown | facebook | facebook | active | pages_manage_engagement, pages_manage_metadata, pages_manage_posts, pages_messaging, pages_read_engagement, pages_read_user_content, pages_show_list, publish_video |
sandbox_token_whatsapp_healthy | facebook | whatsapp | active | business_management, whatsapp_business_management, whatsapp_business_messaging |
sandbox_token_whatsapp_expired | facebook | whatsapp | invalid | business_management, whatsapp_business_management, whatsapp_business_messaging |
sandbox_token_whatsapp_missing_scopes | facebook | whatsapp | active | business_management, whatsapp_business_management |
sandbox_token_whatsapp_publish_rejected | facebook | whatsapp | active | business_management, whatsapp_business_management, whatsapp_business_messaging |
sandbox_token_whatsapp_publish_outcome_unknown | facebook | whatsapp | active | business_management, whatsapp_business_management, whatsapp_business_messaging |
sandbox_token_tiktok_healthy | tiktok | tiktok | active | biz.brand.insights, comment.list, comment.list.manage, message.list.read, message.list.send, user.account.type, user.info.basic, user.info.username, video.list, video.publish, video.upload |
sandbox_token_tiktok_expired | tiktok | tiktok | invalid | biz.brand.insights, comment.list, comment.list.manage, message.list.read, message.list.send, user.account.type, user.info.basic, user.info.username, video.list, video.publish, video.upload |
sandbox_token_tiktok_missing_scopes | tiktok | tiktok | active | user.account.type, user.info.basic, user.info.username |
sandbox_token_tiktok_publish_rejected | tiktok | tiktok | active | biz.brand.insights, comment.list, comment.list.manage, message.list.read, message.list.send, user.account.type, user.info.basic, user.info.username, video.list, video.publish, video.upload |
sandbox_token_tiktok_publish_outcome_unknown | tiktok | tiktok | active | biz.brand.insights, comment.list, comment.list.manage, message.list.read, message.list.send, user.account.type, user.info.basic, user.info.username, video.list, video.publish, video.upload |
sandbox_token_youtube_healthy | google | youtube | active | https://www.googleapis.com/auth/youtube.force-ssl |
sandbox_token_youtube_expired | google | youtube | invalid | https://www.googleapis.com/auth/youtube.force-ssl |
sandbox_token_youtube_missing_scopes | google | youtube | active | none |
sandbox_token_youtube_publish_rejected | google | youtube | active | https://www.googleapis.com/auth/youtube.force-ssl |
sandbox_token_youtube_publish_outcome_unknown | google | youtube | active | https://www.googleapis.com/auth/youtube.force-ssl |
sandbox_token_google_business_profile_healthy | google | google_business_profile | active | https://www.googleapis.com/auth/business.manage |
sandbox_token_google_business_profile_expired | google | google_business_profile | invalid | https://www.googleapis.com/auth/business.manage |
sandbox_token_google_business_profile_missing_scopes | google | google_business_profile | active | none |
sandbox_token_google_business_profile_publish_rejected | google | google_business_profile | active | https://www.googleapis.com/auth/business.manage |
sandbox_token_google_business_profile_publish_outcome_unknown | google | google_business_profile | active | https://www.googleapis.com/auth/business.manage |
sandbox_token_linkedin_healthy | linkedin | linkedin | active | r_organization_social, r_organization_social_feed, rw_organization_admin, w_organization_social, w_organization_social_feed |
sandbox_token_linkedin_expired | linkedin | linkedin | invalid | r_organization_social, r_organization_social_feed, rw_organization_admin, w_organization_social, w_organization_social_feed |
sandbox_token_linkedin_missing_scopes | linkedin | linkedin | active | rw_organization_admin |
sandbox_token_linkedin_publish_rejected | linkedin | linkedin | active | r_organization_social, r_organization_social_feed, rw_organization_admin, w_organization_social, w_organization_social_feed |
sandbox_token_linkedin_publish_outcome_unknown | linkedin | linkedin | active | r_organization_social, r_organization_social_feed, rw_organization_admin, w_organization_social, w_organization_social_feed |
Connect Sessions
Connect Sessions work in sandbox mode too, with an emulated consent screen in place of the platform's, which knows no sandbox App. Opening a session's url in a browser goes to the emulated screen, which approves at once and sends the browser through Koil's callback to your returnUrl, as a user who clicks through would. The Connection holds every scope the issuer's platforms need, for the issuer's one emulated account, so a returning user (the same clientUserId) reauthorizes their Connection, however it was made.
To answer the consent screen another way, or from a test with no browser, answer it yourself instead of opening the link:
curl -X POST "https://api.koil.co/v1/sandbox/connect-sessions/sandbox_cs_123/complete" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -d '{ "outcome": "approved"}'approvedgrants every scope the issuer's platforms need, as opening the link does.partial_scopesgrants only what listing the user's platform profiles needs, as a user who unticks permissions does.deniedrefuses: the session endsfailedwithconnection_invalidandmeta.platformCodeaccess_denied.
The session ends as the browser flow ends it, with the same Connection and connection.* events. A link is spent on its first open, so answering a session whose link was opened, or one that is over, is refused with conflict.
Connection status changes
To test how your product handles a Connection that stops working, have its end user revoke the grant at the emulated platform:
curl -X POST "https://api.koil.co/v1/sandbox/connections/sandbox_conn_123/status" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -d '{ "status": "invalid"}'The request answers 202 with the Connection as it stands. Koil then finds the revocation as it finds a live one, by asking the platform about the token, usually within a minute: the Connection becomes invalid and connection.updated is sent, with the statusReason live mode gives for its issuer (revoked, or renewal_failed where Koil checks by renewing, as for Facebook Login and Connect Session grants). Its Profiles are refused with connection_invalid until you replace its credential with a magic grant (PUT /v1/connections/{connectionId}/credential) or reconnect it through a Connect Session, either of which makes it active again with the same id. A Connection that is already invalid is refused with conflict.
The platform revokes this Connection's grant only, as an end user revokes their own: another Connection holding the same magic grant stays active, and a create or replacement made with that magic grant is a fresh grant.
To test the warning that comes before an expiry, create the Connection from a magic grant with an expiresAt less than 14 days away. Nothing can renew a grant without a refresh token, so Koil makes the Connection reauthorization_required (expiring, dated by credential.reauthorizeBy) and, at that date, invalid (expired), as in live mode. A Facebook Login grant renews itself until it is revoked, so it never warns.
Content
A sandbox Profile reads its platform account through the same schemas and pagination rules as a live read, from an emulated account that holds what you publish through it. Every Profile made through one App of one platform account sees the same account, as on the platform; another App's is separate.
YouTube, Instagram, TikTok, Google Business Profile, LinkedIn, Facebook and WhatsApp are emulated so far. A sandbox YouTube channel starts with three videos, the oldest sandbox_video_1 holding a viewer's comment and the channel's own. A sandbox Instagram account starts with three posts, each with a fan's comment, a story, and a DM conversation with the fan (sandbox_meta_fan_1). A sandbox Facebook Page starts the same way, with a fan's post tagging the Page and the conversation on Messenger. A sandbox WhatsApp number has a contact (US.10000000000000000001) and a group they are in, each with a message from them and one from the number. A sandbox TikTok account starts with three posts, the newest holding a fan's comment and the account's own, and a message request from the fan (sandbox_tt_conversation_1). A sandbox Google Business location starts with three reviews: one with an approved reply, a rating-only anonymous one, and one whose reply Google rejected. A sandbox LinkedIn Page starts with one post holding a member's comment, the Page's reply to it, the Page's own comment, and a reaction from each. Other platforms' reads still return fixed emulated data, and their writes succeed without being kept.
To test how you handle content you didn't publish, make it arrive as one of the platform's users would post it:
curl -X POST "https://api.koil.co/v1/sandbox/profiles/sandbox_prof_123/content/youtube.videos.comments" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "fields": { "text": "Where can I buy this?" }}'fields describes the item in the platform's own terms, and differs by collection; one the collection doesn't take is refused with validation_error. Koil then finds the item the way it finds real content, and it reaches your Event Destinations as the collection's content.*.created event within seconds:
- Through the platform's webhook, where the platform sends one (Instagram's, Facebook's and TikTok's comments, mentions and DMs; LinkedIn comments and mentions; everything on WhatsApp). Koil delivers the platform's own payload, signed with your App's secret, to its own webhook route, which verifies and processes it as a real delivery.
- Through the poll, for a collection Koil polls (YouTube, Instagram and Facebook posts and stories, TikTok posts, Google reviews, LinkedIn posts), even where the platform also sends a webhook for it: the collection's poll runs at once. Until the Profile's first poll of the collection has run, the request answers
409 conflictwithRetry-After, because a first poll takes what it finds as its starting point and announces none of it.
Retry with the same Idempotency-Key: a retry answers the same item, whose event keeps its id.
Edits and deletions by the platform's users (PATCH and DELETE on the item's path) reach you the same way, for a collection whose updated or deleted Koil observes, such as a person reacting to a DM, a TikTok post leaving public view, or a reviewer editing a Google review, which the poll finds because reviews are listed most recently changed first. fields is optional where the change has nothing to describe, such as a fan reading a TikTok conversation:
curl -X PATCH "https://api.koil.co/v1/sandbox/profiles/sandbox_prof_123/content/instagram.dm.reactions/sandbox_meta_fan_1%3Asandbox_ig_message_3" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "fields": { "emoji": "🔥" }}'A collection that emits neither, such as YouTube's comments, answers not_supported: Koil can't observe those changes in live mode either.
What is isolated
The sandbox keeps its own database, event delivery, and background workers, so there is no shared state between modes. Every Koil id a sandbox key produces carries a sandbox_ prefix (sandbox_prof_…, sandbox_pub_…, sandbox_med_…), and every resource carries mode and every delivered event context.mode — live or sandbox — so a receiver shared between modes can tell them apart without parsing an id. Event Destinations are per mode too: a sandbox key manages only sandbox destinations.
Reset
To start a test run from an empty sandbox, reset it:
curl -X POST "https://api.koil.co/v1/sandbox/reset" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08"It deletes the sandbox's Connections and Profiles (announced as connection.deleted and profile.deleted), publish and backfill requests, media, Connect Sessions, idempotency records, and the emulated platform accounts with their content. Apps and Event Destinations are kept, and an account starts again from its seed on its next read. A request running beside a reset may leave what it writes behind, so reset between test runs, not during one; repeating a reset is safe.
Scheduled publishes
To test a scheduled publish without waiting for it, release it once it is scheduled:
curl -X POST "https://api.koil.co/v1/sandbox/publish-requests/sandbox_pub_123/release" \ -H "Authorization: Bearer $KOIL_API_KEY" \ -H "Koil-Version: 2026-12-08"It then runs exactly as it would have at its scheduledAt: it moves to started and on to its outcome, with the same publish_request.* events. The response is the publish request as it stands, usually still scheduled for a moment. A request that was not scheduled, or has already started, finished, or been cancelled, is refused with 409 conflict and its current status. Only a sandbox key can release; a live key is refused with not_supported.
Limits
Sandbox usage is never billed. The sandbox accepts media that would need converting to meet a destination's format, size, or frame-rate requirements, without converting it; in live mode that conversion needs a paid plan with active billing, and without one the same publish fails with validation_error and meta.reason media_transform_not_entitled. Sandbox resources are bounded: each Organization may hold a small number of sandbox Profiles (creating one past that is refused with quota_exceeded), sandbox workflows run for at most an hour, not counting a scheduled publish's wait for its scheduledAt, and sandbox state is disposable and may be reset. A run that reaches the hour fails with quota_exceeded. A sandbox publish may be scheduled as far ahead as a live one.