Exchange an OIDC token
Exchanges an OIDC ID token from a CI or hosting provider (GitHub Actions, Vercel, GitLab, CircleCI or any issuer an environment trusts) for a short-lived access token, so no API key has to be stored there. The token must come from the credential's issuer, be issued for its audience and meet every condition on its claims. Needs no API key. Every refusal is the same invalid_oidc_token; the reason is in the environment's logs. DELETE /v1/api_key with the access token revokes just that token.
Coss-Version?"2026-10-10"The API version (a date) to use for this request. Defaults to your organization's version, pinned to the latest one when it first used the API and upgraded from the dashboard. The SDK always sends the version it was built for.
"2026-10-10"application/json- body
- body
- …
credential_id*stringThe OIDC credential to exchange through (oidc_…, shown on the environment's API keys page). Not a secret: it can live in a workflow file.
1 <= length <= 64token*stringThe OIDC ID token your CI or hosting provider issued to this job or function (a JWT).
1 <= length <= 16384The access token.
application/json- response
- response
- …
A short-lived access token exchanged for an OIDC ID token.
object*"oidc_access_token""oidc_access_token"access_token*stringUse it as an API key (Authorization: Bearer …) until it expires. It can do what the credential allows, in the credential's environment.
token_type*"Bearer""Bearer"expires_in*integerSeconds until it expires.
expires_at*stringWhen it expires (ISO 8601).
environment_id*stringThe environment it works in.
import { Coss } from "coss";const coss = new Coss({ apiKey: process.env.COSS_API_KEY, baseUrl: "https://api.coss.com",});const { data, error } = await coss.oidc.exchangeToken({ credential_id: "oidc_01k7c8m4q2f3e9v6t5r1n0p8yz", token: "eyJhbGciOiJSUzI1NiIsImtpZCI6Ii4uLiJ9.eyJpc3MiOiIuLi4ifQ.c2lnbmF0dXJl",});{ "object": "oidc_access_token", "access_token": "coss_live_oidc_3q2-7wEVR6aZ1xYb0pN4kL8sT5uC9dF2gH6jM1nP0rQ", "token_type": "Bearer", "expires_in": 3600, "expires_at": "2026-11-13T13:00:00.000Z", "environment_id": "env_01k7c8m4q2f3e9v6t5r1n0p8yz"}