Export an `oauth` Connection's current platform grant
Export an oauth Connection's current platform grant. Requires an API key with the credentials:export permission. Any other method is refused with not_supported: Koil exports only what a platform issued to an authorization it ran, never a key someone submitted.
Authorization
bearerAuth credentials:exportAn API key from the Koil admin console, sent as Authorization: Bearer <key>. A live key starts koil_live_ and a sandbox key koil_sandbox_; the key alone selects the Organization and mode. See https://docs.koil.co/concepts/authentication.
In: header
Scope: credentials:export
Path Parameters
1 <= lengthHeader Parameters
The dated API version the request is written against; it fixes the request and response shapes. Every response echoes the version it is rendered in.
"2026-12-01"Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X GET "https://example.com/v1/connections/string/credential" \ -H "Koil-Version: 2026-12-01"{ "connectionId": "conn_123", "method": "oauth", "appId": "app_123", "clientUserId": "customer-user-123", "grant": { "accessToken": "EAAG...", "refreshToken": "rft.8f2c...", "expiresAt": "2026-07-01T10:30:00.000Z" }, "scopes": [ "instagram_basic", "pages_show_list" ]}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}{ "error": { "code": "validation_error", "message": "string", "meta": { "violations": [ { "code": "string", "path": "string", "message": "string" } ], "budgets": [ "string" ], "profileIds": [ "string" ], "required": [ "string" ], "limit": 0, "resourceType": "string", "resourceId": "string", "reason": "string", "refusalReason": "messaging_window_closed", "property1": null, "property2": null }, "requestId": "string" }}Create a Koil Connection from a credential you already hold POST
Create a Koil Connection from a credential you already hold: for `method: "oauth"`, a platform grant an end user gave your App, so adopting Koil costs no reauthorization; for `method: "key"`, a key the brand gave you, as `key`: the `config` and `secret` its issuer declares (`GET /v1/issuers`), with no App. Requires an `Idempotency-Key`. The credential is first checked with the platform, and refused with `connection_invalid` if the platform rejects it, with nothing stored. It always creates: a credential for an account that already has a Connection under the same issuer, App (none for a key) and `clientUserId` is refused with `conflict` (409), whose `meta.resourceId` names that Connection; replace its credential with `PUT /v1/connections/{connectionId}/credential`. The new Connection takes the request's `metadata`. A grant whose access token has expired is renewed first and its fresh token checked, and refused if the platform refuses to renew it or nothing can. A key's `secret` is sealed and never returned. For `method: "oauth"`, the answer names the App's scopes the grant lacks (`missingScopes`), as a completed Connect Session does.
Replace a Connection's credential with a new one of its own method, for the same platform account PUT
Replace a Connection's credential with a new one of its own method, for the same platform account: a new key (`method: "key"`, with `key`: its `config` and `secret`), or a fresh grant (`method: "oauth"`). The credential is first checked with the platform, and refused with `connection_invalid` if the platform rejects it; one for another account is refused with `validation_error` (`subject_mismatch`). Nothing is stored unless both pass. The Connection keeps its id, Profiles and `metadata`, becomes `active` again as a reconnect would (an `invalid` one included), and announces `connection.updated`.