API overview

How the Koil API is shaped — resources, ids, content addressing — and where each part is documented.

The Koil API is a REST API at https://api.koil.co, under /v1. Requests and responses are JSON, every request is authenticated with an API key and names a dated API version, and asynchronous changes are delivered as signed events rather than polled.

Every endpoint, with its parameters, request and response schemas, and samples, is in the generated API endpoints reference; the OpenAPI document it is built from is the contract to generate clients from. This page covers the model the endpoints share.

Principles

  • Versioned by date. Every request with an API key names its version in Koil-Version, and every Event Destination keeps the version it was created with. Within a version, changes are backward compatible; anything else ships as a new version. See Versioning.
  • Profile-scoped. Platform work names the profileId it acts through, never a raw token or platform account id.
  • Safe to retry. Creates and actions on Koil resources take an Idempotency-Key, and writes that start work require one.
  • One error envelope. Every failure has one shape, with a typed code and a retry rule for each code, and a validation error names every field that is wrong. See Errors.
  • One way to page. Every list answers data and hasMore, and a nextCursor while there is more. See Pagination.
  • Events first. Publishes, uploads, connections, and platform content report their outcomes as events. Webhook deliveries are signed in the Standard Webhooks format, every delivery is retried, and a failed one can be sent again; see Verify webhook deliveries. A publish can also wait for its outcome in its response, for a few seconds.
  • Not a store. Platform content is delivered and discarded, held only until its events are published; see Data and storage.
  • One contract in two modes. Sandbox keys use the same endpoints, schemas, and events against emulated platforms.

Resources

ResourceIdWhat it is
Appapp_…Your own OAuth app, registered with Koil. See Bring your own app.
Connect Sessioncs_…A short-lived hosted authorization flow; its url sends your end user to the platform's consent screen.
Connectionconn_…One authorization to act for an account, obtained by one method: oauth, an end user's grant to your App, through a Connect Session or created from one you hold; or key, a key the brand gives you, which you create the Connection from, with no App. Koil holds and renews the credential.
Profileprof_…One platform account, Page, channel, or number reachable through one Connection — what platform operations act through.
Publish requestpub_…One item of content Koil creates on a platform: a post, comment, reply, or message, now or scheduled.
Backfill requestbf_…One re-delivery of a collection's history for a profile. See Backfill history.
Mediamed_…An image, video, audio file or document staged for publishing.
Event Destinationdes_…Where events are delivered and which topics it receives.

Sandbox ids carry a sandbox_ prefix before these (sandbox_prof_…). Platform-owned ids — a post's, a comment's, an account's — stay as the platform defines them and appear as externalId.

What every resource carries

A resource has the same shape wherever it appears: its read, each item of its list, and the data of its lifecycle events.

FieldWhat it is
idThe resource's own id, with its prefix from the table above. The billing account, which an Organization has one of, has none.
kindWhat the resource is, in snake_case: app, connect_session, connection, profile, publish_request, backfill_request, media, event_destination, billing_account. Route on it rather than on which endpoint or topic a payload came from.
modelive or sandbox: which mode's data the resource is. Read it instead of parsing the id's prefix.
createdAt, updatedAtISO-8601 instants, as every other field ending in At is. The billing account has neither.
errorOn a resource whose work can fail (a publish request, a backfill request, media): the same error object an error response carries, with code, message and meta.
metadataYour own key-value pairs: up to 50 keys of at most 40 characters, each with a string value of at most 500. Set it when you create the resource (on each item of a publish or backfill submission, and on a Connection through the Connect Session or POST /v1/connections that makes it), and on an App, Connection, Profile or Event Destination change it with PATCH: the keys you send are merged into what is stored, and a key sent as "" is removed. Koil never reads it. The billing account has none.

A field that refers to another resource is named for it: a Profile's connectionId, a publish request's profileId. Path parameters, request fields and event context name resources the same way, so profileId is always a Profile's id, and an id is always the id of the object that carries it. Code that handles every resource alike, such as a normalized cache or a sync connector, can key each on id.

A create answers 201 Created with the resource as its read returns it, plus anything only the create can give you: a Connect Session's url, a media object's uploadUrl. Publish and backfill requests answer 202 Accepted with the batch they admitted, since their work runs later; a publish submission sent with Prefer: wait waits a few seconds for its outcome, and answers 200 OK if every item has one. A delete answers { kind, id, deleted: true }.

Collections

Platform content is addressed by collection: one platform feed, named {platform}.{surface}.{resource} — instagram.media.comments, youtube.videos.posts. The same name is the kind of every item the collection delivers, the path of content reads, the collection of a publish request, and the middle of every content event topic. Platforms lists every collection and what it supports.

The API serves the same catalog: GET /v1/collections (optionally ?platformId=) and GET /v1/collections/{collection} list each collection's operations, offered or not and why, with the credentials and scopes each needs; the event actions it emits; and whether it can be backfilled. Schemas are given as pointers into the OpenAPI document (schemaRef, and a publish's inputRef), where each is a named component. Like platform discovery, these routes need no key, and neither does GET /v1/issuers, which lists each issuer's methods and the JSON Schema of what a key Connection takes. GET /v1/profiles/{profileId}/capabilities returns the same entries narrowed to one profile's grant.

ToCallStored by Koil
Read platform contentGET /v1/profiles/{profileId}/content/{collection} and GET /v1/profiles/{profileId}/content/{collection}/{externalId}Nothing
Fetch a file an item carriesGET /v1/profiles/{profileId}/content/{collection}/{externalId}/attachments/{attachmentExternalId}, where supportedNothing
Edit contentPATCH /v1/profiles/{profileId}/content/{collection}/{externalId}, where supportedNothing
Act on content: moderate it, like it, or show a read receipt or typingPOST /v1/profiles/{profileId}/content/{collection}/{externalId}/actions, where supportedNothing
Delete contentDELETE /v1/profiles/{profileId}/content/{collection}/{externalId}, where supportedNothing
Create contentPOST /v1/publish-requests with collectionThe ledger entry only
Receive contentcontent.{collection}.{action} eventsNothing

Replies, comments, reposts, and messages are publish requests too — a variant or a target field, not a separate endpoint. See Publish content and Reply to content.

Profile settings

An account setting that belongs to a profile but is not content, such as the greeting and ice breakers Messenger shows a person before they first write, is a profile setting. It is named {platform}.{setting} (facebook.dm_welcome), read with GET /v1/profiles/{profileId}/settings/{setting} and changed with PATCH on the same path: a field you leave out keeps its value, null clears it, and the response is the setting as the platform holds it afterwards. A list such as iceBreakers is replaced whole, so send every locale you want to keep. It runs with the profile's credential like a content read, has no events or backfill, and is listed on its platform's page and, narrowed to one profile's grant, in settings of GET /v1/profiles/{profileId}/capabilities.

curl -X PATCH "https://api.koil.co/v1/profiles/prof_123/settings/facebook.dm_welcome" \  -H "Authorization: Bearer $KOIL_API_KEY" \  -H "Koil-Version: 2026-12-08" \  -H "Content-Type: application/json" \  -d '{  "greeting": null,  "iceBreakers": [    {      "locale": "default",      "questions": [        {          "question": "What are your hours?",          "payload": "HOURS"        },        {          "question": "Where are you?",          "payload": "LOCATION"        }      ]    }  ]}'

Reading content

Content reads go to the platform every time; in sandbox mode they read a emulated platform through the same schemas. A read returns the collection's own schema — the same shape its events carry as data — so a live read and an event about the same item are interchangeable. Comments and messages carry ownerAuthored where Koil can tell whether the Profile wrote them. There is no cross-collection aggregate: to build a unified inbox or timeline, persist the events you receive.

Some collections have no read at all, because the platform offers none: mentions on Instagram, Facebook, and LinkedIn, and WhatsApp messages and delivery statuses arrive only as events, so store them as they arrive. Each platform page says which of its collections can be listed or read.

Add includePlatformRaw=true to a read to receive the platform's own payload as platformRaw beside Koil's fields. It is opaque, platform-defined, and never stored by Koil; events do not carry it.

Fetching attachments

A file a comment, message, or review carries is in its attachments. Where the platform sends a url, fetch it directly; it is signed and expires, so fetch the file rather than store the URL. Where an attachment has only an externalId (a TikTok or WhatsApp DM's image, video, audio, or document), ask for a URL with GET /v1/profiles/{profileId}/content/{collection}/{externalId}/attachments/{attachmentExternalId}, with the ids as the read or event reported them. A collection asks only for what its platform needs to fetch the file: TikTok also takes the item's containerId and the attachment's type as attachmentType in the query; WhatsApp takes neither. It answers { url, expiresAt?, contentType? }. Resolve again when a URL expires.

An Instagram or Messenger DM's files come with URLs that expire, and an event's have no externalId. Read the message again with GET /v1/profiles/{profileId}/content/{collection}/{externalId} for fresh URLs and each file's externalId, or resolve a file whose externalId a read reported. Meta answers either only for a conversation's 20 most recent messages; list the conversation for an older one.

WhatsApp serves a file only to the business, so for WhatsApp the URL is a Koil link that streams the file from WhatsApp as you download it. Koil stores no copy. The link lasts five minutes (expiresAt), so resolve just before you download; it honors Range requests where WhatsApp does. WhatsApp keeps a received file only for a limited time, after which resolving it fails for good, and it has no read to fetch a message again, so download each file when its event arrives.

Editing, acting on, and deleting

PATCH /v1/profiles/{profileId}/content/{collection}/{externalId} edits content the profile wrote where the platform allows it (the text of a Facebook, LinkedIn, or YouTube comment or a Google Business Profile review reply, a YouTube video's details). POST /v1/profiles/{profileId}/content/{collection}/{externalId}/actions performs an action on existing platform content, whether Koil published it or only observed it. Its body is one action from a vocabulary every platform shares — hide, unhide, like, unlike, approve, hold, reject, ban_author, seen, typing_on, typing_off — and each collection takes the ones its platform offers: comments on Instagram and Facebook take hide and unhide, on TikTok also like and unlike, and on YouTube approve, hold, reject and ban_author. Instagram and Facebook conversations take seen, typing_on and typing_off; a WhatsApp DM message from the person takes seen and typing_on, since WhatsApp marks a message read and shows typing only with that. Its platform page and the API reference list them. TikTok also needs the comment's containerId to hide or unhide it. DELETE on the item's path removes it and answers { kind, externalId, deleted: true }.

As on every content route, the path names the profile that acts. An edit takes includePlatformRaw in the query string, as a read does, so the body carries only the change. An edit answers with the item as the platform reports it afterwards, like a read. An action answers with what it applied ({ externalId, action: "hide" }, say) without reading the item back: it is an inbox's highest-volume call, and a platform can report a change before its read reflects it. The moderated event reports the outcome the platform observed. A failure is its error.

Moderation done on the platform itself — a comment hidden in the platform's own app — arrives as content.{collection}.moderated on collections that observe it.

Media

Publish inputs reference media by mediaId or by sourceUrl. Prefer mediaId: create it with POST /v1/media (from an HTTPS sourceUrl Koil fetches, or as a direct upload to the pre-signed URL the response returns), and Koil validates and stages the file before any publish runs. A sourceUrl given directly in a publish must be HTTPS; Koil creates the media from it when the request is submitted, and the publish waits until it is processed, as it does for any media still processing.

Billing

GET /v1/billing-account reports the Organization's plan, the free plan's hard caps (null on paid plans), and the Profile count the profile fee is billed on and the free plan's cap holds: profiles that are active under a Connection that is not invalid. An invalid profile, or one whose Connection is invalid, is not billed. Invoices and payment methods are in the billing portal, reachable from the admin console.

On this page