HYBRID-CHAINDEVELOPERS
DOCUMENTATIONv2
POST

Identity sessions and federation

Exchange federated authorization

/api/v2/auth/federation/{provider}/exchanges
AUTHENTICATIONNone · publicAUTHORITATIVE OWNERidentity-serviceCONTRACT AUTHORITYGenerated Rust OpenAPISTATUSSource ready · production listed

PURPOSE + BUSINESS CONTEXT

Verify and consume a provider authorization response once, then issue a Hybrid session or complete an explicit account link.

WHEN THIS CALL IS USEFUL

Call this when an identity, compliance, relying-party, or trust agent workflow needs to apply the documented federated authorization transition after re-reading the current authoritative state so it can make a purpose-limited identity or assurance decision with current policy and lifecycle state.

OUTCOME · Create or advance

What changes

Creates or advances only the federated authorization resource described by this contract after authorization, validation, policy, and idempotency gates pass.

WHY IT MATTERS

  • Gives people and agents a contract-backed way to advance federated authorization.
  • Separates subject identity, consent, evidence, provider output, review, issuer credentials, and relying-party acceptance instead of collapsing them into a universal trust score.

ISOLATION + AUTHORITY

Bearer subject, tenant, purpose, policy version, role, issuer, reviewer, provider, and relying-party boundaries remain distinct. The response or transition grants no payment, custody, settlement, publisher, matching, or trading authority and must not expose regulated evidence beyond the live schema.

BEFORE YOU CALL

  • No bearer credential is required; apply bounded filters and canonical public identifiers where the contract provides them.
  • Supply the required provider (path), transaction_id (body), state (body), code (body), redirect_uri (body), device_id (body), platform (body) exactly as defined by the live contract.
  • Resolve the applicable purpose, policy version, consent or role basis, and required assurance before relying on this result.

WHAT TO DO NEXT

  • Re-read federated authorization using the canonical identifier returned by this operation.
  • Reconcile an ambiguous response with the same idempotency key before attempting another mutation.
  • Use the returned lifecycle state and policy version to choose the next least-privilege trust action; do not infer a missing stage.

AGENT GUIDANCE

  • Use federated authorization only for the purpose and lifecycle stage described by this operation; do not treat it as authority for an adjacent action.
  • Supply the required provider (path), transaction_id (body), state (body), code (body), redirect_uri (body), device_id (body), platform (body) exactly as defined by the live contract.
  • Treat policy availability, consent, evidence capture, completed checks, review, decision, credential issuance, validity, and relying-party acceptance as separate facts.
  • After a timeout or conflict, read authoritative state before deciding whether an equivalent retry is safe.
MACHINE CONTRACT

The exact deployed parameters, schemas, responses, security requirements, and Hybrid-Chain agent metadata are authoritative at this operation's production OpenAPI JSON Pointer. The readable tables below add integration guidance; the deployed OpenAPI controls if guidance and the machine contract ever differ.

Open the authoritative production contract

EXTENDED INTEGRATION GUIDANCE

Readable request and response reference

Examples illustrate integration intent; the referenced OpenAPI operation and component schemas define the executable shape.

PARAMETERS

Headers, path, query, and body

NAMELOCATIONPRESENCETYPE / RULES / PURPOSE
providerpathRequired

google | apple | githubMust match the transaction provider.

transaction_idbodyRequired

32-character transaction UUIDAuthorization transaction returned by the begin endpoint.

statebodyRequired

hcfed_ opaque valueExact one-time state returned at authorization start.

codebodyRequired

provider authorization codeShort-lived code returned by the provider.

redirect_uribodyRequired

exact registered HTTPS URIMust equal the URI bound at transaction creation.

device_idbodyRequired

safe identifier · 16–128Stable application-scoped client identifier.

device_namebodyOptional

string · max 160Human-readable session label.

platformbodyRequired

ios | android | web | serverClient class.

REQUEST

JSON body example

{
  "transaction_id": "9b51ed4c9c8f4aec85d1bd5520e40557",
  "state": "hcfed_…",
  "code": "provider-code",
  "redirect_uri": "https://hybrid-chain.com/auth/callback",
  "device_id": "web-client-7f4c2109",
  "device_name": "Firefox on macOS",
  "platform": "web"
}

STABLE ERROR CODES

Branch on the code, then follow the recovery action

These codes are published by the authoritative gateway contract for this endpoint. Treat message as safe diagnostic text; integrations should branch on code and HTTP status.

STATUSCODEMEANING
400invalid_jsonThe JSON body is malformed or fails the published identity-security schema.
400invalid_security_requestThe session, scope, public key, proof, or purpose-bound security request is invalid.
401invalid_credentialsThe bearer, client assertion, or proof-of-possession credential is invalid.
403step_up_requiredFresh purpose-bound authenticator verification or stronger authority is required.
404signing_key_not_foundThe requested signing-key or workload-client resource was not found.
409security_conflictThe requested identity-security transition conflicts with current state.
503identity_security_unavailableThe authoritative Identity security service is temporarily unavailable.

RESPONSES

Status and payload examples

200Identity-native Hybrid session issued for a linked provider subject.Mutation completed · JSON RESPONSE+
{
  "data": {
    "session": {
      "access_token": "hcm_…",
      "refresh_token": "hcmr_…",
      "token_type": "Bearer",
      "expires_in": 900,
      "refresh_expires_in": 2592000,
      "client_id": "client-01",
      "session_id": "9b51ed4c9c8f4aec85d1bd5520e40557",
      "scopes": [
        "profile:read"
      ]
    },
    "binding": null,
    "return_to": "/account"
  }
}
INTEGRATION DECISION
CALLER ACTION
Accept the returned representation or receipt, then re-read federated authorization using the canonical identifier returned by this operation.
RETRY SAFETY
Do not repeat a successful mutation merely to confirm it. This mutation has no documented idempotent replay contract. Reconcile state before considering another attempt.
STATE RECONCILIATION
Persist returned identifiers, versions, commitments, and receipts. Re-read market status, owner-scoped order or position state, Core collateral reservation, and settlement receipt; never treat shadow NXG evidence as authority.
400The authorization response is malformed.Request must change · JSON RESPONSE+
{
  "code": "invalid_session_request",
  "message": "The authorization response is malformed."
}
INTEGRATION DECISIONinvalid_session_request
CALLER ACTION
Rebuild the request from the live OpenAPI operation and correct the rejected method, media type, header, parameter, or body field.
RETRY SAFETY
Do not retry the same invalid request. This mutation has no documented idempotent replay contract. Reconcile state before considering another attempt.
STATE RECONCILIATION
Compare the submitted values with the documented constraints before another call. Re-read market status, owner-scoped order or position state, Core collateral reservation, and settlement receipt; never treat shadow NXG evidence as authority.
ESCALATE WHEN
Escalate any ambiguous order or settlement outcome while preserving suspension and Python authority; never enable ingress, publishing, allowlists, markets, or traffic as recovery.
401The transaction is invalid, expired, or already consumed.Authentication required · JSON RESPONSE+
{
  "code": "invalid_session_credential",
  "message": "The transaction is invalid, expired, or already consumed."
}
INTEGRATION DECISIONinvalid_session_credential
CALLER ACTION
Discard the rejected credential, complete the documented authentication or reassertion flow, and rebuild any request signature with fresh timestamps and nonces.
RETRY SAFETY
Retry only with a newly valid credential and fresh replay-protection values. This mutation has no documented idempotent replay contract. Reconcile state before considering another attempt.
STATE RECONCILIATION
Assume the outcome is unknown only when the connection failed after transmission; otherwise authentication failed before domain work. Re-read market status, owner-scoped order or position state, Core collateral reservation, and settlement receipt; never treat shadow NXG evidence as authority.
ESCALATE WHEN
Escalate any ambiguous order or settlement outcome while preserving suspension and Python authority; never enable ingress, publishing, allowlists, markets, or traffic as recovery.
404The provider subject is not linked to a Hybrid account.Resource not visible · JSON RESPONSE+
{
  "code": "session_not_found",
  "message": "The provider subject is not linked to a Hybrid account."
}
INTEGRATION DECISIONsession_not_found
CALLER ACTION
Verify the canonical identifier and authenticated owner boundary. A 404 may intentionally conceal a resource outside the caller's authority.
RETRY SAFETY
Do not retry the unchanged identifier repeatedly. Refresh the relevant collection or lookup before choosing another identifier.
STATE RECONCILIATION
Re-read market status, owner-scoped order or position state, Core collateral reservation, and settlement receipt; never treat shadow NXG evidence as authority.
ESCALATE WHEN
Escalate any ambiguous order or settlement outcome while preserving suspension and Python authority; never enable ingress, publishing, allowlists, markets, or traffic as recovery.
503Provider verification or Identity is unavailable.Dependency unavailable or outcome uncertain · JSON RESPONSE+
{
  "code": "identity_unavailable",
  "message": "Provider verification or Identity is unavailable."
}
INTEGRATION DECISIONidentity_unavailable
CALLER ACTION
Preserve the exact request and treat the outcome as uncertain until authoritative state proves whether it committed.
RETRY SAFETY
Reconcile before retrying. This mutation has no documented idempotent replay contract. Reconcile state before considering another attempt. Use bounded backoff with jitter.
STATE RECONCILIATION
Re-read market status, owner-scoped order or position state, Core collateral reservation, and settlement receipt; never treat shadow NXG evidence as authority.
ESCALATE WHEN
Escalate any ambiguous order or settlement outcome while preserving suspension and Python authority; never enable ingress, publishing, allowlists, markets, or traffic as recovery.

OPERATIONAL NOTES

Security and lifecycle guarantees

  • Authorization codes and provider tokens exist only during verification and are never persisted.
  • Federated sessions carry no legacy upstream assertion; V2 functions still dependent on V1 forwarding fail closed.
  • Email addresses are attributes and never cause automatic account linking.

UPGRADING FROM V1

Legacy calls replaced by this operation

If you maintain an older integration, use this map to find the V2 replacement. Do not translate the old request field-for-field: rebuild it from the V2 parameters and schemas above because identity, authorization, replay protection, and response semantics may have changed.

GET/api/v1/auth/federateAUTH: Generate Web-Federation Token
DOCUMENTATION STATUS

This route is implemented in canonical gateway source and appears in the production OpenAPI snapshot observed 2026-09-11T06:35:11.572Z. Authentication, tenant, feature, venue, and market policy still apply.

Verify the exact production OpenAPI operation Return to the V2 directory