protectionId values, credentials, gateways, and
runtime tokens.
protectionId; it never accepts the parent OAuth connection ID, gateway ID, credential ID, or token ID.
An ID from another connection returns 404 without revealing whether it exists.
Authentication and scopes
Send the OAuth access token asAuthorization: Bearer. Required scopes:
protections:provision— provider discovery, preflight, model discovery, and creation.protections:read— list and read protections.protections:update— gateway name, models, settings, and entitled OTel configuration.protections:manage— revoke, reactivate, and rotate provider/runtime credentials.protections:read-logs— request metadata for runtime tokens owned by this installation.protections:read-spend— token usage and monetary spend for this installation.offline_access— rotating refresh tokens.
Resolve providers
slug; never hard-code the UUID.
kind, native_base_path, and base_url_default describe the provider and its upstream API. They do
not form an /gw/... URL. Build data-plane URLs from the returned gateway slug with
buildGatewayConnectionConfig() or use the connection paths documented in
Connect an AI client.
kind is one of openai-compatible, anthropic, gemini, or arc.
Preflight
Preflight performs no writes and receives no provider key.project and serviceAccount in resources become 0, and project
contains the existing installation project.
Discover models
canonicalId, aliases, modes, lifecycle, and pricing are optional because upstream catalogs do
not all publish them. capabilities describes the provider claim;
supportedCapabilities and airctrlSupport describe what can safely route.
Capability values are chat, vision, tools, streaming, responses, embeddings,
image_generation, audio, realtime, moderation, ocr, completions, code_completion, video,
native_completion, code_generation, generative_ui, research, document_generation, and
browser.
An upstream 401 or 403 is a typed, non-exceptional invalid-key result:
Create one protection
Use one stable idempotency key for one external key and request body. Reuse both unchanged after an uncertain network result.
Creation is atomic. The first protection lazily creates the connection’s project and internal Service
Account, and adds the approving user to the project as
ProjectAdmin. Every protection creates its own
credential, gateway, model bindings, and runtime token.
That gateway token has only the data-plane run scope; it cannot manage resources or read logs.
externalResourceId → protectionId. The nested IDs are metadata; lifecycle operations require
only protectionId.
List and read protections
{ "ok": true, "data": [...] }; the read response uses
{ "ok": true, "data": { ... } }. Runtime token plaintext is omitted from ordinary list/read
responses.
active— runtime access is enabled.connection_suspended— an installation disconnect disabled runtime access; this protection is eligible for automated restoration after reauthorization.revoked— this protection was explicitly revoked and must never be restored automatically.
reactivate for the selected
connection_suspended entries. A partner may reactivate several existing protections and provision
new external keys in the same OAuth session. Each operation remains independent and idempotent.
The connection-details surface presents current permissions separately from Connection history.
Every Connect/Disconnect history event includes the scope snapshot effective for that event, so later
reauthorization never rewrites the evidence of earlier consent.
Update a protection
gatewayName also derives and replaces that gateway’s slug. Read the returned
gateway.slug and rebuild any stored connection URLs. A slug collision returns
oauth_gateway_name_conflict.
OTel updates are partial. Omit otel.headers to preserve the encrypted headers already stored by
. Send "headers": null or an empty object to clear them. Send a non-empty object to
replace them.
Enabling OTel requires the organization’s effective otelExport entitlement; disabling an existing
configuration does not. Run preflight with otel=true before offering enablement.
exportBodies=true additionally requires both loggingEnabled=true and logBodies=true. Turning off
either gateway setting automatically turns off OTel body export. OTel is optional: the OAuth log and
spend endpoints below work without it. OTel delivers the same canonical events in real time with an
OTLP envelope when the customer plan permits export.
Read protection logs
protections:read-logs. Supported filters are since, provider, model, status,
limit, offset, and opaque cursor. Do not combine a cursor with a non-zero offset.
limit defaults to 50 and must be between 1 and 200. offset defaults to 0 and cannot be
negative. When cursor is present, reuse the exact filters from the preceding page.
cost is null unless the access token also has
protections:read-spend. OAuth never exposes stored request or response bodies.
Read protection spend
protections:read-spend. since is optional and must be an ISO 8601 timestamp.
Rotate the provider key
Rotate the runtime token
gatewayToken.plaintext once.
Revoke one protection
state to revoked,
and stamps accessRevokedAt.
It does not delete the gateway, credential, logs, settings, or audit history. Sibling protections remain
active.
Reactivate one protection
state: "active".
If a newer runtime-token operation already superseded that result, retrying the older idempotency key
returns 409 with idempotency_operation_superseded. Keep the newest successful runtime token and do
not retry the older operation with a new key.
Successful response families
The complete protection object is the shape shown in Create one protection. Operations are grouped below because they deliberately reuse that same object:
Idempotent create, runtime rotation, and reactivation responses may also include
replayed: true.
Store a returned plaintext before acknowledging the operation to the external platform.
OAuth token lifecycle and full disconnect
POST /v1/oauth/tokenexchanges an authorization code or rotates a refresh token.POST /v1/oauth/revokerevokes the submitted access token or refresh-token family.- Connected apps → Disconnect revokes the entire OAuth connection, every access/refresh token,
every active protection runtime token, and the internal Service Account. Protections that were active
become
connection_suspended; protections already markedrevokedremain revoked. Resources and audit history remain. - Reauthorizing the same App/organization reuses the installation and preserved resources but revokes every prior access/refresh token before the new authorization code is issued.
Errors and retries
Resource API failures use the standard error envelope:
Stable codes include:
idempotency_key_invalid,idempotency_key_reused,idempotency_operation_in_progress, andidempotency_operation_superseded;oauth_external_resource_already_protected,oauth_gateway_installation_changed,oauth_gateway_installation_not_found, andoauth_gateway_name_conflict;oauth_gateway_protection_revokedandoauth_gateway_protection_connection_suspended;oauth_project_unavailable,oauth_service_account_inactive, andoauth_service_account_unrecoverable;provider_key_invalid,provider_endpoint_not_configured,provider_validation_unavailable,provider_model_not_available,provider_model_not_supported,model_required, andgateway_name_invalid; andotel_endpoint_required,otel_not_available,log_bodies_require_logging,otel_bodies_require_gateway_log_bodies, andotel_headers_invalid.
SDK mapping
- Preflight —
preflightProtection() - Create —
provisionProtection() - List / read —
listProtections()/getProtection() - Update —
updateProtection() - Request logs —
listProtectionLogs() - Spend —
getProtectionSpend() - Rotate provider key —
rotateProtectionProviderKey() - Rotate runtime token —
rotateProtectionRuntimeToken() - Revoke —
revokeProtection() - Reactivate —
reactivateProtection()
OAuthPartnerClient.