Skip to content

Create Plugin Auth Code Exchanges Request

POST /plugin-auth-code-exchangesView source specification ↗

Creates an immutable provider authorization request with a server-assigned ID. Idempotency-Key is required and exact responses are retained for 24 hours. A request whose provider outcome is uncertain is never redispatched because its lease expired; start a new authorization when recovery cannot prove an outcome.

Required scope

endpoint:write

Header parameters

Idempotency-KeystringRequired

Client-chosen key that makes a non-idempotent request retry-safe, following draft-ietf-httpapi-idempotency-key-header. A committed response is stored for 24 hours and replayed for the same principal, operation, key and payload. Missing key returns 400 IDEMPOTENCY_KEY_REQUIRED, a key longer than 255 characters returns 400 IDEMPOTENCY_KEY_INVALID, the same key with a different payload returns 422, and the same key while the first request is still in flight returns 409. Requests rolled back before external provider attempts do not consume the key. Group mutations retain terminal failed responses after provider attempts together with received provider truth; their operation contract defines these replayable outcomes.

minLength: 1

maxLength: 255

Request body

Required

Fields

pluginIdstringRequired

The ID of the plugin for which we are attempting to exchange the code for an access token for.

minLength: 1

authLinkIdstring

Optional existing auth link to renew. It must belong to the requester, reference this plugin, and permit auth-link-write; renewal preserves its endpoint and route identities.

principalIdstringRequired

The authenticated Port OS principal, addressed as ~self.

pattern: "^~self$"

authorizationVariantIdstring

Authorization variant being established. Optional when the plugin has one variant; a renewal keeps the link's stored variant and rejects a different one.

regionalizationIdstring

Regionalization being established. Optional only when the chosen variant allows exactly one; a renewal keeps the link's stored regionalization and rejects a different one. Changing region or variant requires connecting a new link.

pluginAuthenticationDataobjectRequired

The data to exchange the code with. This is opaque data that is bespoke to the plugin and the plugin's authentication flow.

Returns

200

Provider operation completed; the stored request resource is returned.

Fields

authLinkIdstringRequired

Canonical ID of the committed connection, including a newly created connection.

minLength: 1

maxLength: 2048

idstringRequired

Server-assigned immutable authorization request resource ID.

etagstringRequired

Strong stored version of this request resource.

statusstringRequired

This request completed its operation. A code link or MFA challenge still requires the user to finish provider authorization.

Allowed values

  • SUCCEEDED

Response headers

ETagstring

Opaque strong entity tag of the returned resource version. Send it back in `If-Match` on the next mutation of the same resource.

Errors

400 BAD_REQUEST

Invalid request or unsupported provider operation.

Check the request fields and any validation details, then correct the payload.

401 UNAUTHORIZED

Authentication required.

Obtain a valid access token, then retry.

403 FORBIDDEN

Current provider or credential permission denied.

Check the linked account and its permissions for the device or resource.

404 NOT_FOUND

The selected connection or credentials no longer exist.

Verify the target identifier and that its endpoint or plugin route still exists.

409 IDEMPOTENCY_KEY_IN_FLIGHT

An attempt is in flight or its provider outcome is uncertain.

Check the device’s current mode or state. Retry only after the conflict is resolved.

412 PRECONDITION_FAILED

The selected connection changed during authorization.

Inspect the returned code and family and follow the error handling guide.

415 UNSUPPORTED_MEDIA_TYPE

JSON content type is required.

Inspect the returned code and family and follow the error handling guide.

422 IDEMPOTENCY_KEY_REUSED

Idempotency-Key was reused with a different request.

Correct the rejected value using the constraints in the error details or request schema.

500 INTERNAL

Provider or storage outcome could not be confirmed.

Retry with backoff only when the operation is safe to repeat. Include the error code when reporting persistent failures.

503 SERVICE_UNAVAILABLE

Protected authorization storage is unavailable.

Wait for the provider or bridge to recover, then retry safely with backoff.