Back to documentation

O42 Terraform provider

Manage O42 configuration as code, review changes in a plan, and detect drift before applying them.

The reviewed API inventory maps 313 management operations to 41 resources, 148 data sources and 69 explicit actions, with 202 executable examples in this guide. It covers tenant and global administration, identity and access, security, billing, directory provisioning, imports and protected credential delivery. Another 91 operations implement interactive authentication or protocol exchanges and retain their purpose-specific clients.

Agents can read this same guide at /docs/terraform.md.

Install the provider

Install oauth42/oauth42 version 0.1.0 from the Terraform Registry. Use Terraform 1.14 or newer in the 1.x series.

The first verified compatible backend is O42 0.2.0 built from revision 56abf5440fecada981310bcaad5afd0f23209db4. A compatible later build must have its migrations applied. Check the backend revision as well as its version number.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = {
      source  = "oauth42/oauth42"
      version = "= 0.1.0"
    }
  }
}

Run terraform init to download the signed provider package for your operating system and architecture. Commit the generated .terraform.lock.hcl file to keep installations consistent.

terraform init

Run your first read-only O42 plan to verify your credentials and tenant.

Create credentials and verify the tenant

  1. Sign in to the intended tenant in the O42 portal as an authorized administrator.
  2. Open Service Accounts and create a dedicated automation account. For group management, grant tenant-wide access and the explicit admin scope. Keep credentials separate between tenants and environments.
  3. Save the one-time client secret in your secret manager. Supply O42_CLIENT_ID and O42_CLIENT_SECRET in the Terraform process environment; avoid literals in HCL or checked-in variable files.
  4. Set customer_id to the expected tenant UUID and endpoint to the HTTPS API origin for that environment.

The provider obtains an OAuth2 client-credentials token. It checks the expected tenant before resource requests, and checks the current active self-context and the authority required by each operation before every mutation. It does not accept generic API keys, impersonate a human administrator, or add scopes automatically.

read permits ordinary reads, write permits ordinary group creation and updates, and admin permits deletion and includes those operations. Plans that create or update also need read access for refresh. The live self-context check does not require admin. Application-scoped accounts are refused for tenant-wide changes.

TLS verification is mandatory. For a private deployment, set ca_cert = file("/path/to/trusted-ca.pem"). The endpoint cannot contain a path, query, embedded credentials, or fragment; redirects are refused. There is no insecure-TLS switch.

Service-account concepts

Human access with O42 Authenticator

Download the matching oauth42-terraform-login helper from the signed v0.1.0 GitHub release. Verify the companion checksum signature with public fingerprint 916A3B2514628F3F019DCC64DF2E09CCFFBDED49 and check the ZIP against that checksum file.

Human sign-in uses the helper with a compatible O42 backend. The client must be registered as a public OAuth client with the device-code grant and requested scopes, and listed in the deployment's trusted management client IDs. Registration does not grant a user any tenant or platform role. An administrator can create the registration with the public-client resource example. The deployment operator must separately trust its returned client ID before login. The helper does not embed a shared client secret.

Start login with the intended account UUID, selected tenant UUID, client ID, API origin and explicit permissions. The helper prints a verification page and a short code. Sign in to that page with the same account and tenant, complete a fresh independent second factor, and submit the code. In O42 Authenticator, open Settings, then Review connected app requests. Compare the code, app/client, account, tenant, API resource, scopes, expiry and proof-key binding before approving. A notification or browser click alone never authorizes the client.

oauth42-terraform-login login --profile work \
  --endpoint https://api.example.com --client-id REGISTERED_PUBLIC_CLIENT \
  --customer-id TENANT_UUID --subject-id ACCOUNT_UUID \
  --scopes "read offline_access"

Polling expires after 15 minutes; a claimed Authenticator review expires within 90 seconds. Consent lasts one hour. Access tokens last at most five minutes. Request offline_access explicitly to allow rotating refresh within that same consent lifetime. Refresh never advances the original authentication or second-factor time, renews consent, adds scopes, or bypasses a requirement for fresh human presence.

The helper stores its private proof key and refresh credentials in macOS Keychain, Linux Secret Service, or a Windows user-bound DPAPI-protected profile. It fails if protected storage is unavailable. The macOS helper requires its native Keychain build; a cross-compiled build without native storage cannot log in. Headless automation should use the documented service-account workflow. Nothing writes an unencrypted refresh credential or proof private key to a Terraform configuration, state, plan or credential file.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

credential_command is an absolute executable path followed by separate arguments. It runs directly, without a shell. The provider sends the exact intended account, tenant, client, scopes and request method/URI over stdin. The helper returns only a short-lived access token and a fresh DPoP proof for that request. Keep secrets out of command arguments. All requests retain TLS verification, reject redirects, and recheck current backend authority. The provider scopes must exactly match the login profile's management scopes, excluding offline_access; use a separately approved profile for a narrower scope. The self-context data source permits an ordinary account and reports its actual approved scopes and current tenant-wide authority; human login never promotes that account to administrator.

Existing resource requirements still apply, including current object/organization roles, protected-role restrictions, explicit platform selection and fresh-factor checks. A read-only human grant cannot write even when its account is an administrator. Selecting a tenant never grants access to another tenant. Revoking the approving Authenticator key, disabling the account/client/tenant, changing applicable policy, or revoking the grant invalidates subsequent use and refresh.

Concurrent Terraform operations serialize refresh per profile. If a refresh response is lost or the process stops during rotation, the helper refuses to replay that refresh token: log out and approve a new login. Canceling an unfinished login attempts to cancel its pending authorization. To revoke the issued grant and remove the local protected profile, run:

oauth42-terraform-login logout --profile work

Logout preserves the local profile when remote revocation fails so it can be retried. Browser session tokens, passwords, recovery codes and Authenticator delivery credentials are not accepted as Terraform credentials. Interactive consent remains a human ceremony, separate from Terraform plans and actions.

Your current administrator status

data.oauth42_administrator_status reads your current platform-administrator status using the approved human profile. Request read offline_access when logging in and configure exactly scopes = ["read"]. An ordinary account needs no administrator role. Backend capability administrator-status-v1 and current membership in the selected tenant are required.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_administrator_status" "current" {}

The data source returns id (selected tenant UUID/account UUID), user_id, customer_id, email and is_admin. It accepts no target-user override. Role revocation returns false on the next read; a namesake group owned by another customer grants no platform role. Revoked account, tenant membership or consent denies the request instead of producing a false successful snapshot. Machines cannot impersonate their creators.

This status does not authorize a later operation. Each operation independently checks current authority. Email and identity fields are marked sensitive, which redacts ordinary display but does not encrypt Terraform state or plan files. Protect those artifacts. This read creates no role, approval or remote resource.

Approve expiring service-account access

oauth42_platform_grant, oauth42_organization_read_grant and oauth42_organization_group_write_grant manage exact approvals using Authenticator-approved human credentials and backend capability human-delegation-atomic-v1. The target must be an active dedicated service account in the selected tenant, with tenant-wide scope, a paired active client and an explicit expiry. Its OAuth scopes must permit the chosen capability. No machine can approve its own privileges.

Approval creation requires current human authority and original primary authentication plus an independent factor completed within five minutes of commit. Refresh and device consent never renew old proof. Complete a new sign-in and approve a matching human profile before an apply that creates or replaces grants. Current consent, account, client, approving key/device and role checks remain live during transaction waits. Deferred audit failure or proof expiry rolls back approval.

Platform capability

Use human = true, the platform tenant UUID 10000000-0000-0000-0000-000000000001, approved login scopes read admin offline_access and provider scopes ["read", "admin"]. Current platform-tenant administration and the actual o42admin group are required. Human approval does not use the machine-only platform_only mode.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

variable "delegation_expires_at" {
  type        = string
  description = "Explicit RFC3339 expiry within 365 days and the service-account lifetime. Never derive this from timestamp()."
}
resource "oauth42_platform_grant" "selected" {
  service_account_id = "33333333-3333-4333-8333-333333333333"
  capability         = "features_read"
  expires_at         = var.delegation_expires_at
}
data "oauth42_platform_grants" "history" {
  depends_on = [oauth42_platform_grant.selected]
}

Supported platform capabilities are features_read, features_write, social_providers_read, social_providers_write, statistics_read, waitlist_read, audit_read, sessions_read, applications_read, companies_read, groups_read, service_accounts_read, service_accounts_rotate, service_accounts_delete, users_read and subscription_tiers_read. Each resource approves one exact capability. The target machine uses the separately documented platform mode for its approved operations; each approval is limited to its listed machine capability. Human-only actions retain separate consent and current human authority.

Exact organization reads

Use approved human read write offline_access login scopes and provider scopes ["read", "write"]. The caller must currently hold the exact organization's administrator role. Organization approval does not require tenant-wide administrator authority. SCIM deprovisioning overrides retained manual organization roles. The read grant accepts organization_read for organization/member metadata or organization_scim_read for SCIM settings/activity; approve each independently when both are needed.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

variable "delegation_expires_at" {
  type        = string
  description = "Explicit RFC3339 expiry within 365 days and the service-account lifetime. Never derive this from timestamp()."
}
resource "oauth42_organization_read_grant" "selected" {
  organization_id    = "44444444-4444-4444-8444-444444444444"
  service_account_id = "33333333-3333-4333-8333-333333333333"
  capability         = "organization_read"
  expires_at         = var.delegation_expires_at
}
data "oauth42_organization_read_grants" "history" {
  organization_id = "44444444-4444-4444-8444-444444444444"
  depends_on = [oauth42_organization_read_grant.selected]
}

Exact organization group changes

The same current organization authority and human read/write consent apply. Choose exactly organization_group_create, organization_group_update_delete or organization_group_membership. These approvals are independent; none permits protected-role or SCIM-managed group mutation. The combined example approves ordinary group creation.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

variable "delegation_expires_at" {
  type        = string
  description = "Explicit RFC3339 expiry within 365 days and the service-account lifetime. Never derive this from timestamp()."
}
resource "oauth42_organization_group_write_grant" "selected" {
  organization_id    = "44444444-4444-4444-8444-444444444444"
  service_account_id = "33333333-3333-4333-8333-333333333333"
  capability         = "organization_group_create"
  expires_at         = var.delegation_expires_at
}
data "oauth42_organization_group_write_grants" "history" {
  organization_id = "44444444-4444-4444-8444-444444444444"
  depends_on = [oauth42_organization_group_write_grant.selected]
}

Set TF_VAR_delegation_expires_at to a reviewed future RFC3339 timestamp with at most microsecond precision. It must be within 365 days and no later than the service account's expiry. Do not derive expiry from timestamp(). Target, organization, capability and expiry are immutable. A different instant requires replacement; equivalent UTC offsets do not renew access. Revoke before replacement and do not enable create_before_destroy.

Import reads an existing approval without changing authority. Resource fields include the public grant id, customer_id, service_account_id, capability, expires_at, principal_id, granted_by_principal_id, created_at and active status; organization resources also include organization_id. Active reports only grant expiry/revocation, not the target account's effective permissions. Grantor identity is historical attribution. Removing the grantor's role does not silently revoke an independently approved machine grant.

terraform import oauth42_platform_grant.selected GRANT_UUID
terraform import oauth42_organization_read_grant.selected ORGANIZATION_UUID/GRANT_UUID
terraform import oauth42_organization_group_write_grant.selected ORGANIZATION_UUID/GRANT_UUID

External revocation removes the resource during refresh. A later apply requests a new approval for the configured extent and requires fresh human proof. Expired grants remain inactive without automatic renewal. Explicitly change the expiry and review replacement if new access is intended. Destroy revokes only the selected grant and preserves the service account and immutable audit history. Revocation requires current authority but no new factor ceremony; an already revoked or absent grant is accepted only after authorized inventory confirms its state.

The plural data sources read complete typed history in pages of 100, including expired and revoked grants, with a 10,000-record bound. They return customer_id, total and sensitive grants_json; organization inventories require organization_id. Records include public target/principal UUIDs, capability, creation/expiry, and nullable revoked_at/revoked_by_principal_id. Missing, duplicate, malformed or changing page extents fail explicitly. Concurrent changes can still move records without changing totals. Organization history alone can use a separately approved read-only profile; platform history requires admin consent. Protect state and saved plans. No approval resource or history data source exposes credentials, restores deleted service accounts or erases historical grants.

Your own sessions and trust metadata

data.oauth42_personal_sessions, data.oauth42_personal_session and oauth42_personal_session_trust require approved human mode and backend capability personal-session-metadata-v1. Ordinary accounts can manage their own metadata without a tenant administrator role. Machine credentials cannot impersonate an account.

For reads, approve a profile with read offline_access and configure scopes = ["read"]. For the combined example below, separately approve read write offline_access and configure exactly ["read", "write"]. Registration must permit those scopes. The trust resource needs both read and write; an administrator's read-only consent still cannot mutate trust.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}
data "oauth42_personal_sessions" "active" {
  depends_on = [oauth42_personal_session_trust.selected]
}
data "oauth42_personal_session" "selected" {
  depends_on = [oauth42_personal_session_trust.selected]
  id = "33333333-3333-4333-8333-333333333333"
}
resource "oauth42_personal_session_trust" "selected" {
  id      = "33333333-3333-4333-8333-333333333333"
  trusted = true
}

Replace the selected session UUID with a public registry id from the active list or portal. Never supply a session cookie or opaque bearer handle. Both data sources expose a sensitive sessions list; the detail source returns one record, including expired or revoked records. Each record contains public id, user_id, customer_id, revoked, device (device_type, os_name, os_version, browser_name, browser_version and nullable device_name), location (nullable IP, city, region, country, country_code, ISP), activity (nullable creation/last-activity, expiry, is_current), security (is_trusted, nullable risk_score, warnings), and activity_log. Detail history contains at most fifty recent entries with type, nullable endpoint and nullable timestamp; list history is empty.

The list enumerates all active, unrevoked records in the selected tenant registry in pages of 100, with a 10,000-record safety limit. Changed totals, duplicate IDs, incomplete pages or changed authority fail the read. Concurrent activity can still move unique records between pages without changing totals. These are registry records, not proof that a device is online. SDK sessions whose client registry belongs to another tenant are outside this selected-tenant inventory. A CLI grant does not identify itself as an unrelated browser session.

The trust resource manages only trusted on an existing own active session. It does not create a session, grant authentication, bypass MFA, extend expiry or revoke credentials. Import reads existing trust without changing it. Refresh detects drift; destroy clears trust, and needs no write when the session has already ended or disappeared. The resource pins the original account and tenant, refuses foreign targets, and never revives expired or revoked sessions. Every trust change has a mandatory typed audit in the same transaction.

terraform import oauth42_personal_session_trust.selected PUBLIC_SESSION_UUID

Protect Terraform state and plans: sensitive display flags do not encrypt personal device/location metadata. Removing a data source discards only its snapshot. Exact-session and account-wide credential revocation are separate operations and are not performed by these objects.

Revoke one exact session

data.oauth42_personal_session_revocation_review and action.oauth42_personal_session_revoke target one existing session of the configured human account. Approve read write offline_access, configure scopes = ["read", "write"], and use a backend advertising exact-session-revocation-v1. Read-only profiles can review with read consent. The personal action rejects the calling session; select another public session UUID from the selected tenant inventory.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_personal_session_revocation_review" "selected" {
    customer_id = "22222222-2222-4222-8222-222222222222"
    user_id     = "11111111-1111-4111-8111-111111111111"
    session_id  = "33333333-3333-4333-8333-333333333333"
}

The review returns the exact customer_id, user_id, session_id, nullable client_id, credential_binding, session_revoked, nullable credentials_revoked, is_current, can_revoke_exactly and configuration_version. A complete binding comes from actual credential issuance, including refresh rotation and SDK tenant selection. Legacy records have credential_binding = "legacy_unbound" and unknown credential status; they cannot be safely revoked exactly. Their timestamps, shared user or client never substitute for credential lineage. Use the separately explicit account-wide action only when that broader effect is intended.

Review the target first, then manually copy its configuration_version into a separate action configuration. Set confirm_revoke_session = true only after reviewing the binding. Do not wire the action version directly to a refreshing data source. A changed or missing target, changed authority, or stale version fails before mutation. Routine activity does not change the version.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Review the exact target separately; manually pin its observed version.
# Explicit invocation only; do not attach routine resource lifecycle triggers.
# terraform apply -invoke=action.oauth42_personal_session_revoke.selected
action "oauth42_personal_session_revoke" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    user_id     = "11111111-1111-4111-8111-111111111111"
    session_id  = "33333333-3333-4333-8333-333333333333"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_revoke_session = true
  }
}
terraform apply -invoke=action.oauth42_personal_session_revoke.selected

Revocation invalidates every access credential and rotated refresh token in the bound grant, including credentials issued after SDK tenant selection. It also cancels unfinished login-code, browser SSO, authorization-code and connected-client approval continuations from that source. Already-issued independent client grants and other sessions remain usable. Session history and the mandatory typed audit are retained; this operation does not delete the user, remove factors or revoke application consent.

Tenant administrators use data.oauth42_user_session_revocation_review and action.oauth42_user_session_revoke with explicit admin consent and current tenant-wide admin authority. Supply the exact target user and selected tenant. Eligible machine administrators use their own typed authority; machines cannot call personal operations. The administrator action can revoke its own calling session, so invoke it separately from work that needs those credentials afterward.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_user_session_revocation_review" "selected" {
    customer_id = "22222222-2222-4222-8222-222222222222"
    user_id     = "11111111-1111-4111-8111-111111111111"
    session_id  = "33333333-3333-4333-8333-333333333333"
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Review the exact target separately; manually pin its observed version.
# Explicit invocation only; do not attach routine resource lifecycle triggers.
# terraform apply -invoke=action.oauth42_user_session_revoke.selected
action "oauth42_user_session_revoke" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    user_id     = "11111111-1111-4111-8111-111111111111"
    session_id  = "33333333-3333-4333-8333-333333333333"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_revoke_session = true
  }
}
terraform apply -invoke=action.oauth42_user_session_revoke.selected

These actions have no import, drift state, restoration or credential output. Invoke explicitly and never attach routine lifecycle triggers. A successful response confirms the exact reviewed grant in the same transaction as revocation and audit. There is no automatic replay or authenticated read after invocation. If execution is uncertain, inspect current state using a surviving or newly approved credential before deciding on another invocation. Removing a review data source only discards its snapshot.

Sign your account out everywhere

action.oauth42_personal_sessions_revoke_all is an explicit, irreversible account-wide action. It invalidates the selected human account's existing access credentials, refresh grants, pending authorization codes and persisted sessions across all tenants, including the credential making this Terraform request. Other accounts remain signed in, including accounts sharing the same browser registry. It does not remove accounts, factors or application consent, and a fresh independent login can establish new credentials.

Use an approved human profile with read write offline_access and provider scopes ["read", "write"]. The backend must advertise personal-session-global-revocation-v1. Set both account and selected tenant UUIDs explicitly; the action checks them against current authority. A tenant administrator role does not substitute for human consent. The selected tenant records the typed audit; the revocation itself spans the account's tenants.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Explicitly invoke once: terraform apply -invoke=action.oauth42_personal_sessions_revoke_all.account
# This signs the account out everywhere, including this Terraform credential.
# Obtain a new approved login before subsequent Terraform work.
action "oauth42_personal_sessions_revoke_all" "account" {
  config {
    user_id     = "11111111-1111-4111-8111-111111111111"
    customer_id = "22222222-2222-4222-8222-222222222222"
  }
}
terraform apply -invoke=action.oauth42_personal_sessions_revoke_all.account

Keep this action in a separate configuration and invoke it explicitly. Do not attach it to ordinary resource lifecycle triggers or combine it with changes that need the same credentials afterward. There is no import, drift state, restore, output credential or automatic retry of uncertain execution. A successful response confirms the account and reports removed persisted session rows, including expired rows; it is not an online-device count.

After invocation, obtain a new Authenticator-approved login before later provider work. If the response is lost or invalid, the action reports an uncertain result and does not retry; use a fresh login to inspect current state before deciding whether another explicit global revocation is needed. The local protected-store profile is not deleted by this action. Exact single-session revocation remains a separate capability.

Your factor and passkey metadata

data.oauth42_personal_mfa, data.oauth42_personal_email_mfa, data.oauth42_personal_phone_mfa and data.oauth42_personal_passkeys read the approved human account's current security metadata. Use read offline_access for login and exactly scopes = ["read"] in the provider. Current selected-tenant membership and backend capability personal-security-metadata-v1 are required; an ordinary account needs no administrator role. Machine credentials and target-account overrides are refused.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

# These are sensitive snapshots of the approved account, with no target override.
data "oauth42_personal_mfa" "account" {}
data "oauth42_personal_email_mfa" "account" {}
data "oauth42_personal_phone_mfa" "account" {}
data "oauth42_personal_passkeys" "account" {}

Each data source returns the account UUID as id and user_id, the selected customer_id, and sensitive metadata_json. Use jsondecode to inspect the complete typed response. The metadata describes the global account even when another authorized tenant is selected. Losing that selected-tenant membership denies the read. Account, grant, device and policy revocation remain live, including changes while a database read waits.

The MFA response covers TOTP, email OTP and phone MFA: enabled, method, totp_enabled, email_otp_enabled, masked email_otp_address, phone_mfa_enabled, masked phone_mfa_number, phone_mfa_method, nullable verified_at/last_used_at, backup_codes_remaining and nullable opaque backup_codes_version. Its enabled flag does not inventory native O42 Authenticator approval keys or passkeys. Email metadata contains enabled, masked email and nullable dates. Phone metadata contains enabled, masked phone_number, nullable method (sms or voice) and nullable dates. Unknown existing dates remain null; a recovery-code count never exposes code values.

Passkey metadata contains a complete credentials list with public database id, credential_name, created_at, nullable last_used_at, verified backed_up and nullable transports. Backup state comes from the verified stored WebAuthn credential, including older rows whose display column differs. No public-key encoding, private key, authenticator seed, OTP, recovery code or token is returned. The provider rejects unknown fields, invalid types, duplicate credential IDs and unmasked destinations. Responses over 1 MiB or passkey inventories over 10,000 records fail explicitly; they are never silently truncated.

These are read-only snapshots. They do not prove that a factor was recently used, enroll or rename a credential, reset or disable MFA, change authentication policy, or grant access. Removing a data source only discards its Terraform snapshot. Protect state and plans: sensitive display flags do not encrypt personal metadata. Interactive enrollment and security mutations retain their separate authorization requirements.

Regenerate your recovery codes securely

oauth42_personal_backup_codes_regenerate replaces the actual signed-in account's eight recovery codes and delivers them only to an explicit OS protected store. An ordinary account needs no administrator role. Use a selected-tenant human profile, read/write consent and backend capability personal-backup-codes-protected-delivery-v1. Current membership, consent and fresh original independent authentication proof remain required. Machine credentials, another account's ID and platform-only profiles are refused.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Read oauth42_personal_mfa independently and manually pin backup_codes_version.
# terraform apply -invoke=action.oauth42_personal_backup_codes_regenerate.selected
action "oauth42_personal_backup_codes_regenerate" "selected" {
  config {
    backup_codes_version = "66666666-6666-4666-8666-666666666666"
    operation_id         = "55555555-5555-4555-8555-555555555555"
    secret_store_profile = "account-recovery"
  }
}
# Previous unused codes stop working at commit. Recover an uncertain result with
# the SAME operation, original version and destination within 24 hours.
# Recovery never restores consumed codes. Review current MFA status afterward.
# oauth42-terraform-login delivery-inspect --profile account-recovery \
#   --operation-id 55555555-5555-4555-8555-555555555555
# oauth42-terraform-login delivery-consume --profile account-recovery \
#   --operation-id 55555555-5555-4555-8555-555555555555 -- /absolute/trusted-consumer

First read data.oauth42_personal_mfa independently, inspect its sensitive metadata_json, and manually pin the exact backup_codes_version. The nullable UUID identifies the current TOTP recovery set; null means there is no TOTP enrollment. Regeneration requires enabled TOTP. Consumption and encryption maintenance preserve this version. Do not connect the action to a live data-source expression that could refresh your original review during recovery.

Commit immediately invalidates all previous unused codes. The configured secret_store_profile must name an available native protected store before any mutation. After a lost response or local storage failure, retain the same operation ID, original version and destination. Explicitly invoke that same operation within 24 hours to retrieve its original encrypted delivery. Recovery never restores consumed codes or generates a second set. A later regeneration, disabled TOTP, revoked consent or lost current authority prevents recovery.

Use delivery-inspect for public binding metadata and delivery-consume to send the protected values through standard input to an explicitly selected trusted executable. That consumer must store or use codes securely without printing them. Codes, verifiers, recipient private keys and encrypted capsules never become Terraform outputs or state. Review current MFA status and remaining-code counts afterward.

Ordinary plan and apply do not invoke the action. Use its explicit -invoke command only after reviewing the immediate cutover. There is no import, inverse destroy or automatic mutation retry. Removing the action configuration never restores an old set. Interactive TOTP enrollment remains separate.

Manage an existing passkey name

oauth42_personal_passkey_name manages the display name of a passkey you already enrolled interactively. Select its public database UUID from data.oauth42_personal_passkeys; the WebAuthn credential byte identifier is a different value and is never returned. Approve read write offline_access, configure provider scopes ["read", "write"], and use a backend advertising personal-passkey-name-v1 and personal-security-metadata-v1.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

# Enroll interactively first, then select the public database UUID.
resource "oauth42_personal_passkey_name" "selected" {
  id              = "33333333-3333-4333-8333-333333333333"
  credential_name = "Work laptop passkey"
}
data "oauth42_personal_passkeys" "account" {
  depends_on = [oauth42_personal_passkey_name.selected]
}
# Destroy relinquishes label management and preserves this passkey and name.

The name accepts 1 to 255 Unicode characters. The provider pins the original account and selected tenant, accepts only the account's own passkey, and verifies the exact name and identity in the mutation response. Current membership, account and consent authority are required. The typed audit records the actor and public target UUID without copying the display name.

terraform import oauth42_personal_passkey_name.selected 33333333-3333-4333-8333-333333333333

Import reads the existing name without changing it. Later plans detect name changes made in the portal; applying restores the configured name. A deleted passkey leaves Terraform state on refresh; a later apply fails until you select an existing enrolled passkey. Terraform cannot recreate an enrolled credential.

Destroy stops managing the label and preserves the passkey and its current name. It does not delete, disable or revoke the credential, and it does not restore an earlier name. Enrollment and removal remain separate security operations. The name and account identifier are sensitive in Terraform display; protect stored state and plans. An uncertain mutation response is not automatically retried.

Remove your factor or passkey

oauth42_personal_factor_disable explicitly disables one enrolled factor: totp, email or phone. oauth42_personal_passkey_remove explicitly deletes one enrolled passkey by its public database UUID. These Terraform 1.14+ actions require your exact user_id and selected customer_id, approved human read/write consent, and backend capability personal-security-removal-fresh-v1. An ordinary account can remove its own factors; machine credentials and other accounts are refused.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

variable "factor" {
  type    = string
  default = "totp" # Choose totp, email or phone explicitly before invocation.
}
action "oauth42_personal_factor_disable" "selected" {
  config {
    user_id = "11111111-1111-4111-8111-111111111111"
    customer_id = "22222222-2222-4222-8222-222222222222"
    factor = var.factor
  }
}
terraform validate
terraform apply -invoke=action.oauth42_personal_factor_disable.selected
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

action "oauth42_personal_passkey_remove" "selected" {
  config {
    user_id = "11111111-1111-4111-8111-111111111111"
    customer_id = "22222222-2222-4222-8222-222222222222"
    credential_id = "33333333-3333-4333-8333-333333333333"
  }
}
terraform apply -invoke=action.oauth42_personal_passkey_remove.selected

Authenticate using a primary credential and an independent factor within five minutes of invocation, then approve the human login. Both original proof timestamps must still be fresh when the database transaction commits. Refreshing a token or approving device consent does not renew old factor proof. The provider never requests or stores your password, OTP, seed, recovery codes or passkey private key. If proof is stale, sign in again and explicitly invoke the action after reviewing its target.

Successful removal revokes existing credentials and persisted sessions for your account everywhere, including the credential executing Terraform. Other enrolled factors, other passkeys and other accounts are preserved. The removal, typed audit and durable revocation commit atomically; an audit or current-authority failure rolls the transaction back. Pending codes for the removed email or phone factor are also deleted.

Run one removal action by itself. Do not attach it to resource lifecycle triggers or combine it with operations that need the same login afterward. There is no Terraform resource state, import, restore, replacement enrollment or output credential. An absent target fails explicitly. The provider does not retry an uncertain result or perform a read with the revoked credential. Obtain a fresh login to inspect the account before deciding whether another explicit action is necessary.

Keep another usable sign-in and recovery method before removing a factor. The portal continues to offer password confirmation for these explicit removals and signs out after success. Interactive enrollment remains separate. Protect plans and configuration containing the account and public credential identifiers.

Billing account metadata

Use a human profile with read consent and your selected tenant’s current billing administrator authority. An existing tenant administrator role or tenant-qualified portal owner/admin group is required; ordinary billing readers, primary routing alone and machine creator identities do not grant this authority. The backend must advertise billing-metadata-v1. Each read confirms the selected tenant, retains its current billing-account link and rechecks authority after waits.

  • data.oauth42_billing_subscription: current subscription, tier, effective pricing and scheduled changes; subscription is null when absent. An incomplete status means the initial external payment has not succeeded; it does not report an active subscription.
  • data.oauth42_billing_usage: per-tenant usage and distinct account-wide monthly active users and workforce seats. A person present in two tenants counts once in the account total.
  • data.oauth42_billing_payment_methods: complete saved-card metadata, including brand, last four digits, expiry and default status. No card number or payment credential is returned.
  • data.oauth42_billing_invoices: complete invoice metadata from the account’s configured local ledger or Stripe channel.
  • data.oauth42_billing_invoice: one exact invoice_id, using its local UUID or Stripe in_ identifier, with current billing-account ownership checked.
  • data.oauth42_billing_invoice_configuration: the selected account’s invoice schedule, purchase-order and payment-term configuration; configuration is null when absent.

Each data source exposes confirmed customer_id, billing_account_id and sensitive metadata_json. Protect Terraform state, saved plans and exports: financial/contact details and hosted invoice or PDF URLs can be private or access-bearing. Nested responses are checked against the current API schemas and unknown fields are rejected.

Reads never create a Stripe customer or modify payment methods, subscriptions or invoices. An account without a Stripe customer has no saved Stripe records. A linked remote account with Stripe unavailable fails explicitly. Local invoice reads include local line items; Stripe invoice summaries link to the externally hosted details and PDF. Enabling local invoice billing selects its ledger; the data source does not merge both channels or claim an external Stripe line-item inventory.

Complete collections are bounded at 10,000 records. Stripe pages contain up to 100 records and reject duplicate identities, foreign customers, failed pages and malformed records. Remote pagination is not a snapshot across requests. Oversized responses, unavailable data and changing account membership fail instead of becoming partial lists or zero usage. Revoking the current tenant role or human consent denies the next read.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

# Current selected-tenant administrator membership is required for every read.
# Metadata is sensitive Terraform state; invoice URLs may grant access to a PDF.
data "oauth42_billing_subscription" "account" {}
data "oauth42_billing_usage" "account" {}
data "oauth42_billing_payment_methods" "account" {}
data "oauth42_billing_invoices" "account" {}
data "oauth42_billing_invoice_configuration" "account" {}
data "oauth42_billing_invoice" "selected" {
  invoice_id = "33333333-3333-4333-8333-333333333333"
}

Reconcile an uncertain billing customer creation

When the external service may have created a customer but O42 did not receive or link the result, inspect the original provision before taking another action. The tenant data source requires current selected-tenant billing administration; the platform data source requires a current platform administrator and an explicit target customer_id. Both require billing_account_id. The backend must advertise billing-customer-provision-reconciliation-v1.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_customer_provision" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  observed_stripe_customer_id = "cus_OBSERVED_CUSTOMER"
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_customer_provision" "selected" {
  customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  observed_stripe_customer_id = "cus_OBSERVED_CUSTOMER"
}

Omit optional observed_stripe_customer_id to read local history alone. Supplying it performs one exact external GET and requires the customer’s account and provision metadata to match the original dispatched request. Obtain this identifier from the external service’s operational records; the provider never searches for or creates a replacement customer. A prepared request with no original dispatch cannot adopt a candidate.

Computed id, customer_id and configuration_version bind the result to current authority and the target. Sensitive review_json contains the authority kind/customer, target customer, account, complete related-company IDs, account name/status/email and current external link. Nullable provision contains the original provision UUID, frozen customer name/email, state, first-dispatch time, accepted time and external customer ID. States are prepared, dispatching, uncertain and accepted. Nullable candidate exposes only its customer/account/provision IDs, current name/email and creation time. Private external metadata and credentials are excluded; billing contact details still require encrypted state and saved plans.

Review any difference between the frozen request and current candidate contact details. Copy the observed version into the action as a literal. Each action requires billing_account_id, the original provision_id, exact observed_stripe_customer_id, pinned configuration_version and confirm_customer_reconciliation = true. The platform action also requires the target customer_id. Current human authority and fresh original primary authentication plus an independent factor are rechecked through commit.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
action "oauth42_billing_customer_provision_reconcile" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    observed_stripe_customer_id = "cus_OBSERVED_CUSTOMER"
    provision_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_customer_reconciliation = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
action "oauth42_platform_customer_provision_reconcile" "selected" {
  config {
    customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    observed_stripe_customer_id = "cus_OBSERVED_CUSTOMER"
    provision_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_customer_reconciliation = true
  }
}

Invoke the selected action explicitly with terraform apply -invoke=action.oauth42_billing_customer_provision_reconcile.selected, or the corresponding platform action address. Ordinary apply and destroy never perform reconciliation. The action sends only an external GET, then atomically accepts the original receipt, links the active account and writes mandatory audit. It preserves the original dispatch time and any previously accepted receipt. It can reconcile an exact observed customer after the 23-hour resend window; it never renews that window, generates another key or sends another customer creation request.

Actions have no outputs or automatic retries. A stale review, changed candidate, foreign metadata, inactive account or existing local link fails closed. After failure, reread current history before making another explicit decision. After successful adoption, reread the original financial operation and separately confirm its recovery. Invoice creation and existing local draft updates can continue with this exact original accepted link; unrelated policy, account, company-cohort or invoice changes still conflict. Destroy preserves the linked customer and audit history.

Review and import Supabase identities

Use a current selected-tenant human administrator with backend capability supabase-import-management-v1. Existing portal administrator groups are supported without changing a legacy membership to an admin role. Read consent permits source inspection, connection checks, complete import reviews and original outcomes. Source changes, imports and mail decisions require write consent and fresh original primary authentication plus an independent factor. Account, membership, role, consent and approving-device revocation remain live.

Save an input-only source credential

Choose and retain a canonical source_id UUID before creation. The source resource manages configuration and a credential revision; it does not import users. Pass the service-role key or database password through an ephemeral sensitive variable into credential_wo. This input is absent from Terraform plan and state and cannot be recovered through a read or import. Protect the process environment and keep credentials out of HCL, command arguments and committed variable files.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
variable "supabase_credential" {
  type      = string
  sensitive = true
  ephemeral = true
}
resource "oauth42_supabase_import_source" "selected" {
  source_id           = "44444444-4444-4444-8444-444444444444"
  name                = "Reviewed Supabase migration"
  connection_method   = "api"
  project_url         = "https://project.supabase.co"
  credential_wo       = var.supabase_credential
  credential_revision = 1
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
variable "supabase_credential" {
  type      = string
  sensitive = true
  ephemeral = true
}
resource "oauth42_supabase_import_source" "selected" {
  source_id           = "44444444-4444-4444-8444-444444444444"
  name                = "Reviewed Supabase migration"
  connection_method   = "database"
  database_host       = "db.project.supabase.co"
  database_port       = 5432
  database_name       = "postgres"
  database_user       = "source_reader"
  credential_wo       = var.supabase_credential
  credential_revision = 1
}

The API source requires a public HTTPS origin. Database sources require separate host, port, database and user fields, a public destination, and verified native TLS. The database connection uses a read-only repeatable-read transaction and a fixed query of auth.users; grant only the necessary read access. DNS answers are validated and pinned, certificate and hostname verification stay enabled, and redirects are refused. Connection URLs containing credentials are not accepted.

Increase credential_revision and supply the new credential when replacing it or changing its destination, connection method or database identity. A name-only update preserves the credential. Import the original source after a lost creation response; do not invent another UUID and assume the original failed. Drift reads retain the stored configuration and revision, and stale updates fail instead of overwriting a newer configuration.

terraform import oauth42_supabase_import_source.selected SOURCE_UUID
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_supabase_import_source" "selected" {
  source_id = "44444444-4444-4444-8444-444444444444"
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_supabase_import_connect" "selected" {
  source_id      = "44444444-4444-4444-8444-444444444444"
  source_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}

Destroy erases the stored source credential and private reviews and prevents future imports from that source. Imported identities, memberships, original operation outcomes and audit history remain. Removed source UUIDs cannot be reused; choose a new UUID for a new source lineage. Pending mail has its own explicit handoff/cancellation lifecycle.

Review the entire selected cohort

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_supabase_import_preview" "selected" {
  source_id = "44444444-4444-4444-8444-444444444444"
  proposal_json = jsonencode({
    customer_id    = "22222222-2222-4222-8222-222222222222"
    source_id      = "44444444-4444-4444-8444-444444444444"
    source_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    filters = {
      providers = [], email_confirmed_only = false, email_domain = null
      created_after = null, created_before = null
    }
    field_mapping = { first_name = "given_name", last_name = "family_name" }
    options = {
      duplicate_handling = "skip", password_handling = "send_activation"
      assign_groups = [], send_welcome_email = true, dry_run = false
    }
  })
}

Connection and preview reads inspect the complete bounded source: at most 10,000 users and 16 MiB in total. API observations must agree across two complete reads; oversized, inconsistent or incomplete source responses fail rather than returning partial success. Reviews expire after 30 minutes. Execution uses the frozen selected cohort and rejects source-configuration, target-identity, ownership, membership or group changes.

Specify every filter and import option. Provider filters, verified-email selection, email domain and timezone-qualified creation bounds apply before review; active bans are excluded and expired bans are eligible. Field mappings select string values from source user metadata. Duplicate handling can skip, block, or update profiles explicitly owned by the selected tenant. Existing passwords, verification and unrelated memberships are preserved. Foreign identities cannot be adopted, and their O42 UUIDs are withheld. Source-identity mappings prevent a previously imported source user from being rebound to a different account.

Only ordinary tenant groups can be assigned. Protected roles, organization groups and SCIM-managed groups require their separate grant workflows. Password hash import requires a verified database source and a supported bcrypt hash with cost 10–16; the API cannot supply hashes. Generating a temporary credential creates an unknown random password that is never returned. Initial activation creates a separate pending invitation for each new account. Welcome mail is also a separate pending handoff. Existing accounts receive neither replacement passwords nor initial activation.

Confirm one original import

Read review_json, review all proposed users, and manually copy its review_version into expected_version. Choose and retain an operation_id before invoking. Do not automatically connect a changing review to an action confirmation. Ordinary apply does not invoke actions. The explicit invocation commits all reviewed identity changes, ordinary grants, mandatory audit and the durable outcome together. A blocked identity or audit failure leaves the cohort unapplied. A dry run records its original outcome without creating users or sending mail.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
action "oauth42_supabase_import_execute" "selected" {
  config {
    source_id             = "44444444-4444-4444-8444-444444444444"
    operation_id          = "77777777-7777-4777-8777-777777777777"
    expected_version      = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_import_action = true
  }
}
terraform apply -invoke=action.oauth42_supabase_import_execute.selected
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_supabase_import_operation" "selected" {
  source_id    = "44444444-4444-4444-8444-444444444444"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

After a lost response, inspect the same source and operation UUID. An operation with a recorded outcome cannot be executed again. A consumed review also cannot be reused for a second operation. Obtain another complete review only for a separately intended import. Private review snapshots are erased on successful execution, source changes or removal, and expired snapshots are erased by bounded background cleanup. Public outcomes remain available to current authorized administrators.

Hand off or cancel original mail

Inspect the outcome and manually pin its current configuration_version. Select one original source_user_id and kind (activation or welcome). Only the original initiating administrator can deliver; a current selected-tenant administrator can cancel. Each handoff rechecks current identity ownership and the original invitation. No action returns an activation capability or password.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_supabase_import_operation" "selected" {
  source_id    = "44444444-4444-4444-8444-444444444444"
  operation_id = "77777777-7777-4777-8777-777777777777"
}
action "oauth42_supabase_import_deliver" "selected" {
  config {
    source_id             = "44444444-4444-4444-8444-444444444444"
    operation_id          = "77777777-7777-4777-8777-777777777777"
    source_user_id        = "88888888-8888-4888-8888-888888888888"
    kind                  = "activation"
    expected_version      = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_import_action = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_supabase_import_operation" "selected" {
  source_id    = "44444444-4444-4444-8444-444444444444"
  operation_id = "77777777-7777-4777-8777-777777777777"
}
action "oauth42_supabase_import_cancel_mail" "selected" {
  config {
    source_id             = "44444444-4444-4444-8444-444444444444"
    operation_id          = "77777777-7777-4777-8777-777777777777"
    source_user_id        = "88888888-8888-4888-8888-888888888888"
    kind                  = "welcome"
    expected_version      = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_import_action = true
  }
}
terraform apply -invoke=action.oauth42_supabase_import_deliver.selected
terraform apply -invoke=action.oauth42_supabase_import_cancel_mail.selected

accepted means SMTP acceptance, not recipient delivery. If SMTP accepted but the local authorization or audit completion failed, the original outcome retains its accepted timestamp. A fresh authorized invocation finishes that same handoff without sending again. unknown without an accepted receipt cannot be replayed. Cancel its capability before independently issuing a new invitation through the user-invitation workflow. Cancellation during handoff cannot reactivate the invitation, even if an acceptance receipt arrives later.

Pending handoffs expire after 24 hours; expired encrypted mail material is erased by bounded cleanup and the outcome becomes unavailable. Source configuration and operation references are nonsecret, but complete reviews contain personal information. Sensitive marking redacts normal Terraform display; it does not encrypt state. Protect state, saved plans and review exports.

Review subscription changes and negotiated pricing

Subscription and pricing changes are explicit financial actions. Use a current selected-tenant human billing administrator for billing actions, or a current platform human administrator for platform assignment and negotiated pricing. Backend capability billing-subscription-management-v1 is required. Billing reads require read consent; billing writes require write consent. Platform profiles select the platform tenant and require explicit admin consent. Every mutation rechecks fresh original primary authentication, an independent factor, current grants, revocation and exact billing-account ownership.

Configuration reads take billing_account_id and complete change_json. Platform reads also take the target customer_id; billing reads bind the provider’s selected tenant. The proposal includes kind, nullable tier/cycle/card/managed-item IDs, nullable period-end cancellation, downgrade cancellation and impact acknowledgment, nullable payment-exemption choice, nullable pricing terms, proration behavior and a nonempty reason. Assignment must explicitly choose skip_payment. Null preserves the applicable current value; it never authorizes an unrelated external item.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
locals {
  subscription_change = {
    kind = "update"
    tier_id = null
    billing_cycle = null
    payment_method_id = null
    managed_item_id = null
    cancel_at_period_end = true
    cancel_scheduled_downgrade = false
    acknowledge_downgrade_impact = false
    skip_payment = null
    pricing_override = null
    proration_behavior = "none"
    reason = "Explicitly reviewed subscription decision"
  }
}

data "oauth42_billing_subscription_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  change_json = jsonencode(local.subscription_change)
}

output "reviewed_version" {
  value = data.oauth42_billing_subscription_configuration.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_billing_subscription_configuration.selected.review_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
locals {
  subscription_change = {
    kind = "assign"
    tier_id = "44444444-4444-4444-8444-444444444444"
    billing_cycle = "monthly"
    payment_method_id = null
    managed_item_id = null
    cancel_at_period_end = null
    cancel_scheduled_downgrade = false
    acknowledge_downgrade_impact = false
    skip_payment = false
    pricing_override = null
    proration_behavior = "none"
    reason = "Explicitly reviewed subscription decision"
  }
}

data "oauth42_platform_subscription_configuration" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  change_json = jsonencode(local.subscription_change)
}

output "reviewed_version" {
  value = data.oauth42_platform_subscription_configuration.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_platform_subscription_configuration.selected.review_json
  sensitive = true
}

Inspect sensitive review_json and manually copy configuration_version into the action. The review contains the complete billing cohort, current local subscription and history count, selected/current tier terms, every unremoved pricing contract, durable schedules, original customer provision, and owned external subscriptions with all item IDs, quantities, prices, status, periods, cancellation and default-card choices. It also states the exact effect, target price/quantity, effective integer cents, proration, potential payment attempt, timing and restoration policy. Reads reject incomplete, changing or oversized inventories: at most 10,000 cohort/history/pricing/schedule entries, 100 external subscriptions and 10,000 items per subscription.

Creation, tier/cycle changes, assignment without recurring card payment and period-end cancellation preserve unrelated subscription items. A platform exception from recurring payment covers its assigned tier and cycle. A billing administrator’s tier/cycle change or new subscription returns to normal payment; it cannot extend that exception to another paid plan. The managed item must be explicitly named, previously retained, or uniquely identifiable from the existing local price. Ambiguity fails for review. An external payment attempt can leave a subscription incomplete or past due; a completed management operation does not imply successful payment or active service. A subscription-specific card does not silently change the account-wide default.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
locals {
  subscription_change = {
    kind = "create"
    tier_id = "44444444-4444-4444-8444-444444444444"
    billing_cycle = "monthly"
    payment_method_id = null
    managed_item_id = null
    cancel_at_period_end = null
    cancel_scheduled_downgrade = false
    acknowledge_downgrade_impact = false
    skip_payment = null
    pricing_override = null
    proration_behavior = "none"
    reason = "Explicitly reviewed subscription decision"
  }
}

data "oauth42_billing_subscription_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  change_json = jsonencode(local.subscription_change)
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_billing_subscription_create.selected
action "oauth42_billing_subscription_create" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    change_json = jsonencode(local.subscription_change)
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
locals {
  subscription_change = {
    kind = "update"
    tier_id = null
    billing_cycle = null
    payment_method_id = null
    managed_item_id = null
    cancel_at_period_end = true
    cancel_scheduled_downgrade = false
    acknowledge_downgrade_impact = false
    skip_payment = null
    pricing_override = null
    proration_behavior = "none"
    reason = "Explicitly reviewed subscription decision"
  }
}

data "oauth42_billing_subscription_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  change_json = jsonencode(local.subscription_change)
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_billing_subscription_update.selected
action "oauth42_billing_subscription_update" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    change_json = jsonencode(local.subscription_change)
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
locals {
  subscription_change = {
    kind = "assign"
    tier_id = "44444444-4444-4444-8444-444444444444"
    billing_cycle = "monthly"
    payment_method_id = null
    managed_item_id = null
    cancel_at_period_end = null
    cancel_scheduled_downgrade = false
    acknowledge_downgrade_impact = false
    skip_payment = false
    pricing_override = null
    proration_behavior = "none"
    reason = "Explicitly reviewed subscription decision"
  }
}

data "oauth42_platform_subscription_configuration" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  change_json = jsonencode(local.subscription_change)
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_assign.selected
action "oauth42_platform_subscription_assign" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    change_json = jsonencode(local.subscription_change)
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
locals {
  subscription_change = {
    kind = "pricing_override"
    tier_id = null
    billing_cycle = null
    payment_method_id = null
    managed_item_id = null
    cancel_at_period_end = null
    cancel_scheduled_downgrade = false
    acknowledge_downgrade_impact = false
    skip_payment = null
    pricing_override = {
      override_type = "exact_price"
      value_decimal = "10.1234"
      currency = "usd"
      billing_cycle = "monthly"
      effective_at = "2026-11-15T12:00:00Z"
      expires_at = null
      reason = "Reviewed exact recurring price"
      proration_behavior = "none"
    }
    proration_behavior = "none"
    reason = "Explicitly reviewed subscription decision"
  }
}

data "oauth42_platform_subscription_configuration" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  change_json = jsonencode(local.subscription_change)
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_pricing_override.selected
action "oauth42_platform_subscription_pricing_override" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    change_json = jsonencode(local.subscription_change)
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
locals {
  subscription_change = {
    kind = "pricing_remove"
    tier_id = null
    billing_cycle = null
    payment_method_id = null
    managed_item_id = null
    cancel_at_period_end = null
    cancel_scheduled_downgrade = false
    acknowledge_downgrade_impact = false
    skip_payment = null
    pricing_override = null
    proration_behavior = "none"
    reason = "Explicitly reviewed subscription decision"
  }
}

data "oauth42_platform_subscription_configuration" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  change_json = jsonencode(local.subscription_change)
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_pricing_remove.selected
action "oauth42_platform_subscription_pricing_remove" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    change_json = jsonencode(local.subscription_change)
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}

Each action requires an immutable caller-chosen operation_id, manually pinned version, complete matching proposal and confirm_subscription_change = true. Explicitly invoke the address shown in its example. Negotiated terms use value_decimal, an exact nonnegative decimal string with up to four fractional digits and eight integer digits. USD cents are calculated without binary floating point. Dates must retain exact microsecond precision. Pricing kind is percentage discount, fixed-amount discount or exact recurring price; cycle must match the selected subscription. Proration is none, create_prorations or always_invoice. A future approval fixes activation terms; expiry explicitly restores the selected tier/cycle at its then-current standard price.

Preparation commits original intent and mandatory audit before external dispatch. Each external step retains its original request, idempotency key, first dispatch and independently durable accepted receipt. Local subscription/pricing updates, typed audit and operation completion commit together. Another unresolved account-level financial operation prevents replacement work. Never change the operation UUID to bypass an uncertain result, and never treat a missing response as proof that no payment effect occurred.

Inspect and recover the original operation

After invoking an action, replace its proposal example with the operation example using the same original UUID. A successful change can make its original proposal invalid: creating a subscription, for example, prevents another creation. Inspect the recorded outcome before planning further changes or destroying read-only Terraform state; do not refresh an obsolete proposal as if it were a new approval.

Operation data sources take the account and original operation ID; platform variants also take target customer ID. Computed state, version and sensitive review retain immutable intent, original execution origin, historical actor/authorizer, typed external receipts and current target version even when drift prevents completion. Reads never resend an external request. Refresh and destroy only read or remove Terraform state.

Find unresolved references in jsondecode(data.oauth42_billing_subscription.current.metadata_json).pending_operations or in the billing page’s unresolved operations list. This bounded local inventory remains readable when the payment service is unavailable or an uncertain effect prevents a new configuration review. It includes only this selected company and billing account, up to 1,000 unresolved subscription intents, and identifies whether billing or platform authority is required. It grants no recovery permission.

Automatic payment-failure enforcement records execution_kind = dunning_scheduler, the original dunning_subscription_id and exact dunning_past_due_since. Human actor and authorizer fields are null. The worker rechecks the latest subscription and original failure period, removes only its managed item, preserves unrelated items and historical retention deadlines, and refuses externally recovered service. An unknown result keeps its original operation and blocks competing financial changes. The timer does not silently repeat it: a current billing administrator must inspect, explicitly reconcile when necessary, and complete or cancel the original operation with fresh proof. Recovery preserves its system-policy origin.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_operation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

output "reviewed_version" {
  value = data.oauth42_billing_subscription_operation.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_billing_subscription_operation.selected.review_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_operation" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

output "reviewed_version" {
  value = data.oauth42_platform_subscription_operation.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_platform_subscription_operation.selected.review_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_reconciliation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
  step_key = "subscription-change"
  observed_object_id = "sub_original"
}

output "reviewed_version" {
  value = data.oauth42_billing_subscription_reconciliation.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_billing_subscription_reconciliation.selected.review_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_reconciliation" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
  step_key = "subscription-change"
  observed_object_id = "sub_original"
}

output "reviewed_version" {
  value = data.oauth42_platform_subscription_reconciliation.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_platform_subscription_reconciliation.selected.review_json
  sensitive = true
}

Reconciliation reads require the original step_key and exact observed_object_id obtained from the external billing service. Supported steps are subscription-change, subscription-price and remove-managed-item. A removal candidate names its original parent subscription. The backend performs exact reads and validates ownership, original operation metadata, commercial terms and all affected and preserved items. It never searches for a replacement or dispatches a financial write. An uncertain original customer creation uses the separate customer-provision reconciliation described above.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_operation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_billing_subscription_resume.selected
action "oauth42_billing_subscription_resume" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_operation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_billing_subscription_cancel.selected
action "oauth42_billing_subscription_cancel" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_reconciliation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
  step_key = "subscription-change"
  observed_object_id = "sub_original"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_billing_subscription_reconcile.selected
action "oauth42_billing_subscription_reconcile" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    step_key = "subscription-change"
    observed_object_id = "sub_original"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_operation" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_resume.selected
action "oauth42_platform_subscription_resume" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_operation" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_cancel.selected
action "oauth42_platform_subscription_cancel" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_reconciliation" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
  step_key = "subscription-change"
  observed_object_id = "sub_original"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_reconcile.selected
action "oauth42_platform_subscription_reconcile" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    step_key = "subscription-change"
    observed_object_id = "sub_original"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}

Resume retains original intent and keys, and can complete an accepted result without resending it. Cancel is limited to an undispatched original operation. An uncertain or dispatching result requires exact candidate review and explicit adoption before separate completion. Adoption writes its receipt and audit atomically without a new external mutation or renewed resend window. A stale version, changed cohort, foreign owner, changed item, revoked grant or audit failure rejects the decision. Actions have no outputs or automatic retries; ordinary apply, refresh and destroy never charge, cancel, reconcile or undo billing.

Future phases and blocked schedules

Clear an existing period-end cancellation in a separate reviewed immediate change before approving a downgrade. A downgrade approval cannot silently undo a cancellation already scheduled with the billing processor. Scheduled downgrades, future negotiated prices, pricing expiry and local period-end cancellation retain immutable approval, the original human principal, and fixed activation/expiry operation IDs. The worker checks that principal’s current role and the exact approved extent at execution. Revocation, commercial drift or an uncertain dispatch blocks the schedule; restoring access alone does not restart a blocked phase. An activation snapshot binds subsequent expiry to the accepted local subscription, card and complete external items.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_schedule" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  schedule_id = "88888888-8888-4888-8888-888888888888"
}

output "reviewed_version" {
  value = data.oauth42_billing_subscription_schedule.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_billing_subscription_schedule.selected.review_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_schedule" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  schedule_id = "88888888-8888-4888-8888-888888888888"
}

output "reviewed_version" {
  value = data.oauth42_platform_subscription_schedule.selected.configuration_version
}
output "complete_review" {
  value = data.oauth42_platform_subscription_schedule.selected.review_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_schedule" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  schedule_id = "88888888-8888-4888-8888-888888888888"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_billing_subscription_schedule_resume.selected
action "oauth42_billing_subscription_schedule_resume" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    schedule_id = "88888888-8888-4888-8888-888888888888"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_subscription_schedule" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  schedule_id = "88888888-8888-4888-8888-888888888888"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_billing_subscription_schedule_cancel.selected
action "oauth42_billing_subscription_schedule_cancel" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    schedule_id = "88888888-8888-4888-8888-888888888888"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_schedule" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  schedule_id = "88888888-8888-4888-8888-888888888888"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_schedule_resume.selected
action "oauth42_platform_subscription_schedule_resume" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    schedule_id = "88888888-8888-4888-8888-888888888888"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_subscription_schedule" "selected" {
  customer_id = "22222222-2222-4222-8222-222222222222"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  schedule_id = "88888888-8888-4888-8888-888888888888"
}

# Review the complete target and effect, then manually copy its version below.
# Preserve this original operation or schedule reference after every uncertain result.
# Explicit invocation: terraform apply -invoke=action.oauth42_platform_subscription_schedule_cancel.selected
action "oauth42_platform_subscription_schedule_cancel" "selected" {
  config {
    customer_id = "22222222-2222-4222-8222-222222222222"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    schedule_id = "88888888-8888-4888-8888-888888888888"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_subscription_change = true
  }
}

Schedule reads take the original schedule_id, account and, for platform scope, target customer. The review exposes original approval, state, authorizer, fixed phase IDs, any durable phase outcome and a complete current phase plan when available. A current authorized human can explicitly confirm a due blocked phase with fresh proof. Historical authorizer attribution remains separate from that executor. If a phase has already dispatched, inspect and reconcile its original operation; cancellation cannot undo it. Only an unactivated, undispatched schedule can be cancelled. Remove or replace active pricing explicitly instead of discarding its approved expiry.

An elapsed pricing date does not itself prove restoration: the applied price remains visible in the complete review until restoration commits. Legacy scheduled-downgrade fields or pricing records without a durable schedule do not invent a historical approval. Cancel and reapprove a legacy downgrade, or explicitly remove/replace legacy pricing under current authority. Historical subscription rows remain readable but cannot enforce a lower retention tier after replacement; retention cleanup rechecks the latest account subscription.

The portal and admin billing forms use the same reviewed contracts through their authenticated same-origin server routes. They show current price, payment effect and timing before confirmation and retain operation references for explicit recovery. Card entry and any required payment ceremony remain authorized browser interactions. No card number, client secret or credential belongs in Terraform state; complete billing contact and commercial metadata still require encrypted state and plans.

Create and recover a card collection

An incomplete initial payment or overdue billing account can collect a replacement card under the same current authority and fresh-proof requirements. Collection does not reactivate billing, change the default card or charge a subscription.

Card collection prepares a customer-bound card-entry ceremony. Use a selected-tenant human billing administrator with actual current membership, scopes ["read", "write"], approved device consent and backend capability billing-card-collection-v1. Mutations require fresh original primary authentication and an independent factor. Creation does not enter a card, change a default or charge an invoice. Card numbers, security codes and collection client secrets never belong in Terraform.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_card_collection_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
}

The configuration data source requires billing_account_id. Computed id, customer_id and configuration_version bind the selected tenant and account. Sensitive review_json contains those IDs, every related company ID, account name/status/email, nullable external customer ID, service availability, fixed usage = off_session, card-only payment method types, local/full versions and nullable original customer_provision. Provision history includes its immutable UUID, frozen name/email, state, first-dispatch/accepted times and external customer ID. Billing contact metadata requires protected state and plans. Reads have no external mutation.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_card_collection_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
}

# Review the exact account or original operation/candidate, then copy its version.
# Keep the same operation_id after failure. Card entry remains in the browser.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_card_collection_create.selected
action "oauth42_billing_card_collection_create" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_card_collection = true
  }
}

Every collection action requires the billing account, immutable caller-chosen operation_id, manually copied configuration_version and confirm_card_collection = true. Explicitly invoke creation with terraform apply -invoke=action.oauth42_billing_card_collection_create.selected. The version comes from the configuration review. The backend commits the frozen request and audit before external dispatch, retains current authority during each step and records nonsecret customer/SetupIntent receipts independently of local completion. An unlinked account uses its original durable customer provision. A failed response never authorizes a replacement operation UUID or customer.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_card_collection" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

The operation data source requires billing_account_id and the original operation_id. Optional observed_setup_intent_id requests one exact external GET; omit it to read local history even when the external service is unavailable. Computed state, customer_id, id, configuration_version and sensitive review_json expose an outer review containing operation, nullable candidate and a version covering both. The operation includes target/kind, frozen request/review/customer-provision identity, request hash, original target version, state, outcome code, timestamps and every external step's original dispatch time and typed receipt. Creation states are prepared, dispatching, uncertain, external_applied, completed, rejected and cancelled. Completed means creation was recorded; it does not mean card entry finished.

An explicitly supplied candidate must match the originally dispatched operation, billing account, target company, customer, off-session usage and card-only types. Its public projection contains these IDs, SetupIntent ID, current status and creation time. Arbitrary metadata and private proof are excluded. Candidate status may be requires_payment_method, requires_confirmation, requires_action, processing, succeeded or canceled.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_card_collection" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the exact account or original operation/candidate, then copy its version.
# Keep the same operation_id after failure. Card entry remains in the browser.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_card_collection_resume.selected
action "oauth42_billing_card_collection_resume" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_card_collection = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_card_collection" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the exact account or original operation/candidate, then copy its version.
# Keep the same operation_id after failure. Card entry remains in the browser.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_card_collection_cancel.selected
action "oauth42_billing_card_collection_cancel" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_card_collection = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_card_collection" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
  observed_setup_intent_id = "seti_OBSERVED_COLLECTION"
}

# Review the exact account or original operation/candidate, then copy its version.
# Keep the same operation_id after failure. Card entry remains in the browser.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_card_collection_reconcile.selected
action "oauth42_billing_card_collection_reconcile" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_card_collection = true
    observed_setup_intent_id = "seti_OBSERVED_COLLECTION"
  }
}

Recovery actions use the newly reviewed outer operation version. Resume reuses accepted receipts and the original request/key; an unknown dispatch can only be resent within 23 hours of its first dispatch. The window is never renewed. Cancel is available only when there is no non-rejected dispatch and never reverses an external effect. Reconcile additionally requires the exact observed_setup_intent_id included in the candidate review. It sends only a GET and atomically records the original receipt with mandatory audit, including after the resend window expires. Then reread the operation and separately confirm resume to finish local completion. A pending customer creation can first use the customer-provision reconciliation described above. Account identity, contact or company-cohort changes still conflict; only the exact original accepted customer link is normalized during recovery.

Invoke each recovery explicitly using its action address, for example terraform apply -invoke=action.oauth42_billing_card_collection_resume.selected. Actions have no outputs or automatic retries. Refresh, ordinary apply and destroy never create a collection, resume an operation or delete its external outcome. An unresolved account effect excludes another payment, collection, subscription or pricing intent. After any error inspect the original reference before another confirmed decision.

To enter a card, open Billing → Add card in the portal, review the same account, paste the original collection reference and inspect it. After creation completes, choose Continue to card entry. Only the current initiating human with current billing membership/role and fresh independent-factor proof can obtain the browser-only, no-store collection secret. Card entry uses the payment SDK and attaches the card to that exact external customer; default selection and invoice charging remain separate reviewed actions. Closing clears the browser secret. Every O42 request rechecks revocation; a payment-service capability already issued to the browser follows that service's ceremony lifetime. The portal build needs its public NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY setting or Docker build argument to enable card entry; never supply a secret key.

Reviewed payment methods and explicit recovery

Use a human profile for the selected tenant, current actual membership and billing-administrator role, provider scopes ["read", "write"], approved read write offline_access consent, and backend capability billing-payment-management-v1. Mutations additionally require current primary authentication and an independent factor within five minutes. A machine credential, creator identity, old primary-tenant routing or unrelated platform role is insufficient. Every request and recovery rechecks live authority.

oauth42_billing_payment_method_configuration requires billing_account_id and payment_method_id. Optional setup_intent_id identifies a completed card-collection ceremony bound to the same account and card; it is required for an unattached card. Optional retry_invoice_id includes one exact managed-subscription invoice in the review. Reading never attaches a card, changes a default or charges an invoice.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_method_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  payment_method_id = "pm_REVIEWED_CARD"
}

The computed customer_id binds the selected tenant; id combines tenant, billing account and card. Computed configuration_version covers the local account and current external observations. Sensitive review_json includes the exact customer/account IDs, complete related-company IDs, account status, external customer ID, card ID and attached customer, optional collection intent, local and external default IDs, brand/last four/expiry, complete locally managed subscription IDs/status/dunning/defaults, optional exact invoice/currency/total/remaining/paid/status, and local/full configuration versions. Reviews reject inventories beyond 10,000 companies or 1,000 subscriptions instead of returning partial results. Card numbers and collection client secrets never appear.

The explicit actions below all require billing_account_id, caller-chosen immutable operation_id, payment_method_id, a manually pinned observed configuration_version, and confirm_financial_change = true. Attach also requires an explicit set_as_default Boolean and accepts setup_intent_id. A completed setup must name the exact card and carry this billing account’s server-owned metadata; any customer already associated with it must match. If setup already attached the card to this customer, the action records the reviewed state without another attach request. Default changes the customer default; existing subscription-specific choices remain visible and unchanged. Detach clears this card’s reviewed customer and managed-subscription defaults before removing it; future collection may require another card.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_method_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  payment_method_id = "pm_REVIEWED_CARD"
  setup_intent_id = "seti_COMPLETED_COLLECTION"
}

# Review the complete current target and any durable outcomes, then copy its version.
# Keep operation_id after failure. Ordinary apply, refresh and destroy do not invoke actions.
# Invoice payment is omitted; no implicit invoice charge is requested.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_payment_method_attach.selected
action "oauth42_billing_payment_method_attach" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    payment_method_id = "pm_REVIEWED_CARD"
    setup_intent_id = "seti_COMPLETED_COLLECTION"
    set_as_default = false
    confirm_financial_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_method_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  payment_method_id = "pm_REVIEWED_CARD"
}

# Review the complete current target and any durable outcomes, then copy its version.
# Keep operation_id after failure. Ordinary apply, refresh and destroy do not invoke actions.
# Invoice payment is omitted; no implicit invoice charge is requested.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_payment_method_default.selected
action "oauth42_billing_payment_method_default" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    payment_method_id = "pm_REVIEWED_CARD"
    confirm_financial_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_method_configuration" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  payment_method_id = "pm_REVIEWED_CARD"
}

# Review the complete current target and any durable outcomes, then copy its version.
# Keep operation_id after failure. Ordinary apply, refresh and destroy do not invoke actions.
# Invoice payment is omitted; no implicit invoice charge is requested.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_payment_method_detach.selected
action "oauth42_billing_payment_method_detach" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    payment_method_id = "pm_REVIEWED_CARD"
    confirm_financial_change = true
  }
}

Attach and default may also take retry_invoice_id, but only when the same invoice was included in the review. This explicitly charges that card for the reviewed outstanding invoice; the backend verifies current account/subscription ownership and exact amount. Omission never retries the latest invoice. A downgraded subscription is not implicitly reactivated. Customer defaults can affect future automatic collection even when no invoice retry was requested. Detach has no invoice-retry or collection-intent inputs.

Card entry and bank authentication remain an interactive card-collection ceremony. Never put a card number, security code or SetupIntent client secret into Terraform. A completed SetupIntent identifier is a non-secret reference to the ceremony, not a substitute for its customer/card binding. Use the reviewed card-collection actions above for creation and explicit recovery; card entry remains in the portal.

Inspect uncertain outcomes before recovery

oauth42_billing_payment_operation requires the billing account and immutable operation UUID. Its computed customer_id, configuration_version, state and sensitive review_json expose the exact stored request and review, target/kind, request hash, original target version, timestamps, outcome code, and every external step with first-dispatch time, accepted time and typed secret-free receipt. It is read-only and never resumes an operation. Possible states are prepared, dispatching, external_applied, uncertain, completed, rejected and cancelled.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_operation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

Preparation commits immutable intent and typed audit before any external mutation. Every external step records its original request/key and accepted result separately. Final local state, completion and typed audit commit together. An audit failure can therefore leave an external effect recorded while the local default remains unchanged. An unresolved account-level payment/subscription/pricing intent prevents another such intent for a different card from overwriting it. Repeating the original action never silently resumes the operation.

Resume and cancel require the exact billing account/operation UUID, the newly observed operation version, and confirm_reviewed_operation = true. Resume reuses accepted receipts and freshly inspects exact external objects. A separately confirmed recovery may reconcile a previously attempted effect from its precise observed result; this records observed state, not exclusive causation. If another actor made an unrelated external change, recovery conflicts rather than overwriting it. Otherwise an unknown POST can only reuse its original key within 23 hours of the first dispatch. The deadline is never renewed and a replacement key is never minted. After that bound, an unreconciled effect remains a conflict requiring external investigation.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_operation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the complete current target and any durable outcomes, then copy its version.
# Keep operation_id after failure. Ordinary apply, refresh and destroy do not invoke actions.
# Invoice payment is omitted; no implicit invoice charge is requested.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_payment_operation_resume.selected
action "oauth42_billing_payment_operation_resume" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_reviewed_operation = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_operation" "selected" {
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id = "77777777-7777-4777-8777-777777777777"
}

# Review the complete current target and any durable outcomes, then copy its version.
# Keep operation_id after failure. Ordinary apply, refresh and destroy do not invoke actions.
# Invoice payment is omitted; no implicit invoice charge is requested.
# Invoke explicitly: terraform apply -invoke=action.oauth42_billing_payment_operation_cancel.selected
action "oauth42_billing_payment_operation_cancel" "selected" {
  config {
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    operation_id = "77777777-7777-4777-8777-777777777777"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_reviewed_operation = true
  }
}

Cancel only abandons an undispatched intent. It does not undo a charge, default change or detach. Actions have no outputs and do not run during ordinary apply, refresh or destroy. Destroying either data source only removes Terraform state. Protect state and saved plans containing card display metadata, billing relationships and financial outcomes. Keep the operation reference after errors; never replace an uncertain operation merely to bypass its account exclusion.

Check payment requirements without starting card collection

oauth42_billing_payment_requirement reads an exact active tier_id and explicit billing_cycle (monthly or annual) for the selected tenant. Use a human profile with current tenant administration and approved read write offline_access consent, provider scopes ["read", "write"], and backend capability billing-payment-requirement-v1. The existing POST route retains its write/admin consent requirement; this data source has no financial side effects.

The computed customer_id and billing_account_id bind the result to the current selected account. Sensitive metadata_json contains tier_id, billing_cycle, requires_payment, has_payment_method and payment_collection_available. Payment is required when the active target tier has a configured price for the selected cycle and its payment-required flag is enabled. The saved-method flag describes the recorded default method; it does not assert external card usability. A free tier does not invent a saved card. Collection availability reports server configuration only.

No Stripe customer, SetupIntent, subscription, charge or secret is created. Card collection remains a separate explicit user interaction. The portal stops when eligibility cannot be reviewed or required collection is unavailable. A successful review is advisory; later billing changes independently recheck current policy, authority and external ownership. Revoked tenant grants or consent, a different selected tenant, an inactive target tier and malformed responses fail explicitly.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_payment_requirement" "selected" {
  billing_cycle = "monthly"
  tier_id = "33333333-3333-4333-8333-333333333333"
}

# Read-only eligibility: no customer, card collection, payment, subscription or secret is created.

Apply and refresh read current eligibility; changing the tier or cycle refreshes the result. There is no import or managed financial resource. Destroy removes only Terraform state. Protect saved plans and state containing financial metadata. The response limit is 1 MiB, and errors never become a partial successful result.

Billing previews

oauth42_billing_downgrade_preview estimates the feature and capacity effects of an exact active target tier for your selected tenant. It requires current human tenant administration and explicit write or admin consent because the existing preview API uses POST. Read-only consent and machine identities cannot use it. An existing retired current tier remains readable; a retired target cannot be newly selected.

The sensitive metadata_json contains the complete target tier, normalized target features, downgrade decision, effective date, each impact with current/target limits and usage, and whether acknowledgement would be required. The data source also confirms customer_id and billing_account_id. Malformed stored features or backend errors fail explicitly.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_billing_downgrade_preview" "selected" {
  tier_id = "33333333-3333-4333-8333-333333333333"
}

# Advisory data only: applying does not schedule a downgrade or charge a card.

oauth42_platform_pricing_override_preview estimates a proposed recurring price for an exact company under current global human administration. Use a platform-tenant profile with explicit admin consent. pricing_override_json accepts every public input field: percentage, fixed-amount or exact-price override type; numeric value; USD currency; monthly/annual billing cycle matching the subscription; effective date; optional nullable expiry after that date; a nonempty reason of at most 1,000 characters; and none, create_prorations or always_invoice proration behavior.

Percentage discounts must be greater than zero and at most 100; fixed discounts must be positive and cannot exceed the standard price; exact prices must be nonnegative. The complete estimate includes standard, current effective and proposed effective prices, recurring difference, estimated proration, currency, cycle and proration description. Company, platform and billing-account identities are confirmed separately. Monetary estimates follow the API’s cent rounding. Proposed terms and returned financial metadata are sensitive values in Terraform state; protect both configuration and state.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_pricing_override_preview" "selected" {
  company_id = "33333333-3333-4333-8333-333333333333"
  pricing_override_json = jsonencode({
    override_type      = "exact_price"
    value              = 12.34
    currency           = "usd"
    billing_cycle      = "monthly"
    effective_at       = "2026-01-01T00:00:00Z"
    expires_at         = null
    reason             = "Estimate a proposed recurring price"
    proration_behavior = "none"
  })
}

# This estimate does not create an override, invoice, payment or Stripe object.

Both data sources require billing-previews-v1. Refresh recalculates an advisory estimate from current billing data; time, usage, tiers or existing overrides can change the result. A preview is not a reservation, committed quote or authorization to change billing. Applying either example does not schedule a downgrade, create a pricing override, invoice or payment, or create a Stripe object. Destroy removes only Terraform state. No import or inverse financial operation is needed. The proration description explains what a separately authorized future change would do; the preview itself performs none of those writes.

Global billing metadata and exports

Use an explicit human profile in the platform tenant, approved read/admin consent, current global administrator membership and backend capability platform-billing-metadata-v1. An ordinary tenant administrator or machine creator has no global billing authority. Every request rechecks current roles, consent and account authority, including after database lock waits.

  • data.oauth42_platform_billing_stats: current active billing-account subscription counts and catalog monthly-price estimates. Each account counts once using its latest subscription; subscribers on retired tiers remain included. This estimate excludes annual pricing, negotiated overrides, cash collected and recognized revenue.
  • data.oauth42_platform_billing_invoices: complete global local-ledger invoices and local line items from one database snapshot. Optional status accepts draft, open, paid, past_due, uncollectible or void.
  • data.oauth42_platform_billing_aging: local accounts-receivable balances by billing account, grouped into current/30-day, 31–60-day, 61–90-day and over-90-day buckets, with totals.
  • data.oauth42_platform_billing_invoice_export: complete local invoice CSV with its header and row count.
  • data.oauth42_platform_billing_revenue_export: complete local revenue-recognition CSV, including scheduled, recognized and reversed entries.
  • data.oauth42_platform_company_billing: exact company subscription, complete pricing history, invoice configuration, saved-card metadata and its configured local or Stripe invoice channel.
  • data.oauth42_platform_company_invoice_configuration: exact company invoice schedule, purchase-order and payment-term configuration; configuration is null when absent.

Each data source returns confirmed platform_customer_id and sensitive metadata_json. The two company readers require an exact company_id and return the confirmed current billing_account_id. Global administrators may inspect existing inactive companies and companies outside the platform tenant; the current global role grants this access. A company’s current billing-account link is retained through each read.

CSV metadata contains csv and row_count; the count excludes the header. Quoted fields and spreadsheet-formula protection are preserved. CSV is financial data: keep it, state, saved plans and hosted invoice URLs private. The provider does not write an export file automatically.

Complete collections are bounded at 10,000 records and each provider response at 1 MiB. Oversized data fails explicitly; it never becomes a successful partial export. Local invoice snapshots include at most 100,000 line items in total and 10,000 per invoice. Pricing history uses one database snapshot. Separate data sources run independently and do not promise one shared financial snapshot.

Company reads never create Stripe customers or mutate financial records. Unlinked accounts have empty remote inventories; unavailable linked accounts fail. Local invoice billing selects its ledger rather than merging remote history. Stripe pagination checks every page but is not a snapshot across requests; invoice summaries link to external details. Revoking the global role or human consent denies the next read.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}
# Current global administrator membership and explicit admin consent are required.
# Protect state and saved plans: financial metadata and CSV contents are sensitive.
data "oauth42_platform_billing_stats" "platform" {}
data "oauth42_platform_billing_invoices" "platform" {}
data "oauth42_platform_billing_aging" "platform" {}
data "oauth42_platform_billing_invoice_export" "platform" {}
data "oauth42_platform_billing_revenue_export" "platform" {}
data "oauth42_platform_company_billing" "selected" {
  company_id = "33333333-3333-4333-8333-333333333333"
}
data "oauth42_platform_company_invoice_configuration" "selected" {
  company_id = "33333333-3333-4333-8333-333333333333"
}

Shared invoice billing policy

oauth42_platform_invoice_billing manages the complete purchase-order and net-term invoice policy for one exact billing account. Use a human profile in the platform tenant with explicit admin consent, current global administrator membership and backend capability platform-invoice-billing-management-v1. Writes retain the original primary authentication and independent factor, both fresh within five minutes through mandatory audit and commit. Repeat interactive sign-in and approval when that proof expires; token refresh does not renew it.

First read data.oauth42_platform_invoice_billing_review for the company. Inspect its billing_account_id, all related_company_ids, sensitive configuration_json and enablement_eligibility. A missing policy has null configuration. Manage each shared account in one resource: every related company shares the resulting policy. Manually copy the reviewed version and account into the resource, then set confirm_invoice_billing = true. A changed account, subscription or policy requires a new review.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_billing_review" "selected" {
  company_id = "44444444-4444-4444-8444-444444444444"
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_invoice_billing" "selected" {
  company_id                     = "44444444-4444-4444-8444-444444444444"
  billing_account_id             = "66666666-6666-4666-8666-666666666666"
  reviewed_configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  confirm_invoice_billing        = true
  initial_next_invoice_at        = "2099-01-01T00:00:00Z"
  enabled                        = false
  frequency                      = "manual"
  auto_send                      = false
  payment_terms_days             = 30
  po_number                      = "Reviewed purchase order"
  contract_id                    = null
  contract_start                 = null
  reminder_days                  = [7, 14]
  default_payment_method         = null
  stripe_tax_enabled             = false
}

The example creates a disabled manual policy. Supported frequencies are manual, monthly and annual; payment terms and reminder days range from 1 to 365. Optional purchase-order number, contract ID, contract start and payment method are cleared when omitted. Payment methods are wire, ach, check or other. Dates use RFC3339 with at most microsecond precision. Protect contract details in encrypted state and saved plans.

Enabling invoice billing requires an active billing account and its current DB-only subscription with skip_payment enabled and no Stripe subscription. Enabling an automatic frequency also requires an explicit next date. The policy operation does not create the subscription, issue a charge or claim an invoice was sent. The scheduler can subsequently issue invoices according to the enabled policy; auto_send controls its delivery behavior.

initial_next_invoice_at is creation-only intent. The computed next_invoice_at follows scheduler progress; refresh and normal policy updates preserve it. To change that date, read a fresh review and invoke action.oauth42_platform_invoice_billing_reschedule.selected separately with the exact account, manually pinned version and confirm_reschedule = true. Set clear_next_invoice_at = false with an exact date, or explicitly set it to true and omit the date to clear a manual or disabled schedule. An enabled automatic schedule requires a date and rejects clearing. A past date can make automatic billing immediately due. Ordinary apply does not invoke the action. A stale or uncertain invocation is never replayed automatically.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
action "oauth42_platform_invoice_billing_reschedule" "selected" {
  config {
    company_id            = "44444444-4444-4444-8444-444444444444"
    billing_account_id    = "66666666-6666-4666-8666-666666666666"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    next_invoice_at       = "2099-02-01T00:00:00Z"
    clear_next_invoice_at = false
    confirm_reschedule    = true
  }
}
terraform apply -invoke=action.oauth42_platform_invoice_billing_reschedule.selected

Import with PLATFORM_UUID/COMPANY_UUID/BILLING_ACCOUNT_UUID. Omit reviewed_configuration_version, confirm_invoice_billing and initial_next_invoice_at when importing: historical creation intent is not inferred. Refresh observes external policy changes and apply reconciles the configured policy while preserving the observed scheduling date. If the company's billing-account link changes or disappears, refresh fails and preserves Terraform state; review the surviving shared account before explicit reimport. Destroy disables future scheduling and retains the policy, existing invoices, payments and audit history; it does not cancel an invoice already issued or work already in progress. Invoice creation, sending, marking paid and voiding are separate operations.

terraform import oauth42_platform_invoice_billing.selected PLATFORM_UUID/COMPANY_UUID/BILLING_ACCOUNT_UUID

Global user passkey administration

data.oauth42_platform_user_passkeys reads complete public passkey metadata for one exact global account. Use an explicitly approved human profile in the platform tenant, read/admin consent, current platform administrator membership and backend capability platform-user-passkeys-atomic-v1. Tenant ownership or a service account does not grant this global authority.

Set target_user_id to the exact global user UUID and expected_customer_id to that user’s current primary routing-customer UUID. Use exactly unassigned when the routing customer is null. This confirms the target; it is not an authorization grant or a claim about profile ownership. A changed routing customer refuses the operation. Global administration can inspect and remove passkeys for inactive and unassigned existing targets, including accounts outside the administrator’s selected tenant.

The sensitive credentials_json contains id, credential_name, created_at, nullable last_used_at, verified backed_up, and nullable transports. It exposes no WebAuthn credential handle, public-key bytes, tokens or authentication evidence. Pages are bounded to 100 rows; Terraform follows complete pages up to 10,000 records and refuses changing totals, duplicate IDs or incomplete responses. Pagination is not a snapshot across requests. Protect labels and account metadata in encrypted private Terraform state.

action.oauth42_platform_user_passkey_remove takes the same target confirmation and one exact public credential_id. Original primary authentication and an independent factor must both remain fresh within five minutes through commit. Refreshing a token or approving new device consent never makes old proof fresh. If proof expires, repeat the interactive sign-in and approval before a new explicit invocation.

Removal, mandatory audit and global target-account credential revocation commit together. The target is signed out across tenants; other passkeys, factor enrollment, native Authenticator enrollment and unrelated accounts are preserved. Current administrator roles, consent, key/device, client and account authority remain checked after waits. Audit failure, revoked authority or expired proof rolls the operation back.

Invoke self-removal alone: it commits once and invalidates the calling credential. There is no automatic retry, post-action read, secret output or inverse destroy. A missing passkey does not prove that an uncertain invocation succeeded. Review current metadata with fresh authorized credentials before any explicit retry. Re-enrollment remains an interactive WebAuthn ceremony.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}
data "oauth42_platform_user_passkeys" "target" {
  target_user_id       = "33333333-3333-4333-8333-333333333333"
  expected_customer_id = "44444444-4444-4444-8444-444444444444"
}
# Apply and review the exact target account and public passkey registry UUID.
# Use expected_customer_id = "unassigned" only when the target routing customer is null.
# Removal signs the target account out across tenants. Invoke self-removal alone:
# terraform apply -invoke=action.oauth42_platform_user_passkey_remove.selected
action "oauth42_platform_user_passkey_remove" "selected" {
  config {
    target_user_id       = "33333333-3333-4333-8333-333333333333"
    expected_customer_id = "44444444-4444-4444-8444-444444444444"
    credential_id       = "55555555-5555-4555-8555-555555555555"
  }
}

Your authorized applications

data.oauth42_personal_consents reads your account's active OAuth consents across client owners, including applications owned by organizations you do not belong to. It requires approved human read consent, current selected-tenant membership and backend capability personal-consent-management-v1. Machine credentials cannot impersonate your account. An inactive application remains visible until you revoke its existing consent.

The sensitive consents list contains consent id, user_id, client_customer_id, internal client_id, public oauth_client_id, client_name, nullable client_description, client_active, granted_scopes, nullable remember and nullable created_at/updated_at. Legacy unknown dates and remember settings remain null. There are no client secrets, tokens or signing keys. Protect state and plans; sensitive display flags do not encrypt them.

The provider reads pages of 100 up to 10,000 consents and fails on changing totals, duplicate IDs, incomplete responses or changed authority. Concurrent changes can still move distinct records without changing totals. The snapshot neither grants consent nor creates access. Removing it from Terraform only removes the local snapshot.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}
data "oauth42_personal_consents" "account" {}
# First apply and inspect your own consent inventory. To revoke one client:
# terraform apply -invoke=action.oauth42_personal_consent_revoke.selected
# Use oauth_client_id (public identifier), not the internal client_id UUID.
action "oauth42_personal_consent_revoke" "selected" {
  config {
    user_id         = "11111111-1111-4111-8111-111111111111"
    customer_id     = "22222222-2222-4222-8222-222222222222"
    oauth_client_id = "PUBLIC_CLIENT_TO_REVOKE"
  }
}

For this combined example, approve read write offline_access and configure ["read", "write"]. A read-only inventory uses its own approved read profile and scopes = ["read"]. Apply first to read the inventory. Set oauth_client_id to the exact public client identifier from that list, then explicitly invoke action.oauth42_personal_consent_revoke.selected. The internal client_id UUID is a different identifier. Set user_id and customer_id to the current account and selected tenant; the client owner can be another tenant.

terraform apply -invoke=action.oauth42_personal_consent_revoke.selected

Revocation removes your existing consent and invalidates your existing access credentials, refresh grants and pending authorization codes for that exact client. Other accounts, other clients and independent browser sessions remain intact. You may authorize the application again later through its normal interactive consent. No administrator role is needed to revoke your own consent.

This is an explicit one-time action with no import, restore, automatic retry of uncertain execution or output credential. Repeating an already removed consent reports absence. If you target the client used by the Terraform helper, that credential also becomes unusable: keep that invocation separate from other work and obtain a new approved login afterward. The action performs no authenticated read after its mutation. A pre-authorization DPoP nonce challenge can be answered once; a lost or invalid mutation response requires independent inspection before another explicit invocation.

Quickstart: an ordinary group

Replace the example endpoint and tenant UUID with your environment. Save this as main.tf, supply credentials through the environment, and review the plan.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_group" "engineering" {
  name        = "Engineering"
  description = "Engineering team"
}
terraform validate
terraform plan -out=reviewed.tfplan
terraform apply reviewed.tfplan

The public examples are consumed by the provider acceptance suite and exercised against disposable backend/database fixtures. Do not use production credentials for the test suite.

Resources and data sources

oauth42_group

name is required, with 1–255 characters and at least one non-whitespace character. description is optional, up to 1000 characters; omitting it or using an empty string clears the managed description. API null and empty descriptions normalize to an empty Terraform string. Computed attributes are id and customer_id. Optional organization_id selects an existing organization at creation and is preserved when omitted after import; an explicit change requires replacement.

The resource owns the ordinary group lifecycle. Optional initial_member_ids seeds up to 1,000 active primary or secondary tenant members at creation. The group, all initial grants and typed audit commit together; one invalid member rejects the whole creation. Changing this input replaces the group. Refresh never restores a removed initial grant. Import leaves this creation input null: omit it when adopting an existing group, or review the replacement plan.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_group" "seeded" {
  name        = "Initial access"
  description = "Creation-only initial grants"
  initial_member_ids = ["33333333-3333-3333-3333-333333333333"]
}

Use membership resources for ongoing grant ownership. Deleting a group removes its memberships. Every group or membership mutation requires the backend capability ordinary-group-transactions-v1; an older backend is refused before writing. Create, update and add require explicit write or admin scope; removal and deletion require admin.

SCIM-managed, portal-role and platform-role groups are excluded. An existing ordinary organization-associated group can be imported, updated and deleted after the separate exact-organization approval described below. Tenant-wide scope or organization-read approval alone never authorizes this. Creation requires its own organization approval; in-place organization reassignment remains unsupported. Individual memberships require a separate membership approval described below.

oauth42_group_membership

Declare one independently owned grant using group_id and user_id. Changing either replaces that grant. Other members and schedule leases remain untouched. The computed id is the group UUID and user UUID separated by a slash; customer_id records the selected owning tenant. Exact grant identities, import and explicit whole revocation are described below.

The user must be active and have a current primary or secondary membership in the group's tenant. A queued grant rechecks membership and the acting credential after waiting for a database lock. Removing an existing grant is allowed even if its user has become inactive. A current human portal manager can manage genuine portal roles; machines cannot. Global administrator and SCIM-managed memberships remain separate. Ordinary organization-group memberships require independent exact-organization approval for machine writes.

Read-only data sources

data.oauth42_group takes id and returns the ordinary group's name, description, customer, and organization. data.oauth42_group_members takes group_id and returns user_ids plus customer_id. Neither owns or changes those objects. Standalone actions are documented in the outbound SCIM synchronization and user consent sections.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_group" "engineering" {
  name        = "Engineering"
  description = "Engineering team"
}
resource "oauth42_group_membership" "engineer" {
  group_id = oauth42_group.engineering.id
  user_id  = "22222222-2222-2222-2222-222222222222"
}
data "oauth42_group" "engineering" {
  id = oauth42_group.engineering.id
}
data "oauth42_group_members" "engineering" {
  group_id   = oauth42_group.engineering.id
  depends_on = [oauth42_group_membership.engineer]
}
output "member_ids" {
  value = data.oauth42_group_members.engineering.user_ids
}

Exact tenant membership ownership

oauth42_group_membership requires current tenant-wide authority, backend capability tenant-group-memberships-v1, read access for refresh, write or admin scope to add, and admin scope to remove. The original ordinary-group-transactions-v1 and exact organization membership contracts remain required. Human profiles use explicit approved consent. Machine credentials never inherit their creator's portal roles.

The resource records independent_grant_id, grant_instance_id, storage_customer_id, configuration_version, effective_access and scheduled_lease_count. The independent identity belongs to this resource; the physical instance can also carry another owner's schedule leases. Destroy removes only its independent grant. Eligible scheduled access and actual tenant membership survive. Permission schedules never grant portal roles; retained historical leases remain ineffective. A later independent regrant is a different owner even when the physical instance stays the same.

Creation returns its exact transaction receipt. It never follows a successful write by adopting whatever grant happens to exist later. Import an existing independent grant explicitly with terraform import oauth42_group_membership.selected GROUP_UUID/USER_UUID. Scheduled-only access cannot be imported as an independent grant. An external replacement, or state created by an older provider without independent_grant_id, refuses refresh and destroy: review ownership, remove that resource from Terraform state, then deliberately import the current grant. State removal alone does not revoke access.

A genuine portal role must be stored in the platform tenant and named exactly for the selected customer. Its mutation requires a current human portal owner or administrator, actual tenant membership, live consent and retained authority through audit/commit. The last active owner and current seat capacity are protected. A primary-only target can have its existing tenant membership materialized without promoting its generic membership role or changing profile ownership. Foreign users cannot be adopted. A local namesake remains an ordinary group and grants no portal authority or routing membership. SCIM-managed memberships and the global administrator role use their separate authority paths.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_group_membership" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  user_id            = "55555555-5555-4555-8555-555555555555"
}

data.oauth42_group_membership takes exact group_id, user_id and target_customer_id; the last must equal the selected provider tenant. It returns the complete identity and configuration metadata, group name/SCIM status, independent grant and effective-access flags, nullable grant identities and retained lease count. An absent grant is a successful metadata read with false access and null identities; it does not authorize a write. Expired schedule bookkeeping does not imply effective access.

action.oauth42_group_membership_revoke explicitly revokes the whole reviewed physical instance, including its current schedule leases. Supply exact target identities and a manually reviewed configuration_version; do not link irreversible intent to an automatically refreshed value. Ordinary apply and destroy do not invoke this action. Invoke it explicitly with terraform apply -invoke=action.oauth42_group_membership_revoke.selected. A changed target, uncertain response or already-removed instance fails without automatic replay, fake success or inverse operation. Future grants and schedule activations remain independent decisions; cancel a schedule separately to prevent its future activation.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_group_membership" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  user_id            = "55555555-5555-4555-8555-555555555555"
  target_customer_id = "22222222-2222-4222-8222-222222222222"
}
# Apply this read and review the exact target and both grant identities.
# Copy the observed configuration_version below after reviewing the loss of
# independent access AND current schedule leases. The hash is a placeholder.
action "oauth42_group_membership_revoke" "selected" {
  config {
    group_id              = "33333333-3333-4333-8333-333333333333"
    user_id               = "55555555-5555-4555-8555-555555555555"
    target_customer_id    = "22222222-2222-4222-8222-222222222222"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}

Existing organization groups: explicit write approval

Use this workflow to adopt an existing ordinary organization group without changing its organization or member grants. A current human administrator of that exact organization approves an active, expiring, tenant-wide service account. The administrator must supply fresh independent-factor proof; a password-only session, ordinary organization membership, tenant-wide machine access or organization-read approval cannot approve writes. Existing human group-management permissions are unchanged.

The human approval request is POST /organizations/ORGANIZATION_ID/group-write-grants with service_account_id and an RFC3339 expires_at. Omitting capability preserves the original organization_group_update_delete approval. It expires within 365 days and within the account lifetime, and cannot be edited or revived. The target account needs current write or admin scope before approval. Terraform does not automate this human approval ceremony or impersonate the grantor.

Keep admin scope for the full update/delete lifecycle; updates can use write with read access for refresh, but deletion still requires admin. The provider requires organization-group-update-delete-v1 and the backend checks the exact organization approval, account pairing, live scopes, expiry and revocation on every mutation. Approval for one organization never applies to another organization or tenant.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_group" "existing" {
  name        = "Approved organization group"
  description = "Existing organization group managed after explicit approval"
}
terraform import oauth42_group.existing EXISTING_GROUP_UUID
terraform plan
terraform apply

Import only reads the existing group and records its computed organization_id; it does not obtain approval. Omit initial_member_ids when importing. Review the plan before applying. This workflow supports name/description drift and updates, then terraform destroy deletes the group and its memberships atomically with typed audit. It cannot create organization groups, reassign their organization, change individual memberships, manage SCIM groups or alter protected portal/platform roles. Do not remove the resource from state and expect a subsequent apply to recreate its organization association.

A current organization administrator can list approval history with GET /organizations/ORGANIZATION_ID/group-write-grants?limit=20&offset=0 (maximum 100 per page), or revoke with DELETE /organizations/ORGANIZATION_ID/group-write-grants/GRANT_ID. Revocation needs current administrator authority but no new factor ceremony; repeating it is safe. Revoke an old approval before issuing a replacement. Removing the historical grantor's role does not silently revoke a separately approved machine: revoke that exact grant explicitly. Failed or expired authorization and failed audit writes leave group data unchanged.

Existing organization groups: member relationships

A current human administrator of the exact organization can independently approve organization_group_membership using the same group-write-grants API and fresh independent-factor proof. Include capability explicitly. Organization-read and group-update/delete approvals do not authorize member changes; membership approval does not authorize changing or deleting the group. Both approvals can coexist and are revoked independently. Existing grants retain their original authority after upgrade.

POST /organizations/ORGANIZATION_ID/group-write-grants
{
  "service_account_id": "SERVICE_ACCOUNT_UUID",
  "capability": "organization_group_membership",
  "expires_at": "2027-01-01T00:00:00Z"
}

Choose an expiry within the service account lifetime and no more than 365 days ahead. Keep admin for the full add/remove lifecycle; adding may use write plus read access for refresh. The provider requires organization-group-membership-v1 before writing, and the backend independently checks the exact current approval, tenant, account, scopes, expiry and revocation through commit.

The target must already be an active member of the selected tenant through a primary or secondary association. This workflow neither adopts a global identity nor assigns an organization role. It cannot revive an identity denied by current organization SCIM state. Removing a stale ordinary relationship remains allowed when its user becomes inactive or leaves the tenant, provided the actor still has current approval. Protected portal/platform roles and SCIM-managed groups stay excluded.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
data "oauth42_group" "existing" {
  id = "33333333-3333-3333-3333-333333333333"
}
resource "oauth42_group_membership" "existing" {
  group_id = data.oauth42_group.existing.id
  user_id  = "22222222-2222-2222-2222-222222222222"
}
data "oauth42_group_members" "existing" {
  group_id   = data.oauth42_group.existing.id
  depends_on = [oauth42_group_membership.existing]
}
output "member_ids" {
  value = data.oauth42_group_members.existing.user_ids
}
terraform import oauth42_group_membership.existing EXISTING_GROUP_UUID/EXISTING_USER_UUID
terraform plan
terraform apply

Import only reads the relationship; it does not grant write authority. Refresh observes external removal, and apply can restore the declared relationship only with current approval. Destroy removes this one relationship and preserves other users and the group. A denied removal leaves the Terraform state entry intact. Failed or expired authority and failed audit writes roll back the mutation. Revoking approval stops future writes but does not retroactively remove previously approved memberships; remove unwanted relationships explicitly before revoking that grant.

Create an organization group

A current human administrator of the exact existing organization can issue organization_group_create through the same group-write-grants API with fresh independent-factor proof. Read, metadata and membership approvals never imply creation authority. A service account cannot approve itself. Set capability explicitly; omitting it still requests only update/delete approval.

POST /organizations/ORGANIZATION_ID/group-write-grants
{
  "service_account_id": "SERVICE_ACCOUNT_UUID",
  "capability": "organization_group_create",
  "expires_at": "2027-01-01T00:00:00Z"
}

Choose expiry within the account lifetime and at most 365 days ahead. Creation with no initial members needs only creation approval. Nonempty initial_member_ids additionally requires independent organization_group_membership approval for the same organization. Later update or destroy needs organization_group_update_delete approval. Use admin scope for the full lifecycle; creation alone accepts write with read access for refresh. The backend checks current authority and expiry through commit; compatibility marker organization-group-create-v1 alone grants nothing.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["admin"]
}
resource "oauth42_group" "organization" {
  name = "Approved new organization group"
  description = "Created with independent organization approval"
  organization_id = "22222222-2222-2222-2222-222222222222"
  # Omit initial members for an empty group; otherwise membership approval is also required.
  initial_member_ids = ["33333333-3333-3333-3333-333333333333"]
}
output "organization_group_id" { value = oauth42_group.organization.id }

All initial targets must already be active primary or secondary members of the selected tenant and not denied by organization SCIM state. Group creation, initial independent grants and typed audit are atomic. Any ineligible target, failed audit, expired approval or revoked authority leaves no partial group. Reserved platform/portal names and SCIM-managed groups remain excluded; this creates neither organizations nor identities nor organization roles.

Changing an explicit organization_id requires destroy/create replacement with current approval in both affected organizations; there is no in-place move. Omission after import preserves the observed association. Import remains read-only and leaves initial_member_ids null; omit initial members when importing an existing group to avoid replacement. Refresh never restores removed initial members. Use separate membership resources for ongoing relationship ownership.

terraform import oauth42_group.organization EXISTING_GROUP_UUID
terraform plan
terraform apply

Revoking creation approval stops future creation but does not revoke independent metadata/membership approvals or delete existing groups. A denied destroy preserves state. Before intentionally replacing or destroying a group, review the loss of all its member relationships and dependent grants.

Discover your service account's tenant

oauth42_portal_tenants reads the complete machine catalog: exactly its active configured tenant. oauth42_portal_tenant reads that same tenant by explicit UUID. Both require a current tenant-wide service account with read or admin scope and backend capability tenant-self-read-v1. Application-scoped accounts are refused. There is no automatic traversal of billing-account siblings or the human creator's memberships.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_portal_tenants" "current" {}
output "tenants" {
  value = data.oauth42_portal_tenants.current.tenants
  sensitive = true
}
terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_portal_tenant" "current" {
  id = "11111111-1111-1111-1111-111111111111"
}
output "tenant" {
  value = data.oauth42_portal_tenant.current.tenant
  sensitive = true
}

The catalog returns customer_id, active_customer_id and a one-element tenants list. Detail requires id equal to the provider's configured customer and returns customer_id and tenant. Each summary includes id, name, contact email, status, created_at is_admin and can_manage_tenants. Contact metadata is sensitive Terraform state; protect plans and remote state. Inactive or deleted tenants fail authorization rather than returning a partial or empty successful catalog.

For machines, is_admin and can_manage_tenants are always false: discovery does not grant a human portal role or tenant creation/deletion, tenant switching, billing or cross-tenant management authority. Use separately approved platform company data sources for global inventory. Human discovery and tenant lifecycle are described below.

These are read-only data sources with no import. Refresh observes current metadata and fails on revoked account activity, tenant-wide authority or scope, even if a prior state snapshot exists. Destroy only removes the data-source snapshot from state and does not delete or modify the tenant.

Manage tenants in your shared billing account

Use an Authenticator-approved human profile with the original selected source tenant and backend capability portal-tenant-lifecycle-v1. Creation requires its actual current portal-owner or portal-administrator grant, read admin offline_access login consent and provider scopes ["read", "admin"]. A generic tenant-admin role alone is insufficient. Existing primary-only membership remains valid when that actual portal grant exists; it does not become a generic administrator role.

data.oauth42_portal_tenant_creation_context returns the selected source and shared billing UUIDs, reviewed configuration version, current tier, tenant count, nullable maximum (null means unlimited) and whether configuration writes are allowed. Copy the billing UUID and version into the lifecycle resource manually. Creation rechecks policy, payment restrictions and capacity while retaining the billing lock. It never purchases a subscription or upgrades a plan.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_portal_tenant_creation_context" "current" {}
output "reviewed_shared_billing" {
  value = data.oauth42_portal_tenant_creation_context.current
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_portal_tenant" "managed" {
  name = "Shared Billing Workspace"
  billing_email = "[email protected]"
  # Copy the reviewed source billing account and policy version before creating.
  billing_account_id = "99999999-9999-4999-8999-999999999999"
  initial_context_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  grant_initial_portal_owner = true
}

oauth42_portal_tenant requires name, reviewed billing account, initial_context_version and explicit grant_initial_portal_owner = true for creation. Optional billing email defaults to your current email. It returns the exact source/billing/customer UUIDs, configuration version, nullable contact metadata, status, creation time and initial owner/group/grant receipts. No credentials enter state. Names and billing contact are immutable through this resource; changed inputs or external drift require a reviewed replacement. Initial policy/grant inputs describe creation only and never recreate revoked access.

Import an existing tenant as SOURCE_CUSTOMER_UUID/BILLING_ACCOUNT_UUID/TARGET_CUSTOMER_UUID, using its current name and contact and omitting unknown initial context/grant inputs. Imported historical receipts remain null. The source must remain the provider's originally selected tenant; moving a target to another billing account denies refresh rather than adopting it. Sensitive contact metadata remains in Terraform plans and state, so protect both.

Destroy retires the exact target with its saved configuration version, makes it inactive and revokes its tenant-scoped sessions and refresh credentials. The source or platform tenant cannot be retired. Tenant tables, memberships, billing and history remain retained. A later creation can reuse a retired display name but creates a distinct UUID; it cannot reactivate old history. Stale saved retirement plans, changed billing bindings, repeated retirement and uncertain responses are refused without automatic replay.

Retirement requires current portal-owner/admin authority in the target and current membership in another tenant of the same billing account; it does not invent an administrative requirement in the source. An import-only retirement workflow can use approved read write offline_access consent and provider scopes ["read", "write"]. Creation still requires admin consent. Sensitive mutations retain the original fresh independent-factor proof and mandatory typed audit through commit. Revoked target ownership denies refresh, import and destroy; Terraform never restores it.

With human mode, the existing tenant catalog lists current memberships within the selected billing account, including primary-only membership, and detail requires current portal authority in the exact target. Reads accept approved read scope and do not create tenants or grant access. is_admin preserves generic tenant-management metadata; can_manage_tenants reports the separate actual portal role. Nullable existing contact and legacy role values are preserved. Catalogs fail beyond 10,000 entries instead of returning a partial success; concurrent changes can still alter a later snapshot. These human forms do not change machine discovery's own-tenant boundary.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_portal_tenants" "current" {}
output "tenants" {
  value = data.oauth42_portal_tenants.current.tenants
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_portal_tenant" "current" {
  id = "33333333-3333-4333-8333-333333333333"
}
output "tenant" {
  value = data.oauth42_portal_tenant.current.tenant
  sensitive = true
}

Discover existing tenant configuration

These read-only catalogs require an active tenant-wide service account. Users and groups accept explicit read or admin scope; service-account catalogs require admin. Before each read, the provider checks live authority through the self-context API. Application-scoped accounts are refused for these tenant catalogs. No automatic scope escalation occurs.

  • data.oauth42_groups returns customer_id and groups, sorted by UUID. Each group has id, name, description, customer_id, and nullable organization_id. SCIM-managed and portal authorization groups are excluded.
  • data.oauth42_users returns customer_id and a sensitive users list. Each entry has id, email, nullable first_name/last_name, is_active, and created_at. The current API lists primary-tenant users, including inactive users; secondary tenant memberships are not included. It does not create, activate, invite, or remove people.
  • data.oauth42_service_accounts returns customer_id and service_accounts, sorted by UUID. data.oauth42_service_account takes a required account id and returns that same account metadata as top-level attributes. An account from another tenant is not accessible.

Service-account attributes are id, client_id, name, nullable description, customer_id, sets of scopes/roles/permissions, credential_version, is_active, tenant_wide, timestamps created_at/updated_at and nullable last_used_at/expires_at/created_by. application_access contains an application UUID, nullable application name, and role set. Client secrets are never returned. These reads can show inactive target accounts but omit deleted tombstones; the acting account must remain active. Deletion revokes the account and retains typed audit history. A new account with the same display name gets a new identity and does not inherit old credentials or assignments.

Catalogs observe current data without owning it. Last-used timestamps can change when an account authenticates. Store only necessary outputs, protect state containing personal metadata, and mark derived user outputs sensitive. Terraform sensitivity hides display output; it does not encrypt state.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
data "oauth42_groups" "ordinary" {}
data "oauth42_users" "primary_tenant" {}
data "oauth42_service_accounts" "automation" {}
data "oauth42_service_account" "observed" {
  id = "33333333-3333-3333-3333-333333333333"
}

output "ordinary_group_ids" {
  value = [for group in data.oauth42_groups.ordinary.groups : group.id]
}

output "primary_tenant_user_ids" {
  value     = [for user in data.oauth42_users.primary_tenant.users : user.id]
  sensitive = true
}

Manage service-account identity and assignments

oauth42_service_account creates a new account using an independent tenant-wide administrator credential. Required inputs are name (1–255 characters) and a nonempty scopes set. Optional description defaults to an empty string, and tenant_wide defaults to false. The backend has no ordinary account-update endpoint: changing any creation input replaces the account with a fresh identity and credential.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_service_account" "automation" {
  name            = "Scoped Terraform automation"
  description     = "Dedicated read automation"
  scopes          = ["read"]
  tenant_wide     = false
  expires_in_days = 30
}
resource "oauth42_service_account_application" "access" {
  service_account_id = oauth42_service_account.automation.id
  application_id     = "44444444-4444-4444-4444-444444444444"
}

expires_in_days is a creation-only lifetime of 1–365 days; omit it for no expiration. Reading or planning never extends the deadline. initial_application_ids seeds scoped assignments only at creation and is not an authoritative ongoing set. Changing either input replaces the account. Import cannot recover these original inputs: leave them omitted when adopting an existing account, or review the resulting replacement plan.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_service_account" "bootstrap" {
  name                    = "Bootstrap-scoped automation"
  scopes                  = ["read"]
  initial_application_ids = ["44444444-4444-4444-4444-444444444444"]
}

oauth42_service_account_application owns one relationship using service_account_id and application_id. Changing either replaces that relationship; unrelated assignments and their roles remain untouched. It works only with scoped accounts and applications in the same tenant. Use it for ongoing drift repair, including an assignment originally seeded at account creation.

Computed account fields are id, customer_id, client_id, is_active, credential_version, roles, permissions, application_access, and the timestamps and nullable human creator field described in the catalog section. Current inactive status is observed without silently reactivating an identity. Changes to observable immutable settings produce replacement plans; creation-only seed/lifetime inputs do not claim ongoing ownership of assignments or relative time.

client_secret is a sensitive creation result stored in Terraform state. Protect state and saved plans with encryption and access controls; sensitivity does not encrypt them. Import cannot recover a secret. The opaque credential_version changes on rotation without exposing secret material; refresh clears a previously stored secret if rotation occurred outside Terraform. Use the explicit rotation revision described below to issue a new one-time credential. Do not assume an old state value remains usable after external rotation. Legacy accounts without a paired client retain null credential/version fields on import and preserve their existing activity flag; the provider never fabricates a client to make import succeed. Creation checks version support before making a new account.

terraform import oauth42_service_account.automation SERVICE_ACCOUNT_UUID
terraform import oauth42_service_account_application.access SERVICE_ACCOUNT_UUID/APPLICATION_UUID

Destroy revokes the credential and retains an inactive audit tombstone. The name becomes available for a different identity; no grants or credentials are inherited. Replacements using the same name require destroying the old account first, so create_before_destroy is incompatible with that name constraint. Removing an assignment revokes only that relationship. Keep the provider’s own administrator account separate from resources it destroys.

Inspect current management authority

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["read"]
}
data "oauth42_management_context" "current" {}

data.oauth42_management_context returns your current customer_id, OAuth subject_id, native actor_id, actor_kind, tenant_wide, effective scopes and explicitly assigned application_ids. It accepts read, write or admin scope and works for an application-scoped service account. It also returns implemented contract capabilities, which never replace current authorization. It never returns a token or inherits the creator’s human permissions. Tenant-wide authority does not grant platform administration.

Terraform uses the same live self-context before mutations and tenant catalogs, without requesting admin automatically. Each backend operation still checks its own current scope and tenant or application grant. Ordinary read operations can use read scope; create/update plans also need the appropriate write scope, and deletion requires admin. Service-account catalogs remain admin operations. Revocation, expiry and removed assignments take effect on subsequent requests.

Rotate managed service-account credentials

Use an independent, currently active tenant-wide admin service account for provider authentication. Set rotation_revision on oauth42_service_account to a non-whitespace value of at most 128 characters, then change that value when deliberately rotating an existing account. Creation already issues a fresh secret and records the initial revision without a second rotation. Unchanged plans never repeat rotation; clearing the revision does not rotate.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_service_account" "worker" {
  name              = "Versioned rotation example"
  scopes            = ["read"]
  tenant_wide       = false
  rotation_revision = "credential-change-2026-11-05"
}
output "worker_client_secret" {
  value     = oauth42_service_account.worker.client_secret
  sensitive = true
}

The returned one-time secret and opaque version are captured together in sensitive state before refresh. Integrate that sensitive value with your approved secret-manager resource and update consumers; sensitivity does not encrypt state or saved plans. The example creates an application-scoped account with no grants: attach only the required application assignments separately. Imported accounts have no recoverable secret; leave the revision empty before import, then explicitly set a new revision to rotate.

External rotation clears stale state secrets. Inactive, expired or unpaired accounts cannot rotate, and the provider never creates a missing client or reactivates an account to make rotation succeed. The backend requires service-account-credential-response-v1; older backends are refused before mutation. If a successful rotation is followed by revoked read access, Terraform retains the committed pair and revision for recovery without repeating rotation after access is restored.

The provider refuses to rotate its own acting credential. Rotate provider authentication through an independent authorized administrator, update your secret manager and restart Terraform with the replacement. Current scope, tenant-wide authority, account activity and tenant binding remain mandatory on every request.

Manage organization SCIM user profiles

oauth42_scim_user owns a profile and access status within one organization. It uses the same bound SCIM mode, current read/write scopes and completed provisioning capability as groups. The organization must have a current default provisioning role. Creation requires an unused global identity email; it never adopts, links or reactivates an existing identity because an email matches.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint        = "https://api.example.com"
  scim_only       = true
  customer_id     = "11111111-1111-1111-1111-111111111111"
  organization_id = "66666666-6666-6666-6666-666666666666"
  scopes          = ["scim:read", "scim:write"]
}
resource "oauth42_scim_user" "person" {
  username    = "new-provisioned-person"
  email       = "[email protected]"
  given_name  = "New"
  family_name = "Person"
  external_id = "directory-person-001"
  active      = false
}
data "oauth42_scim_user" "person" {
  id = oauth42_scim_user.person.id
}
data "oauth42_scim_users" "directory" {
  depends_on = [oauth42_scim_user.person]
}

Choose a new username and unused email before applying this example. Required username has no surrounding whitespace; required email is one lowercase address. Optional given_name, family_name and external_id default to empty strings, which clear those local fields. External IDs reject surrounding whitespace. These fields are sensitive in Terraform output, but still exist in state: use encrypted state storage with restricted access.

active defaults to true; the example starts false so it grants no active organization access. Setting false disables this organization's role grants and removes its group and direct application assignments. Setting true grants only the current default role; it cannot revive historical group, app or nondefault role grants. A globally disabled identity remains disabled: Terraform reports the effective inactive state and an attempted local activation fails.

Profile updates change only this organization's username, email and names. Global sign-in identifiers, verification status, human identity fields and other organizations remain independent. The computed user_id is the underlying UUID for group membership; customer_id and organization_id pin the scope. The computed id is also the import identity:

terraform import oauth42_scim_user.person CUSTOMER_UUID/ORGANIZATION_UUID/USER_UUID

Import requires an existing profile or current ordinary membership in that organization. It does not grant access or fabricate a new identity. Imported legacy members retain global human fields when their local profile is edited. The computed version protects updates and deletion against stale plans, including relevant global activity changes. Refresh and review a new plan after a conflict.

Destroy permanently deletes this organization's profile. It preserves the global identity, tenant membership and unrelated organization grants. A deletion tombstone prevents automatic restoration, and creation with that existing identity email fails. Use active = false for reversible deprovisioning; use Terraform deletion protection where permanent removal needs a separate review.

data.oauth42_scim_user takes the scoped id and returns the same fields without owning the profile. data.oauth42_scim_users returns a sensitive users list sorted by UUID, including visible inactive profiles. It uses the same bounded complete-pagination checks and concurrent-change limitations as the group directory. Removing data sources changes state only. User credentials, global identity administration and nondefault role assignment are separate capabilities.

Provision organization SCIM groups

oauth42_scim_group manages a SCIM group and its complete member_ids set in one organization. Configure a separate SCIM provider and supply O42_SCIM_TOKEN from your secret manager. Both scim:read and scim:write must be explicitly configured and currently granted. The API must advertise organization-provisioning-transactions-v1; older backends are refused before object requests.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint        = "https://api.example.com"
  scim_only       = true
  customer_id     = "11111111-1111-1111-1111-111111111111"
  organization_id = "66666666-6666-6666-6666-666666666666"
  scopes          = ["scim:read", "scim:write"]
}
resource "oauth42_scim_group" "team" {
  display_name = "Provisioned team"
  external_id  = "team-engineering"
  member_ids   = ["22222222-2222-2222-2222-222222222222"]
}
data "oauth42_scim_group" "team" {
  id = oauth42_scim_group.team.id
}
data "oauth42_scim_groups" "directory" {
  depends_on = [oauth42_scim_group.team]
}

display_name is required. Optional external_id defaults to an empty string, which clears it. Both fields reject surrounding whitespace. Omitting member_ids means an empty group. Members must be current, active organization users; expired or revoked membership cannot be granted through Terraform. Deactivating a user can remove group membership and produce visible drift. Never give another state or provisioner ownership of the same authoritative member set.

The computed group_id is the group UUID. The computed id binds the customer, organization and group together. Import preserves that scope:

terraform import oauth42_scim_group.team CUSTOMER_UUID/ORGANIZATION_UUID/GROUP_UUID

customer_id and organization_id are immutable scope evidence. Switching provider credentials cannot reinterpret an imported ID in another organization. The computed version is used for conditional updates and deletion. If another writer changes the object after a saved plan, apply fails; refresh, review and create a new plan. Destroy deletes the group and its memberships, preserving user identities.

data.oauth42_scim_group takes the scoped id and returns the same fields without owning the group. data.oauth42_scim_groups returns a groups list with those fields, sorted by group UUID. It enumerates up to 100,000 groups and refuses repeated IDs, changing totals or truncated pages. Offset pagination is not a cross-request snapshot: retry after concurrent provisioning finishes. Data-source removal changes only state.

Group membership and external identifiers are stored in Terraform state. Protect the state as tenant data. Token rotation is external to this resource: replace the process secret and refresh; revoked tokens fail immediately. Use the separately approved human action in the protected SCIM rotation section to rotate the provisioning token.

Verify SCIM provisioning identity

Use a separate provider configuration with scim_only = true for an organization provisioning token. Set O42_SCIM_TOKEN from your secret manager and explicitly configure both the customer and organization UUIDs. This mode ignores ambient OAuth credentials and refuses ordinary OAuth management resources. Global provisioning tokens are refused.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  scim_only   = true
  customer_id = "11111111-1111-1111-1111-111111111111"
  organization_id = "66666666-6666-6666-6666-666666666666"
  scopes      = ["scim:read"]
}
data "oauth42_scim_context" "current" {}

data.oauth42_scim_context returns the current customer_id, organization_id and scopes, never token material. Explicit scopes must be scim:read or scim:write and remain granted on refresh. The backend checks both expected identifiers on every bound request; a mismatched token cannot select another tenant. Disabled organizations, tenant deletion/suspension, token rotation and empty scope grants fail closed. Removing the data source changes only Terraform state.

The provider requires the O42 /scim/v2/Context extension from #680. The SCIM group resource additionally requires the completed organization provisioning capability. SCIM user and group resources use this completed scoped contract. Ordinary SCIM clients may continue using standard unbound protocol requests. Never confuse the SCIM provisioning token with an OAuth service-account secret.

Read an existing user

data.oauth42_user reads one active or inactive identity by canonical lowercase UUID, using a current tenant-wide service account with explicit read or admin scope. It requires current visibility through profile ownership, default routing or tenant membership. It never creates, adopts, activates, invites or deletes an identity. Removing the data source changes only Terraform state.

terraform {
  required_providers {
    oauth42 = {
      source = "oauth42/oauth42"
      version = "~> 0.1.0"
    }
  }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_user" "existing" {
  id = "55555555-5555-5555-5555-555555555555"
}
output "user_email" {
  value = data.oauth42_user.existing.email
  sensitive = true
}

Computed customer_id is the configured requesting tenant. Nullable default_customer_id and default_company_name describe routing; nullable profile_owner_customer_id records explicit profile ownership. These can differ for a secondary member. A null owner never implies that the default tenant owns the profile. This read requires migration 040 and the matching user API; an older backend missing explicit ownership metadata fails safely.

Other computed fields are email, nullable username, first_name, last_name, phone, is_active, nullable email_verified/mfa_enabled, created_at and nullable updated_at. Identity, contact and verification fields are sensitive in Terraform output but remain present in state: encrypt state and restrict access. No password hash or MFA secret is accepted. Refresh observes profile drift and current grant revocation; a missing or inaccessible identity fails the read.

Existing identity association uses the explicitly reviewed organization-member and tenant lifecycle operations described above. Default routing and membership never transfer global profile ownership. The resource below creates a new explicitly owned tenant identity. The repaired tenant provisioning API permits omission of its unused password field, defaults invitations to off, and rejects a supplied customer ID that differs from current authority. Creating a user cannot grant membership in an organization-associated group with tenant machine scope. Queued creation rechecks current authority after group or organization locks. Public signup and platform-admin password creation still require a validated password; Terraform user creation uses only the authenticated tenant provisioning flow.

Generic tenant removal requires current admin scope and refuses independently owned SCIM profiles, SCIM group memberships or current organization roles until their authorized flows clear them. Machines cannot remove portal-role holders through generic user deletion. The tenant-owned user resource below supports association removal with these same boundaries; global identity adoption and organization/platform delegation remain separate work.

Read tenant statistics and your automation’s activity

data.oauth42_tenant_statistics and data.oauth42_actor_activity require current tenant-wide read or admin and actor-observability-v1. They expose snapshots only: no create, import, update, deletion or audit replay. Refresh rechecks current grants; destroying their state changes nothing in O42.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["read"]
}
data "oauth42_tenant_statistics" "current" {}
data "oauth42_actor_activity" "recent" {
  limit = 3
}
data "oauth42_actor_activity" "older" {
  count  = data.oauth42_actor_activity.recent.next_cursor == null ? 0 : 1
  limit  = 3
  cursor = data.oauth42_actor_activity.recent.next_cursor
}
output "active_members" {
  value = data.oauth42_tenant_statistics.current.total_users
}
output "recent_actor_events" {
  value     = data.oauth42_actor_activity.recent.activities
  sensitive = true
}

Statistics return customer_id, active explicit tenant members (total_users), active applications (total_applications), unrevoked and unexpired active_sessions, and recent_logins counting session-created events during the past 24 hours. These are operational counts, not billing totals or a promise that time-dependent values remain unchanged.

Activity belongs only to the authenticated principal. A service account never inherits its creator’s or another account’s history. Each page returns customer_id, total retained events, activities and nullable next_cursor. Each event has id, event_type, message, optional detail, created_at and sensitive metadata_json. Treat the activity list and Terraform state as sensitive.

limit accepts 1–50, defaulting to 50. This is an explicitly bounded page, not a complete audit export. Omit cursor for newest events; pass next_cursor to another page for older retained events. Cursors are tied to the exact actor and tenant. Events sort by creation time and UUID descending; tenant retention still applies. New activity and retention expiry can change totals between refreshes. The example stops after two pages deliberately.

Stored organization security configuration

oauth42_organization_security_configuration manages the complete stored security configuration of an existing active organization. The matching data source reads it without taking ownership. This metadata does not change effective tenant authentication policy. Use an explicit human profile, approved admin scope, current global administrator authority and current membership in the selected tenant. Organization read approvals and machine credentials do not authorize these operations. The backend must advertise organization-stored-security-v1.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Stored organization metadata; effective tenant authentication policy is separate.
# Requires current global administrator membership AND membership in this selected tenant.
resource "oauth42_organization_security_configuration" "stored" {
  organization_id              = "33333333-3333-4333-8333-333333333333"
  mfa_enforcement              = "optional"
  mfa_grace_period_days        = 0
  mfa_allowed_methods          = []
  password_min_length          = 19
  password_breached_action     = "warn"
  session_max_duration_hours   = 8
  session_idle_timeout_minutes = 15
  session_allow_concurrent     = false
}
data "oauth42_organization_security_configuration" "observed" {
  organization_id = oauth42_organization_security_configuration.stored.organization_id
  depends_on      = [oauth42_organization_security_configuration.stored]
}
# Import CUSTOMER_UUID/ORGANIZATION_UUID to inspect existing settings first.
# Destroy detaches Terraform ownership and preserves the organization's settings.

Set the exact organization_id and provider customer_id. Create adopts only that existing organization's security configuration; it never creates an organization. Declare at most one resource per organization. Import first to inspect existing values: terraform import oauth42_organization_security_configuration.stored CUSTOMER_UUID/ORGANIZATION_UUID. Import is read-only. Changing the configured tenant cannot transfer ownership or redirect an update.

Writes replace all policy fields and require original primary authentication plus an independent factor completed within five minutes, including after lock waits and deferred audit checks. Refresh does not renew this proof. Reauthenticate through the approved helper if it expires. Current consent, membership, global role, factor enrollment and organization access remain required.

Configure mfa_enforcement as disabled, optional or required; nonnegative mfa_grace_period_days; and mfa_allowed_methods from totp, sms, email, webauthn and authenticator. An empty method set is preserved. password_min_length accepts 8–128 and password_breached_action accepts block, warn or off (default off). Deprecated composition flags read false and maximum password age reads zero. Session duration accepts 1–8760 hours, idle timeout 5–1440 minutes, and concurrent sessions is an explicit boolean. These are stored metadata fields, not a preview of effective sign-in policy.

Readback includes id, customer_id, organization_id and opaque configuration_version. Each update uses the version observed during refresh; a stale saved plan fails instead of overwriting an outside change. Refresh and review a new plan after a conflict. Unrelated organization settings remain unchanged. Legacy absent or JSON-null settings read defaults; successful updates persist the complete configuration. Malformed stored values fail explicitly.

Destroy removes Terraform ownership and preserves stored settings. It never deletes the organization or resets its security configuration. To change settings, apply the desired explicit configuration before detaching. The data source returns the same complete fields; removing it only removes state.

Organization security settings in the admin API are separate stored metadata, available through oauth42_organization_security_configuration. Use oauth42_security_policy below for the effective tenant policy.

Manage tenant security policy

oauth42_security_policy owns the configured tenant’s existing policy singleton. Declare at most one resource per tenant. Both resource and data.oauth42_security_policy require current tenant-wide admin scope and the backend capability tenant-security-policy-v1. Application-scoped credentials and older servers are refused before policy requests.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_security_policy" "tenant" {
  mfa_enforcement              = "required"
  mfa_grace_period_days        = 0
  mfa_allowed_methods          = ["authenticator", "totp"]
  password_min_length          = 14
  password_breached_action     = "block"
  session_max_duration_hours   = 12
  session_idle_timeout_minutes = 15
  session_allow_concurrent     = false
}
data "oauth42_security_policy" "current" {
  depends_on = [oauth42_security_policy.tenant]
}
output "tenant_mfa_policy" {
  value = data.oauth42_security_policy.current.mfa_enforcement
}

Creation and update replace all three tenant policy sections with the explicit configuration, atomically with typed audit. Other customer metadata and other tenants remain unchanged. Read/import only observe the policy; external changes appear as drift. Configure the desired values before importing so the next plan makes any intended changes reviewable:

terraform import oauth42_security_policy.tenant CUSTOMER_UUID

Destroy only removes Terraform ownership. It never resets the policy or disables MFA. There is no policy-delete API. The computed id and customer_id equal the configured tenant UUID, and changing the provider tenant for existing state is refused. A missing tenant or invalid stored policy is an error, never an invitation to recreate defaults.

  • Required mfa_enforcement: disabled, optional or required. Optional mfa_grace_period_days defaults to zero and cannot be negative. Required mfa_allowed_methods is a set of totp, sms, email, webauthn or authenticator. An empty set permits no independent factor; consider the resulting sign-in restrictions before applying it.
  • Required password_min_length: 8–128. Optional password_breached_action: block, warn or off; absent legacy values normalize to the API default off. The example explicitly selects block. Computed password_require_uppercase, password_require_lowercase, password_require_numbers and password_require_special remain false, and password_max_age_days remains zero: the API does not support composition rules or periodic password expiration.
  • Required session_max_duration_hours: 1–8760; required session_idle_timeout_minutes: 5–1440; required session_allow_concurrent: boolean.

The data source has no inputs beyond provider configuration and returns the same attributes without owning policy. These values describe the stored tenant policy, not a bypass of application or deployment enforcement. An application may still require a second factor; a primary passkey cannot count twice. O42 Authenticator uses its enrolled approval key. Email requires the application’s explicit opt-in and is weaker. Global identities must satisfy applicable password rules across their tenant memberships. Organization/platform policy remains a separate authority surface.

Manage tenant-owned users

oauth42_user creates a new global identity owned by the configured tenant and manages its non-identity profile. Use current tenant-wide authority and backend capability tenant-user-mutations-v1. Reads require read/admin, creation and profile changes require write/admin, and removal requires admin. The example uses admin for the complete lifecycle. Current grants, activity and expiry are rechecked after mutation lock waits; mandatory typed audit must commit with the change.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["admin"]
}
resource "oauth42_user" "teammate" {
  email = "[email protected]"
  username = "terraform-user"
  first_name = "Taylor"
  last_name = "Example"
}
data "oauth42_user" "teammate" {
  id = oauth42_user.teammate.id
}

Required email is a normalized lowercase address without a display name and is immutable: changing it replaces the identity. Optional username, first_name and last_name allow up to 255 characters; phone allows 50. Control characters and blank usernames are rejected. Omitted profile fields are explicitly cleared, including username. Optional creation-only initial_is_active defaults to true; changing it requests replacement, never reactivation of an existing identity. Omit that field on import.

Computed id, customer_id, profile_owner_customer_id, default_customer_id, is_active, email_verified, mfa_enabled, created_at and updated_at expose current metadata. Outside deactivation remains inactive after a profile update. Contact and verification fields are marked sensitive but still reside in state; protect state storage and access.

Create never adopts an existing email, sets a known password, links or reactivates an identity, or sends an invitation. Existing-email conflicts, including retained inactive identities, require an explicit ownership decision outside this resource. Use the separate invitation resource for onboarding and additive group/application resources for grants. Organization assignment and platform authority are not inferred from tenant-wide scope.

terraform import oauth42_user.teammate 22222222-2222-2222-2222-222222222222

Import only reads an identity explicitly profile-owned by this tenant. Secondary membership and default routing are insufficient. Match existing profile fields in configuration before applying, since omission clears optional fields. A later ownership change fails refresh rather than silently adopting or deleting another owner's profile. Tenant changes also fail safely.

Destroy removes only the configured tenant association and its local access. It relinquishes that tenant's profile ownership, preserves other tenant memberships and the global authentication identity/history, and leaves an inactive tombstone when no tenant remains. The retained email cannot be recreated automatically. Independent SCIM profiles, organization roles or protected portal grants must first be removed through their authorized flows. Use Terraform deletion protection when unlinking needs separate review.

Read user security inventory

data.oauth42_user_mfa, data.oauth42_user_sessions, data.oauth42_user_consents, data.oauth42_user_passkeys and data.oauth42_user_groups read security metadata for one current active tenant member. All require the canonical user UUID in id, current tenant-wide admin scope and backend capability tenant-user-security-inventory-v1. An application assignment or read scope alone is insufficient. The backend rechecks actor authority and target membership after reading data; a database failure is an error rather than an empty inventory.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["admin"]
}
data "oauth42_user_mfa" "member" {
  id = "55555555-5555-5555-5555-555555555555"
}
data "oauth42_user_sessions" "member" {
  id = "55555555-5555-5555-5555-555555555555"
}
data "oauth42_user_consents" "member" {
  id = "55555555-5555-5555-5555-555555555555"
}

data "oauth42_user_passkeys" "member" {
  id = "55555555-5555-5555-5555-555555555555"
}

data "oauth42_user_groups" "member" {
  id = "55555555-5555-5555-5555-555555555555"
}

Each data source returns the configured customer_id and sensitive metadata_json; use jsondecode to inspect the complete response. Snapshots remain in state, so encrypt state and restrict access. Unknown fields that might expose credentials are rejected. These reads do not supply cryptographic proof that a factor was used.

MFA metadata contains totp_enabled, email_otp_enabled, phone_mfa_enabled, nullable masked email_otp_address/phone_mfa_number, nullable phone_mfa_method (sms or voice), verified_at, last_used_at and backup_codes_remaining. No factor seed or recovery-code value is returned. This endpoint reports TOTP/email/phone configuration; native authenticator and passkey inventories are separate API capabilities.

Session metadata is a sessions array of active, unrevoked records in this tenant: id, nullable ip_address/user_agent/risk_score, and created_at, last_activity_at, expires_at. IDs identify database records, not bearer session tokens. Consent metadata is a consents array with id, client_id, client_name, nullable client_description, granted_scopes, remember, created_at and updated_at.

Passkey metadata is a credentials array with id, credential_name, created_at, nullable last_used_at, backed_up and optional transports. These O42 identity credentials can span tenants; this data source only reads their metadata and never deletes a passkey or exposes public-key bytes. Group metadata contains groups and total: the user's current effective memberships in the configured tenant, including owned portal-role groups. Each group has its UUID, name, nullable description and organization UUID, tenant UUID, SCIM metadata, member count and timestamps. Future, expired and foreign grants are excluded. Metadata reads do not grant permission to manage protected roles.

Refresh observes current metadata and fails for revoked authority, inactive users, removed membership, a foreign target or a tenant mismatch. Removing these data sources only discards Terraform snapshots. It never resets factors, revokes sessions or changes consent. No import step is needed for data sources. Use the explicit human-authorized factor-reset action below for an owned account. Exact-target session revocation remains separately tracked work; these snapshots do not perform either mutation.

Reset an owned account's factors

action.oauth42_user_mfa_reset explicitly resets TOTP, email and phone factors for an active account whose global profile is owned by your current tenant. Use an Authenticator-approved human profile with read admin offline_access and provider scopes ["read", "admin"]. The backend must advertise tenant-user-mfa-reset-atomic-v2. Machine credentials, ordinary tenant members and a current administrator's read-only consent cannot perform this action.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_management_context" "human" {}

# Select an existing active account explicitly owned by this tenant.
action "oauth42_user_mfa_reset" "selected" {
  config {
    user_id = "33333333-3333-4333-8333-333333333333"
    customer_id = "22222222-2222-4222-8222-222222222222"
  }
}
terraform validate
terraform apply -invoke=action.oauth42_user_mfa_reset.selected

The action requires the exact target user_id and current customer_id. The target must be a current active member and have explicit global profile ownership by that tenant. Secondary tenant membership cannot authorize a global reset. A missing target, relinquished profile ownership, foreign account, removed administrator role or revoked device consent fails closed. Human login never grants an administrator role.

Complete primary authentication and an independent allowed factor within five minutes of invocation. Enrollment alone is insufficient. Refreshing a token does not renew authentication proof. Current factor validity, tenant policy and administrator authority remain mandatory, including after target and audit waits. Deferred audit constraints finish before the final proof-expiry check.

Success removes TOTP (including its recovery codes), email and phone factors and their pending codes, then invalidates the target account's existing credentials and sessions globally. Native O42 Authenticator approval keys and passkeys are preserved. Other accounts and the administering account remain usable unless you explicitly reset your own account. Self-reset revokes the credential invoking Terraform too.

Both mandatory audits, exact factor deletion and global credential revocation commit in one transaction. The response must confirm the original actor, exact target, tenant and affected methods. A failed audit rolls everything back. There is no password or factor-secret input, credential output, import, state restoration or enrollment replacement. Run one reset action alone; do not attach it to resource lifecycle triggers. The provider never retries an uncertain result or performs a post-reset read. Obtain independent current credentials to inspect the account before deciding whether to explicitly invoke again.

Reset does not enroll a replacement factor or remove preserved passkeys/native keys. Plan the account's next sign-in and recovery before invoking it. Protect configuration and plans containing target identifiers. The older tenant-user-mfa-reset-fresh-v1 contract does not provide the atomic typed confirmation required by this action.

Invite an explicitly owned tenant user

oauth42_user_invitation sends one email invitation to an existing active, unverified user explicitly owned by the configured tenant. Required user_id is the canonical UUID. A secondary membership is insufficient; already verified users use ordinary password recovery. The backend must advertise tenant-user-invitations-v1, including migration 041. Older servers are rejected before sending any email.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["write"]
}
resource "oauth42_user_invitation" "onboarding" {
  user_id = "22222222-2222-2222-2222-222222222222"
}
output "invitation_status" {
  value = oauth42_user_invitation.onboarding.status
}

Use current tenant-wide write or admin scope for create and destroy; read-only refresh accepts read, write or admin. Optional application_url is an HTTPS hint without embedded credentials. It grants no application access. Optional revision is an operator-controlled string: changing it deliberately replaces the request and sends another invitation. Changing the target or hint also requires replacement. Avoid create_before_destroy; a new invitation intentionally invalidates older unused proofs for the same user.

Computed fields are id, customer_id, created_by_principal_id, status, delivery_status, created_at, expires_at and nullable delivered_at, used_at, revoked_at. The mailed bearer, token hash, email and password never enter this resource’s state. Treat user identifiers and audit metadata as private and protect state accordingly.

Observed status is pending, delivered, failed, used, revoked, expired or unavailable. Delivery status records the historical mail outcome; delivery alone does not guarantee a currently usable proof. Current issuer revocation, changed target email/password/ownership, removal or inactivity invalidate the invitation. Failed mail remains an unusable tombstone, with a Terraform warning; fix the underlying problem and explicitly replace the resource to retry.

Refresh, import and terminal status never send mail or recreate access. Import with the existing target configured and omit creation-only revision/application_url unless deliberate replacement is intended:

terraform import oauth42_user_invitation.onboarding CUSTOMER_UUID/INVITATION_UUID

Destroy revokes only an unused invitation. It preserves the identity, verified email and historical audit rows. Used proofs remain used. Accepting the mailed link verifies that exact email and sets the initial password once; it neither signs the user in nor completes MFA. The user then follows ordinary application sign-in and its configured passkey, O42 push or permitted email factor policy. Platform administrator and company-owner bootstrap invitations remain separate API work.

List all active tenant members

data.oauth42_tenant_members returns customer_id and a sensitive tenant_members list, sorted by user UUID. Each member has id, email, nullable first_name/last_name, is_active, and created_at. This includes active secondary tenant memberships. The primary-customer data.oauth42_users catalog has different semantics and also includes inactive identities.

This data source requires a current tenant-wide service account with read or admin scope. The corrected API checks that authority on each page, so no additional self-account preflight is needed. The provider fetches all pages automatically. Each page has a consistent database snapshot and a stable UUID tie-breaker. Concurrent membership changes between pages can move rows; detected total-count changes, duplicates or incomplete pages fail the read and require a retry. This is not a snapshot spanning every page.

This data source requires the pagination fix tracked in #681. Older backends return repeated default pages, which the provider rejects. Reading or destroying this data source never grants membership, activates an identity or changes a profile.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["read"]
}
data "oauth42_tenant_members" "active" {}
output "active_member_ids" {
  value     = [for member in data.oauth42_tenant_members.active.tenant_members : member.id]
  sensitive = true
}

Inspect existing applications

Application reads require current read or admin scope and tenant-wide authority or a current grant for the exact application. A scoped catalog contains only assigned applications. Application creation, configuration, explicit credential lifecycle and direct assignment resources are available below.

  • data.oauth42_applications returns customer_id and applications, sorted by UUID. Optional include_deleted defaults to false; true includes inactive or soft-deleted records.
  • data.oauth42_application takes an application id and returns its complete configuration, including inactive records. A missing, unauthorized or foreign-tenant ID is an error.
  • data.oauth42_application_users takes application_id and returns customer_id plus a sensitive users list containing ID, email, nullable first/last names and active status.
  • data.oauth42_application_groups takes application_id and returns customer_id plus assigned groups: ID, name, nullable description and SCIM-managed status. This assignment inventory includes SCIM-managed groups without changing their ownership.

Application metadata includes id, customer_id, organization_id, client_id, credential_version, grant_types/response_types, logo_uri/client_uri/policy_uri/tos_uri, name, nullable description, sets of redirect_uris/scopes/default_group_ids, is_first_party, is_active, is_public, allow_signup, access_control, timestamps created_at/updated_at, and nullable owner_name/owner_email. Owner email is sensitive. No client secret or private signing key is returned. An absent organization or URI is represented by an empty string.

Nullable security_settings reports mfa_enforcement, email_otp_login_enabled, dpop_bound_access_tokens, token_endpoint_auth_method, require_pushed_authorization_requests, and public jwks.keys entries with kty, crv, x, y and kid. The optional email_second_factor_enabled read field depends on the unmerged backend work in PR #679. A null policy field means the API did not return it; it does not mean the policy is disabled.

The matching backend independently enforces typed machine authority, current application assignments, tenant-wide boundaries and scope revocation. Use the tested backend revision recorded with your provider build.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
data "oauth42_applications" "active" {}
data "oauth42_application" "existing" {
  id = "44444444-4444-4444-4444-444444444444"
}
data "oauth42_application_users" "assigned" {
  application_id = data.oauth42_application.existing.id
}
data "oauth42_application_groups" "assigned" {
  application_id = data.oauth42_application.existing.id
}

output "application_client_id" {
  value = data.oauth42_application.existing.client_id
}

Manage applications and credentials

oauth42_application requires a name and a nonempty set of absolute redirect_uris. Creation requires a current tenant-wide actor with read plus write, or admin scope. Existing applications can be managed by a current actor assigned to that exact application. Rotation, restoration and deletion require admin scope. The example uses an independent tenant-wide admin service account.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_application" "web" {
  name          = "Terraform managed web application"
  description   = "Example registration managed by Terraform"
  redirect_uris = ["https://app.example.com/auth/callback"]
  scopes        = ["openid", "profile", "email"]
  grant_types   = ["authorization_code", "refresh_token"]
  response_types = ["code"]
  access_control = "restricted"
  allow_signup   = false
  security_settings = {
    mfa_enforcement             = "required"
    email_second_factor_enabled = false
  }
}
data "oauth42_application" "current" {
  id = oauth42_application.web.id
}
output "application_client_id" {
  value = oauth42_application.web.client_id
}
output "application_client_secret" {
  value     = oauth42_application.web.client_secret
  sensitive = true
}

Mutable configuration includes name, description, redirect_uris, scopes, is_first_party, is_public, allow_signup, access_control, default_group_ids and the registered security policy. An empty description clears it; an empty default-group set clears signup grants. Default groups must be ordinary groups in this tenant. is_public controls external-user access; it does not convert a confidential OAuth client into a public client.

Creation-only organization_id, grant_types, response_types, logo_uri, client_uri, policy_uri and tos_uri changes replace the application and its credentials. Organization and URI fields default to empty strings; grants default to authorization_code and refresh_token, responses to code. Scopes default to openid, profile and email; flags default to false, access control to all_users, and signup groups to an empty set. Review replacement plans and coordinate dependent clients before applying.

security_settings supports mfa_enforcement (optional, required or disabled), email_otp_login_enabled, email_second_factor_enabled, dpop_bound_access_tokens, require_pushed_authorization_requests, token_endpoint_auth_method and pinned public jwks.keys. Client authentication methods and public ES256 keys must satisfy backend policy. Keys expose only kty, crv, x, y and kid. Omitted policy fields retain their current server policy; removing a field does not silently disable a safeguard. Application settings cannot override stronger tenant requirements.

The resource reports its application id, customer_id, public client_id, observed is_active, creation/update timestamps and opaque credential_version. Creation returns a one-time client_secret, stored as sensitive Terraform state. Import cannot recover it. External rotation clears a stale secret; it never pairs the old secret with a new version. Protect the entire state and any saved plans, and never publish credential outputs or state files.

Lifecycle requests are explicit and run only when the action/revision pair changes. Set lifecycle_action to rotate, restore or deactivate and supply a nonempty lifecycle_revision of at most 128 characters. Changing the revision requests that action again; unchanged plans do not repeat it. Leave both empty for no lifecycle request. Restore rotates the credential only when the application is inactive; an already-active application satisfies that request without another rotation. Rotation requires an active application. External deactivation never automatically triggers restoration.

lifecycle_action   = "rotate"
lifecycle_revision = "credential-change-2026-11-05"

Place these two attributes inside the application resource for a deliberate rotation. To restore, change the action to restore and use a new revision. The returned secret and version are captured together before any follow-up read. Refresh and profile edits remain available while inactive. An initial deactivate request creates both application and client inactive. Review a failed plan before retrying: creation commits the requested security and access policy with the identity and credential in one transaction. Invalid policy or audit failure creates nothing. A later read interrupted by revocation retains the protected identity and one-time credential for explicit recovery or cleanup.

on_destroy defaults to deactivate: Terraform removes its state entry after revoking the application/client, while the inactive identity and grants remain available for explicit reimport/restoration. Set on_destroy = "permanent" deliberately to deactivate and permanently remove the application, client and associated grants. Typed audit history survives either choice. Other objects referencing the application UUID should use Terraform references so their lifecycle order is explicit.

terraform import oauth42_application.web APPLICATION_UUID

Before importing, match the existing registration in configuration and leave lifecycle requests empty. Import preserves inactive status and never restores or rotates credentials. Current grant removal, scope revocation and changed tenant configuration remain errors rather than false deletion. This resource requires application-lifecycle-audit-v2, application-credential-response-v1, application-policy-update-v1 and application-atomic-create-v1; older backends fail before lifecycle mutation.

Manage direct application assignments

oauth42_application_user requires application_id and user_id; oauth42_application_group requires application_id and group_id. Both return the owning customer_id and composite id. These are additive resources: unrelated assignments remain unchanged. Changing either identifier replaces that assignment.

Creation needs read plus write, or admin scope, and an active application. Removal needs admin scope. A current assignment to the exact application is sufficient for a scoped acting service account; creating the example’s ordinary group still requires tenant-wide authority. The target user/group must belong to the application’s tenant. No human creator permissions are inherited.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_group" "team" {
  name = "Application team"
}
resource "oauth42_application_group" "team" {
  application_id = "44444444-4444-4444-4444-444444444444"
  group_id       = oauth42_group.team.id
}
resource "oauth42_application_user" "member" {
  application_id = "44444444-4444-4444-4444-444444444444"
  user_id        = "22222222-2222-2222-2222-222222222222"
}
data "oauth42_application_groups" "assigned" {
  application_id = "44444444-4444-4444-4444-444444444444"
  depends_on     = [oauth42_application_group.team]
}

Import either resource using APPLICATION_UUID/TARGET_UUID. Refresh detects a removed grant and plans its deliberate recreation. Destroy removes only that grant. Inactive application assignments remain readable and removable. Terraform never restores an application merely to manage a grant, and it refuses new assignments to an inactive parent.

Current scope removal, actor deletion and removed application grants stop subsequent requests and preserve existing state on authorization errors. If a scoped actor loses its target grant because the application itself was permanently deleted, use an appropriately authorized tenant-wide actor to verify deletion; a permission failure is not evidence that the resource disappeared.

These resources and updated application data sources require the application-lifecycle-audit-v2 backend capability. Older backends are rejected before assignment mutation. An interrupted post-write check retains the deterministic identity in failed-apply state so a successful grant is not orphaned; correct the reported error and refresh before retrying.

Inspect OAuth client registrations

data.oauth42_oauth_client takes the public OAuth client_id, which is different from an application UUID. data.oauth42_oauth_clients lists active registrations in clients, sorted by client ID. Both require current tenant-wide authority with read or admin scope and return the configured customer_id.

Each registration contains client_id, client_type (public or confidential), name, nullable description, and sets of redirect_uris, grant_types, response_types and scopes. Nullable management_access reports none, tenant or application; management_application_id pins application-owned credentials to that application. Older backends may omit both fields, which is unknown authority, not permission. Standalone tenant-management access requires an explicit current tenant-wide administrator grant; legacy unknown or orphaned clients do not gain authority during migration. Application credentials never become tenant-wide when a parent disappears. Service-account clients report none in this field; their own live service-account grants govern access. Provider authentication uses explicit service-account credentials or the approved human mode described above. Inactive registrations are excluded from the list and fail a detail lookup. Client secrets and private keys are never returned. These data sources observe registration changes; they do not create, update, delete or rotate credentials.

Completed backends also report registration_id (the database UUID), credential_version, is_active, logo_uri, client_uri, policy_uri, tos_uri, owner_id, created_by_principal_id, application_id, service_account_id, created_at and updated_at. Nullable legacy timestamps and human ownership are preserved. Older backends may omit optional metadata; unknown values are not inferred. Client authentication type is required, so upgrade a backend that omits it.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}

provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}

data "oauth42_oauth_clients" "active" {}
data "oauth42_oauth_client" "existing" {
  client_id = "your-existing-client-id"
}

output "allowed_grants" {
  value = data.oauth42_oauth_client.existing.grant_types
}

Manage standalone OAuth clients

oauth42_oauth_client manages registrations created independently of an O42 application or service account. Use their owning resources for application/service-account credentials; importing those credentials here is refused. A standalone registration does not create application access policy, user/group assignments or service-account identity.

Required inputs are name and explicit sets of redirect_uris, grant_types, response_types and scopes. Name, description, redirect URIs and scopes are mutable. description defaults to an empty string, which clears it. Grant/response types and optional creation-only logo_uri, client_uri, policy_uri and tos_uri changes replace identity and leave the predecessor inactive.

management_access defaults to none. Setting tenant explicitly delegates tenant-management authority and requires a current tenant-wide administrator; revoking it also requires that authority. Creation and ordinary configuration changes need read plus write, or admin scope. Rotation and destruction require admin. Every request checks current scopes, tenant-wide status and the expected customer; the provider never uses a creator’s privileges.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_oauth_client" "web" {
  name              = "Standalone web registration"
  description       = "Managed independently from O42 application policy"
  redirect_uris     = ["https://example.test/oauth/callback"]
  grant_types       = ["authorization_code", "refresh_token"]
  response_types    = ["code"]
  scopes            = ["openid", "profile", "email"]
  management_access = "none"
  rotation_revision = "registration-2026-11-05"
}
output "web_client_secret" {
  value     = oauth42_oauth_client.web.client_secret
  sensitive = true
}

The resource returns id and client_id as the public OAuth identifier, plus registration_id, customer_id, owner_id, created_by_principal_id, nullable creation/update timestamps and observed is_active. For confidential clients, the one-time client_secret and atomic credential_version are saved together. Public clients return a null secret. Protect Terraform state and saved plans; sensitivity hides display but does not encrypt storage.

For a confidential client, change a nonempty rotation_revision of at most 128 characters to rotate it once. Creation records the revision without issuing a second secret. Clearing a revision, an unchanged plan, refresh and import never rotate. Import cannot recover a secret; external rotation clears stale state credentials. Successful credential state is retained without a separate post-rotation read. If an API response is lost before Terraform receives it, inspect the registration and deliberately recover through import/rotation; do not assume a retry is exactly once.

terraform import oauth42_oauth_client.web PUBLIC_CLIENT_ID

Match the imported registration’s creation-only metadata before applying; a difference requests replacement. Keep rotation_revision empty while adopting an imported registration. Setting a new nonempty revision afterward deliberately requests rotation.

Inactive standalone clients can be imported and observed, but cannot be edited or rotated. External deactivation never triggers restoration. Destroy deactivates the registration and removes routing atomically with audit, preserving an inactive tombstone and attribution. There is no inferred restoration or permanent deletion. Destruction of an already inactive managed registration only removes its Terraform state.

The oauth-client-lifecycle-v1 backend capability is required before creation or lifecycle mutation. Older backends fail before creating credentials. Application/service-account registrations must use their owning lifecycle, while compatible generic API rotation validates the exact active parent and commits both audit histories. Standalone scope delegation cannot exceed the actor’s current effective management grants.

Register a public CLI client

Set client_type = "public" to create a standalone client without a shared secret. The default remains confidential. Client type is immutable: a change requests replacement and deactivates the predecessor. Readback and import preserve the stored type; legacy null types retain confidential semantics.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_oauth_client" "cli" {
  name              = "Approved Terraform CLI"
  client_type       = "public"
  redirect_uris     = []
  grant_types       = ["urn:ietf:params:oauth:grant-type:device_code", "refresh_token"]
  response_types    = []
  scopes            = ["read", "offline_access"]
  management_access = "none"
}
output "registered_public_client_id" {
  value = oauth42_oauth_client.cli.client_id
}

A device-only client may use empty redirect URI and response-type sets. Public browser clients instead register authorization_code, response_types = ["code"] and exact redirect URIs; authorization codes require PKCE. Optional refresh_token permits the grant type, while human refresh still requires explicit offline_access consent. Public clients cannot register password, implicit or client-credentials grants.

Keep management_access = "none" and rotation_revision empty. Public clients cannot obtain machine management authority, return a client secret, or rotate one. A human grant derives from the approving account's current authority, selected tenant, resource and exact approved scopes. Registration never adds a user role or trusts the client for management by itself.

After creation, the deployment operator must explicitly add the returned client ID to trusted management client IDs before the login helper can use it. Register only the scopes you intend to request. This example registers read access and optional refresh; a different scope set needs an explicit registration update and separate human approval. The backend must expose public-client-registration-v1; older backends are refused before creation.

Scheduled permission lifecycle

oauth42_permission_automation manages a bounded lease on ordinary group memberships. Set a name, explicit start and expiry, and nonempty sets of current tenant user and group UUIDs. Use lowercase UUIDs, up to 100 users and 100 groups, and at most 1,000 combinations. Names allow 255 characters; the optional description defaults to an empty string and allows 1,000. SCIM-managed and portal/platform authority groups are excluded.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_permission_automation" "window" {
  name        = "Temporary access window"
  description = "Bounded ordinary-group access"
  user_ids    = ["22222222-2222-2222-2222-222222222222"]
  group_ids   = ["33333333-3333-3333-3333-333333333333"]
  starts_at   = "2099-01-01T00:00:00Z"
  expires_at  = "2099-01-02T00:00:00Z"
  cancel_requested = false
}

Replace the example dates with your intended access window. Both timestamps use RFC3339 with at most microsecond precision; equivalent UTC offsets have the same meaning. Creation and pending updates require a future expiry after the start. A start in the past activates immediately. Avoid rolling timestamp() expressions: use explicit reviewed deadlines. Expiry and external cancellation are observed without automatic renewal.

Pending schedules permit configuration updates. Changing the configuration of an active, cancelled or expired schedule plans replacement. Set cancel_requested = true on an existing schedule to cancel its lease; do this separately from configuration edits. Creating with cancellation already requested is rejected. Clearing a previously applied cancellation request deliberately replaces the identity. The computed status remains distinct from this command intent.

Destroy cancels pending/active schedules and removes their definitions while preserving audit records, other schedules and independent ordinary grants. Explicit membership revocation is never reversed by an already active job. Do not adopt scheduled access as a permanent membership resource unless you intend to create an independent grant.

Full lifecycle requires a current tenant-wide service account with explicit admin scope; read plus write supports creation, editing and cancellation, but deletion requires admin. Every operation checks live authority. The backend must advertise permission-automation-ownership-v1; older backends fail before mutation. Never grant machines a human creator identity. Existing active schedules need the reviewed ownership migration described below before upgrading.

terraform import oauth42_permission_automation.window CUSTOMER_UUID/AUTOMATION_UUID

Import binds the exact tenant and existing schedule without activation or cancellation. Configure its observed targets and deadlines, keep cancel_requested = false, and review the plan. Import cannot reconstruct earlier cancellation command intent. A timestamp representation change can produce a state-only update plan; applying it does not edit or renew the remote schedule. Computed attributes include ID, tenant, status, timestamps, nullable human creator/canceller, typed creator/canceller/current authorizer and cancellation reason, as listed in the metadata section. User IDs are sensitive Terraform state; protect plans and state storage.

If creation times out after the backend commits, inspect the schedule inventory and import the confirmed identity before retrying. Names are not unique adoption keys; the provider does not guess which remote schedule belongs to a failed request. Cancellation/expiry can race a pending update; refresh and review the resulting terminal status instead of assuming it can be renewed.

Inspect scheduled permissions

data.oauth42_permission_automation takes an existing automation id. data.oauth42_permission_automations returns customer_id and an automations list sorted by UUID, optionally filtered by status: pending, active, expired or cancelled. Omit the filter to include every status. These reads require a current tenant-wide account with explicit read or admin scope.

Each record includes id, name, nullable description, customer_id, nullable historical human created_by, ordered user_ids/group_ids lists, starts_at, expires_at, status, created_at and updated_at. Optional audit fields are activated_at, expired_at, cancelled_at and cancelled_by. Newer backends also expose nullable created_by_principal_id, cancelled_by_principal_id, authorizing_principal_id and cancellation_reason. Typed principals distinguish human, service-account and standalone-client actors; a historical actor is not a current permission grant. Machine-created schedules have no fabricated human creator. User identifiers are sensitive state; protect saved state and derived outputs.

Refresh observes changes made by authorized operators or the scheduler. Removing a data source from state does not cancel its schedule or change group membership. The backend upgrade tracks exact membership leases, preserves independent grants, checks current authority before deferred activation and commits audit with each transition. Expired leases stop authorizing access even if cleanup is delayed. Existing active schedules require a reviewed ownership migration; missing or stale decisions stop the migration instead of guessing. Do not model a scheduled membership by importing it as an ordinary permanent membership.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}

provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}

data "oauth42_permission_automations" "pending" {
  status = "pending"
}

data "oauth42_permission_automation" "existing" {
  id = "55555555-5555-5555-5555-555555555555"
}

output "scheduled_user_ids" {
  value     = data.oauth42_permission_automation.existing.user_ids
  sensitive = true
}

Read public server metadata without credentials

data.oauth42_public_metadata reads one fixed public API document. Set document to openid_configuration, jwks, features, billing_tiers, health, branding, social_providers, scim_service_provider_config, scim_schemas, or scim_resource_types. Branding and social-provider availability require client_id, identifying an existing application. Social availability reports enabled provider names without external client credentials.

The computed document_json preserves all public response fields. Use jsondecode to select the fields your configuration needs. This data source sends no credentials, never follows returned URLs, and cannot call an arbitrary endpoint. TLS verification and redirect refusal still apply. Refresh reads the current document; a health endpoint returning a failure status is an error.

For a configuration that only needs these documents, set metadata_only = true. Omit customer_id, scopes, client_id, and client_secret from the provider block. Credential environment variables are ignored in this mode, and all private data sources and resource operations are refused. In the default authenticated mode, the expected tenant, explicit scopes, and credentials remain required; public metadata reads still send no credentials.

Public discovery is not proof of tenant access or an authorization grant. SCIM capability/schema documents do not authorize SCIM user or group provisioning. Use the authenticated organization SCIM context and the implemented SCIM user and SCIM group resources for provisioning. Their data requests enforce the current token, exact tenant/organization binding and scopes independently of public discovery.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}

provider "oauth42" {
  endpoint      = "https://api.example.com"
  metadata_only = true
}

data "oauth42_public_metadata" "server" {
  for_each = toset([
    "openid_configuration", "jwks", "features", "billing_tiers", "health",
    "scim_service_provider_config", "scim_schemas", "scim_resource_types"
  ])
  document = each.value
}

data "oauth42_public_metadata" "branding" {
  document  = "branding"
  client_id = "your-existing-client-id"
}

output "issuer" {
  value = jsondecode(data.oauth42_public_metadata.server["openid_configuration"].document_json).issuer
}

data "oauth42_public_metadata" "social" {
  document  = "social_providers"
  client_id = "your-existing-client-id"
}

Configure application login branding

oauth42_application_branding manages an existing application's hosted presentation settings. Use its application UUID, current admin scope, and either the exact application assignment or tenant-wide authority. Reads accept read or admin with the same current grant. The backend must advertise application-branding-management-v1. Import/read do not write. Create/update replace the supplied hosted settings with mandatory typed audit and an observed configuration version.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_application_branding" "login" {
  application_id = "22222222-2222-2222-2222-222222222222"
  hosted_auth_settings_json = jsonencode({
    theme         = "dark"
    primary_color = "#123456"
    features = {
      signup_enabled = false
      social_login_enabled = true
    }
    session_timeout_minutes = 15
  })
}
data "oauth42_application_branding" "login" {
  application_id = oauth42_application_branding.login.application_id
  depends_on = [oauth42_application_branding.login]
}

Required application_id identifies the application and requires replacement when changed. Required hosted_auth_settings_json is a complete JSON object, bounded to 64 KiB. Omit unset fields instead of using null. Object order and whitespace do not create drift. An explicit empty object resets hosted presentation defaults. Existing unknown legacy settings remain visible on read; review their removal when adopting a configuration containing the supported fields.

  • theme: light, dark or auto. primary_color and accent_color: six-digit hexadecimal colors with a leading #.
  • logo_url: HTTPS URL, at most 2,048 bytes, without embedded credentials or fragments. custom_css_url follows those limits and requires the managed oauth42.com or cdn.oauth42.com HTTPS origin without a custom port, matching the sign-in renderer's trust boundary.
  • features: optional boolean signup_enabled, password_reset_enabled, social_login_enabled, remember_me_enabled and email_otp_login_enabled. These configure presentation; effective tenant/application authorization still applies.
  • password_requirements: min_length from 8 through 128. Deprecated require_uppercase, require_lowercase, require_numbers and require_special must remain false. session_timeout_minutes is 5 through 60.

Readback includes id (application UUID), customer_id, oauth_client_id, client_id, configuration_version, updated_at and the complete current security_settings_json. Manage registered sign-in/client policy through oauth42_application.security_settings; branding writes preserve it. The opaque version changes for outside branding or security-policy edits, so stale writes fail instead of overwriting them. Refresh and review a new plan after a conflict. Stronger tenant policy remains effective.

Import with terraform import oauth42_application_branding.login APPLICATION_UUID. Configure only one branding resource per application. Destroy only removes Terraform ownership and preserves remote branding and security policy; use an explicit empty hosted-settings object before detaching if you intend to reset presentation. Inactive applications remain readable, but cannot accept branding writes. data.oauth42_application_branding takes application_id and returns the same complete stored metadata, normalizing absent hosted settings to an empty object. Public rendered branding may include defaults and stronger tenant policy; use the public metadata data source for that effective view.

Provision a downstream directory with outbound SCIM

Outbound SCIM sends an application's assigned identities to another directory. It is separate from organization SCIM tokens that provision identities into O42. Configure an OAuth service account with current tenant-wide admin scope. Application-only grants are insufficient. The backend must advertise outbound-scim-management-v1; the provider refuses older unsafe contracts before sending credentials.

oauth42_scim_outbound_provider requires application_id, name and a public HTTPS base_url without user information, query or fragment. TLS is verified and redirects are refused. Creation also requires auth_token_wo. Supply it through an ephemeral sensitive variable from your secret manager. The write-only value is absent from plans and state. Increase credential_revision to rotate it; changing only the secret does not schedule a write. Metadata changes preserve the existing token. Remote credential versions reveal outside rotation without recovering or replaying the secret.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
variable "scim_auth_token" {
  type      = string
  sensitive = true
  ephemeral = true
}
resource "oauth42_scim_outbound_provider" "directory" {
  application_id      = "22222222-2222-2222-2222-222222222222"
  name                = "Downstream directory"
  base_url            = "https://directory.example.com/scim/v2"
  auth_token_wo       = var.scim_auth_token
  credential_revision = 0
  is_active           = false
  sync_users          = true
  sync_groups         = true
  attribute_mapping   = { displayName = "first_name" }
}
data "oauth42_scim_outbound_provider" "directory" {
  id = oauth42_scim_outbound_provider.directory.id
  depends_on = [oauth42_scim_outbound_provider.directory]
}
data "oauth42_scim_outbound_providers" "all" {
  depends_on = [oauth42_scim_outbound_provider.directory]
}
data "oauth42_scim_outbound_validation" "directory" {
  provider_id = oauth42_scim_outbound_provider.directory.id
  depends_on = [oauth42_scim_outbound_provider.directory]
}
data "oauth42_scim_outbound_logs" "recent" {
  provider_id = oauth42_scim_outbound_provider.directory.id
  limit       = 50
  depends_on = [oauth42_scim_outbound_provider.directory]
}
action "oauth42_scim_outbound_sync" "directory" {
  config {
    provider_id    = oauth42_scim_outbound_provider.directory.id
    sync_type      = "delta"
    resource_types = ["User", "Group"]
  }
}

New configuration defaults to inactive, with user and group delivery enabled. Explicit is_active, sync_users and sync_groups control delivery. Omitted values preserve imported configuration. attribute_mapping maps userName, displayName, name.givenName or name.familyName to email, first_name or last_name. Empty mapping restores defaults; identity, activity and membership cannot be overridden. Legacy unsupported mappings remain readable as JSON but must be remediated before resource management.

Import with terraform import oauth42_scim_outbound_provider.directory PROVIDER_UUID. Import starts the local rotation counter at zero and never recovers a token. Readback includes tenant/application IDs, all configuration fields, has_token, opaque credential/configuration versions, timestamps and nullable last_full_sync_at. Conditional writes reject concurrent edits. Refresh and review before retrying. Application or destination changes replace configuration; existing downstream identities are never rebound to another server. Destroy removes the configuration and stops future delivery, but does not delete previously provisioned remote identities. Plan downstream cleanup separately before destruction.

data.oauth42_scim_outbound_provider reads one required id. data.oauth42_scim_outbound_providers returns the complete providers catalog and total. Both return redacted configuration, including attribute_mapping_json. data.oauth42_scim_outbound_validation takes provider_id and performs an audited, credential-bearing HTTPS ServiceProviderConfig check on refresh, even while staged inactive. Inspect status, message and nullable http_status; HTTP 200 alone is not sufficient. This check does not provision users.

After checking the destination and assignments, set is_active = true and apply. Ordinary application assignment changes can then trigger configured provisioning. For an explicit reconciliation, invoke terraform apply -invoke=action.oauth42_scim_outbound_sync.directory. The action takes provider_id, sync_type (full or delta), and an explicit set of User and/or Group. Full reconciliation sends current assignments; delta skips successfully delivered unchanged payloads. Groups reference downstream IDs from this same provider: include both types, or synchronize users before groups. Unassigned users are deactivated and removed groups deleted only through this provider's existing remote mappings.

The action reports its job UUID and waits for actual success or failure. Acceptance/queueing is not completion. Jobs are bounded to five minutes and recheck the initiating actor, token, current grants, provider configuration and tenant before each delivery. Revocation, expiry or configuration changes stop remaining delivery. Interrupting Terraform stops waiting; inspect the bounded job before retrying. An interrupted or failed remote request can have an uncertain downstream outcome; review logs and remote state before rerunning. Failed manual jobs require an explicit retry and do not silently schedule automatic retries.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
data "oauth42_scim_outbound_job" "completed" {
  provider_id = "22222222-2222-2222-2222-222222222222"
  id          = "33333333-3333-3333-3333-333333333333"
}

data.oauth42_scim_outbound_job requires the exact provider and job UUIDs and returns tenant, status, sync type, selected resources, message, deadline and timestamps. Only succeeded and failed are terminal. data.oauth42_scim_outbound_logs takes provider_id, optional limit (1–100, default 50) and an opaque cursor. It returns one bounded page of sensitive entries and nullable next_cursor, not a full history export. Entries include resource/local IDs, operation, nullable HTTP status/duration/error, and creation time; upstream bodies and credentials are excluded. Keep state encrypted and access-controlled.

Application social credentials and platform providers

These resources require application-social-providers-v1. Use a current service account with admin and either the exact application assignment or tenant-wide authority. Reads accept read or admin with the same current application grant. Revoking the account, scope, application assignment or tenant stops access. A machine actor never inherits its human creator's permissions. These resources configure login trust; they do not perform social sign-in or manage global platform credentials.

oauth42_application_social_provider manages custom credentials for immutable application_id and provider_name. Providers are google, apple, twitter, linkedin, github, gitlab, facebook, discord and slack. Required client_id is the external provider's public client identifier. enabled defaults to true. Optional scopes uses backend defaults at creation when omitted; an explicit empty set remains empty. Apple also requires the 10-character team_id and key_id, with its private .p8 key supplied as the write-only secret.

Social secrets are write-only. Supply client_secret_wo through a sensitive, ephemeral variable from your secret manager. It never enters Terraform plans or state. It is required on creation and when you increase the nonnegative secret_revision counter, which defaults to zero. Changing only the secret does not schedule a change. Metadata updates preserve the stored secret. Import initializes revision zero without recovering or rotating credentials; retain the current revision in configuration after rotation. Decreasing it fails. Never put secret values in committed files, shell history or command-line arguments.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
variable "social_client_secret" {
  type      = string
  sensitive = true
  ephemeral = true
}
resource "oauth42_application_social_provider" "google" {
  application_id  = "22222222-2222-2222-2222-222222222222"
  provider_name   = "google"
  client_id       = "external-google-client"
  client_secret_wo = var.social_client_secret
  secret_revision = 0
  enabled         = true
  scopes          = ["openid", "email"]
}
data "oauth42_application_social_provider" "google" {
  application_id = oauth42_application_social_provider.google.application_id
  provider_name  = oauth42_application_social_provider.google.provider_name
  depends_on     = [oauth42_application_social_provider.google]
}
data "oauth42_application_social_providers" "all" {
  application_id = oauth42_application_social_provider.google.application_id
  depends_on     = [oauth42_application_social_provider.google]
}

Creation refuses to adopt existing custom or platform trust. Import existing custom configuration with terraform import oauth42_application_social_provider.google APPLICATION_UUID/google. Readback includes id (application/provider), customer_id, configuration_id, configuration_version, credential_version, has_credential, timestamps and all configurable metadata. Opaque credential versions report external rotation without recovering or replaying a secret. Updates and deletes require the observed configuration version; a concurrent change fails rather than overwriting it. Refresh and review the new plan before retrying.

Destroy removes custom login trust. Keep another authorized sign-in path. If an external change replaces the custom configuration with a platform selection, refresh reports a mode conflict; explicitly resolve ownership before proceeding. Terraform does not erase a platform replacement as though it were the old custom credential. Configuration changes and deletions commit atomically with redacted typed-actor audit records; neither plaintext nor encrypted credential contents enter those audit records.

oauth42_application_platform_provider manages whether an application selects an already configured global platform provider. It accepts immutable application_id/provider_name and enabled (default true). Enable requires current global availability and refuses to replace custom credentials. A false value means no platform selection; it does not disable or delete custom credentials. Destroy removes only a platform selection, even when the global provider is no longer available. Import APPLICATION_UUID/PROVIDER reads the current selection without modifying it, including a disabled/absent selection. Creation can reconcile an existing platform selection; custom credential trust always needs explicit import or migration.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
resource "oauth42_application_platform_provider" "github" {
  application_id = "22222222-2222-2222-2222-222222222222"
  provider_name  = "github"
  enabled        = true
}
data "oauth42_application_platform_providers" "selected" {
  application_id = oauth42_application_platform_provider.github.application_id
  depends_on     = [oauth42_application_platform_provider.github]
}

Platform resource outputs include id, customer_id, nullable configuration_id/configuration_version, nullable platform_available and timestamps. These metadata fields are null when no platform selection exists. Platform secrets are never read or stored by this resource.

data.oauth42_application_social_provider takes application/provider and returns one complete redacted configuration; absence is an error. data.oauth42_application_social_providers takes application and returns all its configured providers. data.oauth42_application_platform_providers returns only selected platform configurations, not the global availability catalog. Both list data sources return id, customer_id, application_id and providers, with an empty list when none exist. Each record includes its configuration UUID as id, tenant/application identity, provider_name, nullable public client/team/key IDs, enabled status, scopes, use_platform_credentials, has_credential, platform_available, opaque versions and timestamps. No data source exposes plaintext or encrypted secrets.

Tenant SAML configuration and validation

oauth42_saml_configuration manages one configuration per tenant using current tenant-wide admin authority and the tenant-saml-management-v1 capability. Existing trust must be imported explicitly with terraform import oauth42_saml_configuration.tenant CUSTOMER_UUID. Creation is subject to the tenant's current SAML entitlement and billing write policy. Service accounts act as themselves and never inherit their creator's human grants.

Required fields are idp_entity_id, idp_sso_url, and the complete public PEM idp_certificate (at most 32 KiB); idp_slo_url is optional. Never supply a private key. sign_requests defaults to true and enabled defaults to false. attribute_mapping is the complete JSON object, defaulting to the API's standard email/first_name/last_name claim URIs; preserve existing extension fields when importing. JSON whitespace and object order do not cause drift, and large integer values keep their precision.

Computed fields are id/customer_id (the tenant UUID), provider_id (the configuration UUID), created_at, updated_at, sp_entity_id, acs_url, sp_slo_url, and metadata_url. require_signed_assertions remains true and allow_idp_initiated remains false. Enabling validates the stored certificate using the same strict signing-certificate profile as SAML login. Changing only enabled uses the dedicated toggle operation. To rotate certificates, obtain the IdP's new public PEM certificate, review and apply its change, then coordinate IdP signing and test an actual login separately.

data.oauth42_saml_configuration returns configured, enabled, tenant identity and service-provider URLs, plus a complete configuration object with the resource's fields. The configuration is null when absent. data.oauth42_saml_validation explicitly requests a read-only server check: on refresh, the backend validates stored certificates and sends a bounded public HTTPS HEAD request to the IdP SSO URL. It returns success, message, optional error, idp_reachable, certificate_valid, and certificate_expires. Details are null when no configuration exists. An unreachable IdP is a result, not a successful SSO assertion; no interactive login is performed. Use Terraform checks for any required readiness condition.

Supply TF_VAR_idp_certificate_pem from the reviewed public certificate. Replace the illustrative .test URLs with your IdP; the example intentionally reports an unreachable IdP. Public certificate rotation and both data sources are exercised by the acceptance suite using this exact example.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint    = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes      = ["admin"]
}
variable "idp_certificate_pem" {
  type        = string
  description = "Public PEM signing certificate from your IdP; never a private key."
}

resource "oauth42_saml_configuration" "tenant" {
  idp_entity_id    = "https://idp.example.test/entity"
  idp_sso_url      = "https://idp.example.test/sso"
  idp_certificate = var.idp_certificate_pem
  enabled         = false
  sign_requests   = true
  attribute_mapping = jsonencode({
    email     = "email"
    first_name = "firstName"
    last_name = "lastName"
    extension = { counter = 9007199254740993 }
  })
}

data "oauth42_saml_configuration" "current" {
  depends_on = [oauth42_saml_configuration.tenant]
}

# Explicitly opt into backend HTTPS reachability/certificate validation.
# The illustrative .test IdP is deliberately not reachable.
data "oauth42_saml_validation" "current" {
  depends_on = [oauth42_saml_configuration.tenant]
}

Destroy deletes SAML configuration. This disables this tenant's SAML login, so retain another authorized administrative sign-in path. Configuration changes and enable/disable/deletion commit with mandatory typed audit records; failed audit rolls back the change. Deleting configuration or retiring its service account preserves historical human and machine audit identities. Import and data sources never change trust, and switching provider tenants cannot move the configuration.

Read public SAML service-provider metadata

data.oauth42_saml_metadata takes the public customer_id of a tenant with an existing SAML configuration. It works with metadata_only = true and sends no credentials. A tenant without SAML configuration returns an error.

Computed fields are the complete metadata_xml, entity_id, assertion_consumer_url, authn_requests_signed, want_assertions_signed, and signing_certificates as a list of base64 DER public X.509 certificates. Private keys are never returned. The provider verifies the advertised entity and consumer URL identify the requested customer, rejects XML directives, and never fetches XML entities or advertised URLs.

This observes the current public configuration. A legacy unsigned request configuration remains visibly unsigned; the data source does not enable signing, configure an identity provider, verify a SAML login, or grant tenant access. Treat advertised URLs as configuration to review before using them. Destroying this data source only removes its state.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}

provider "oauth42" {
  endpoint      = "https://api.example.com"
  metadata_only = true
}

data "oauth42_saml_metadata" "existing" {
  customer_id = "11111111-1111-1111-1111-111111111111"
}

output "saml_service_provider_entity_id" {
  value = data.oauth42_saml_metadata.existing.entity_id
}

Manage organizations and exact role assignments

Use an Authenticator-approved human profile for the originally selected tenant, approved read write offline_access consent, provider scopes ["read", "write"] and backend capability organization-lifecycle-v1. Ordinary current tenant membership permits creating a new organization with fresh original independent-factor proof. Explicit grant_initial_organization_admin = true assigns you its initial organization administrator role; it does not promote your tenant role. A parent organization requires current administration of that exact parent.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_organization" "managed" {
  name = "Managed organization"
  slug = "managed-organization"
  description = "Explicit organization lifecycle"
  is_active = true
  grant_initial_organization_admin = true
  max_users = 50
  max_applications = 5
  features = ["oauth2", "sso"]
  additional_settings_json = jsonencode({ precise_counter = 9007199254740993 })
  metadata_json = "{\"precise_decimal\":1.00000000000000000001}"
}

The oauth42_organization resource owns the complete name, description, positive optional user/application limits, ordered feature list, additional-settings JSON object, optional metadata JSON object and explicit active state. Omitted optional settings clear their values; null and an empty feature list remain distinct. Additional settings cannot duplicate the separately managed limit or feature fields. Arbitrary-precision JSON numbers survive PostgreSQL formatting and Terraform refresh without hiding real numeric drift. Sensitive settings and metadata remain in state and saved plans.

Slug and optional parent are immutable creation inputs. Creation returns exact tenant/organization UUIDs, a configuration version and initial user/role/membership receipts. Refresh never restores an initial grant. Updates need current organization administration and a matching reviewed version, and commit configuration with mandatory typed audit. Current SCIM deprovisioning, grant expiry, consent revocation and overdue-payment configuration restrictions remain authoritative. A creator UUID or generic tenant-admin flag alone cannot administer an existing organization.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_organization_management" "reviewed" {
  organization_id = "33333333-3333-4333-8333-333333333333"
}
output "organization_configuration" {
  value = data.oauth42_organization_management.reviewed.configuration_json
  sensitive = true
}

Review existing configuration with data.oauth42_organization_management, then import CUSTOMER_UUID/ORGANIZATION_UUID using its actual settings. Omit unknown historical initial-grant intent; imported initial receipts stay null. Nullable legacy timestamps and creator metadata remain nullable. Inactive organizations can be read and imported under retained actual organization authority. Keep their explicit is_active = false unless deliberately reactivating them.

Destroy deactivates the exact reviewed organization and retains roles, memberships, configuration and history. It never deletes shared users or their tenant memberships. Deactivation and reactivation require fresh original independent-factor proof; reactivation may restore access through retained grants. A stale saved plan, changed original tenant or revoked organization authority fails instead of adopting another target or restoring access. Configure only one owner for each organization.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_organization_member_management" "reviewed" {
  organization_id = "33333333-3333-4333-8333-333333333333"
  membership_id = "44444444-4444-4444-8444-444444444444"
}
output "reviewed_membership" {
  value = data.oauth42_organization_member_management.reviewed
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Copy these exact identities and version from a separately reviewed assignment.
# Invoke explicitly: terraform apply -invoke=action.oauth42_organization_member_remove.reviewed
# A normal apply or destroy never invokes this action.
action "oauth42_organization_member_remove" "reviewed" {
  config {
    organization_id = "33333333-3333-4333-8333-333333333333"
    membership_id = "44444444-4444-4444-8444-444444444444"
    user_id = "55555555-5555-4555-8555-555555555555"
    role_id = "66666666-6666-4666-8666-666666666666"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}

For one-time membership removal, separately review data.oauth42_organization_member_management and manually pin the organization, immutable membership UUID, user UUID, role UUID and configuration version in action.oauth42_organization_member_remove. The server verifies all five identities and the version before deleting the assignment, with current organization authority and atomic audit. Assignment or role changes require a new review. Do not wire an automatically refreshed version into this destructive action.

Normal apply and destroy never invoke the action, and it is never automatically replayed. It removes only that role assignment; other roles can still confer access. Removing your own last administrator role may prevent further management. The user identity, tenant membership and unrelated grants remain. These contracts do not implicitly invite an email address or create a new tenant membership.

Create a new organization user

Use data.oauth42_organization_user_provisioning_review and action.oauth42_organization_user_create to create a new tenant-owned identity together with one explicitly reviewed default organization role. The selected human must currently administer both the tenant and that exact organization. Tenant administration, organization administration and historical creator identity are separate authorities. Tenant-wide machine scope does not grant this human provisioning authority.

Approve read write offline_access, configure scopes = ["read", "write"], and use a backend advertising organization-user-provisioning-v1. Creation requires original primary authentication and an independent factor completed within five minutes; refresh does not renew that proof. Current consent, grants, SCIM restrictions and proof expiry are checked again after lock and audit waits.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_organization_user_provisioning_review" "selected" {
  customer_id     = "22222222-2222-4222-8222-222222222222"
  organization_id = "33333333-3333-4333-8333-333333333333"
}

The review returns exact customer_id, organization_id, role_id, role_name, nullable role_display_name, complete role_configuration_json, nullable max_users, current_users and configuration_version. Capacity counts distinct users with active, unexpired organization roles. Read the role permissions and manually pin the tenant, organization, role and version in the separate action. Capacity is checked again during creation; a default-role or organization configuration change requires a new review.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
variable "organization_user_email" {
  type      = string
  sensitive = true
  default   = "[email protected]"
}
# Review the default role and manually replace these exact observed inputs.
action "oauth42_organization_user_create" "selected" {
  config {
    customer_id                      = "22222222-2222-4222-8222-222222222222"
    organization_id                  = "33333333-3333-4333-8333-333333333333"
    organization_role_id             = "44444444-4444-4444-8444-444444444444"
    configuration_version            = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_create_organization_user = true
    email                            = var.organization_user_email
    username                         = null
    first_name                       = "Example"
    last_name                        = null
    phone                            = null
    is_active                        = true
  }
}

Choose a normalized new email, explicit initial is_active and optional profile values. Omitted profile values become null. An existing active or inactive identity is never adopted, linked or reactivated. The action creates no invitation, activation token or additional group grant, and returns no password or action outputs. Identity, tenant membership, organization role and both typed audits commit together; an audit failure rolls them all back.

terraform apply -invoke=action.oauth42_organization_user_create.selected

Invoke once after review. Do not attach routine lifecycle triggers or automatically retry an uncertain response: inspect the tenant user and organization member inventories first. The retained email cannot be recreated by repeating the action. Use those inventories to find the committed user and exact role-assignment IDs. Later profile import/management, invitation delivery, organization-member removal and tenant-user removal are separate authorized operations. Removing the action from configuration leaves the identity and role intact; removing a role does not delete the identity or its other access.

Invite an existing member to an organization role

The backend must advertise organization-invitations-v1. Use human mode with approved read write offline_access consent, current administration of the exact organization, and fresh independent MFA for creation or revocation. The recipient must already be an active member of the selected tenant. Provisioning an identity, verifying its email and granting tenant membership are separate explicit workflows.

Apply the target review first. Inspect the exact recipient UUID, email and full role configuration, then manually pin its version in the invitation resource. Replace the example deadline with an RFC3339 timestamp within 30 days of creation. Both deadlines use at most microsecond precision; equivalent UTC offsets describe the same instant. An optional role deadline cannot precede the invitation deadline. The invitation cannot overwrite or reactivate an existing assignment of the same role.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_organization_invitation_target" "reviewed" {
  organization_id   = "33333333-3333-4333-8333-333333333333"
  recipient_user_id = "55555555-5555-4555-8555-555555555555"
  role_id           = "77777777-7777-4777-8777-777777777777"
}
output "invitation_target_version" {
  value = data.oauth42_organization_invitation_target.reviewed.configuration_version
}
output "invitation_role_configuration" {
  value     = data.oauth42_organization_invitation_target.reviewed.role_configuration_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Review the exact existing recipient and role with organization_invitation_target.
# Replace the placeholder review hash and email with that reviewed result.
# Replace the date with an explicit deadline within 30 days of creation.
resource "oauth42_organization_invitation" "reviewed" {
  organization_id        = "33333333-3333-4333-8333-333333333333"
  recipient_user_id      = "55555555-5555-4555-8555-555555555555"
  recipient_email        = "[email protected]"
  role_id                = "77777777-7777-4777-8777-777777777777"
  reviewed_target_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  grant_organization_role = true
  expires_at             = "2099-01-02T00:00:00Z"
  role_grant_expires_at   = null
  message                = "Please review this organization role before accepting."
  revision               = "initial-reviewed-request"
}
# Refresh never resends; explicitly replace or change revision for a new request.
# Destroy revokes unused intent and preserves any already accepted role.

Creation sends one email attempt and retains the actual result. ready means the mail server accepted delivery and the intent was activated; it does not guarantee inbox delivery. Failed delivery produces a warning and retained terminal metadata. Refresh and import never resend. After resolving the cause, deliberately change revision or replace the resource to make a new request.

The email link opens a review step. The recipient signs in with the exact invited identity, selects an existing membership in the invitation tenant, reviews the role and explicitly accepts it. Terraform never receives the acceptance token. Acceptance rechecks the original issuer assignment, role configuration, live identity, factor, client, consent, SCIM restrictions and deadline. Revocation or changed authority can make an invitation ineligible before its displayed deadline; a historical creator or newly regranted role does not restore it.

Import a current managed request with terraform import oauth42_organization_invitation.reviewed CUSTOMER_UUID/ORGANIZATION_UUID/INVITATION_UUID. Match the immutable recipient, role, email, message and deadlines; omit revision, reviewed_target_version and grant_organization_role rather than inventing historical intent. Destroy revokes an unused invitation. If it was accepted, its role remains independently managed; use the separately reviewed organization-member removal action to remove that exact assignment.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_organization_invitation" "existing" {
  organization_id = "33333333-3333-4333-8333-333333333333"
  invitation_id   = "88888888-8888-4888-8888-888888888888"
}
output "invitation_metadata" {
  value     = data.oauth42_organization_invitation.existing.metadata_json
  sensitive = true
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_organization_invitations" "page" {
  organization_id = "33333333-3333-4333-8333-333333333333"
  limit           = 20
  offset          = 0
}
output "invitation_page" {
  value     = data.oauth42_organization_invitations.page.metadata_json
  sensitive = true
}

Metadata and bounded pages preserve pending, delivery-failed, accepted, revoked, expired and ineligible requests. Legacy plaintext invitations are retired during migration, with their original history retained and no recipient identity inferred from email. Inspect that history through the data sources; it cannot be imported as a new role-grant request. No bearer or stored authentication evidence appears in these outputs.

Read organizations and member directories

oauth42_organizations, oauth42_organization and oauth42_organization_members read the provider’s exact tenant. Use a dedicated, active, tenant-wide service account with an explicit expiry and read or admin scope. Tenant scope alone grants no organization access: a current human administrator of each organization must approve that exact account and organization.

The administrator must use a current signed-in session with a fresh independent second factor. Password-only sign-in, refresh issuance time, tenant-owner status and a historical creator ID do not substitute for that proof or the current organization-admin role. The approval API is POST /organizations/ORG_ID/read-grants with service_account_id and an RFC3339 expires_at. Approval expires within 365 days and cannot outlive the account. The API returns the approval UUID. The human-authorized organization read-grant resource now manages approval, import, drift and revocation. A machine cannot approve itself.

POST /organizations/ORG_ID/read-grants
Authorization: Bearer HUMAN_SESSION_WITH_FRESH_SECOND_FACTOR
Content-Type: application/json

{
  "service_account_id": "SERVICE_ACCOUNT_UUID",
  "expires_at": "EXPLICIT_FUTURE_RFC3339_TIMESTAMP"
}

Current organization administrators can list approval history at GET /organizations/ORG_ID/read-grants?limit=20&offset=0 and revoke an exact approval with DELETE /organizations/ORG_ID/read-grants/GRANT_ID. Revocation needs current authority but no new factor ceremony; repeated revocation returns 204 without another audit entry. Grants cannot be extended in place or revived: revoke and approve a replacement. Approval creation/revocation and typed audit commit together. Removing the historical grantor’s role does not silently revoke an independent machine approval; revoke that approval explicitly.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
# A current organization administrator must approve each exact organization first.
data "oauth42_organizations" "example" {
  limit = 20
  offset = 0
  # Optional: search and exact organization_id. This is one explicit page.
}

The catalog returns one explicit page of approved active organizations, with total, page, limit and row offset. Limit is 1–100, default 20; offset defaults to zero. Optional search matches name or slug case-insensitively, preserving SQL pattern characters, at most 256 bytes. Optional organization_id narrows authority and results to one exact UUID. No approval yields a denial rather than a misleading empty catalog. More than 1,000 current organization approvals requires the exact organization filter; the API never silently drops approvals. Explicit offset pages are independent current snapshots, not a database-wide export transaction.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_organization" "example" {
  organization_id = "22222222-2222-2222-2222-222222222222"
}

Detail requires organization_id. Sensitive organization contains id, customer_id, name, slug, description, parent_org_id, is_active, created_at, updated_at and created_by. Historical nulls remain null. settings_json and metadata_json preserve custom keys and numeric precision, with normalized key order for stable state; nullable metadata stays null. Settings include current max_users, max_applications and features columns.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_organization_members" "example" {
  organization_id = "22222222-2222-2222-2222-222222222222"
  limit = 20
  offset = 0
  # Optional search matches email/username. Rows are role assignments, not unique users.
}

Members require the exact organization_id and use the same explicit limit/offset bounds; optional search matches email or username. Sensitive members rows represent role assignments, so one user may appear more than once with distinct assignment IDs. Fields are id, user_id, organization_id, email, nullable name, role, role_id, nullable permissions, status, nullable joined_at, invited_at, invited_by and expires_at. Historical assignments remain visible; status is active only while the user and role assignment are active, unexpired and not SCIM-denied. Personal and custom data enters Terraform state: sensitive marking hides ordinary CLI display but does not encrypt state.

For human portal use, active selected-tenant members can view catalog metadata unless SCIM denies access to that organization. Viewing the member directory additionally requires a current effective organization membership of any role. The portal preserves metadata visibility when the directory is denied, clears stale directory data on revocation, and paginates both collections. Machines always require the explicit exact-organization approval. Account, scope, tenant, organization and approval revocation are checked on each read. These data sources grant no organization configuration, protected-role or membership writes.

Import, drift, and deletion

Write the matching resource configuration first, then import existing objects. Use actual UUIDs in these commands:

terraform import oauth42_group.engineering GROUP_UUID
terraform import oauth42_group_membership.engineer GROUP_UUID/USER_UUID
terraform plan

Refresh reads current backend state. A confirmed missing resource or relationship disappears from state; authentication failures, denied permissions, server errors, and rate limits remain errors. Out-of-band changes appear in the next plan. Review a plan before applying or destroying; do not declare the same relationship in multiple states.

Mutations are not automatically retried. If a request fails after an uncertain network response, inspect the tenant before retrying; import an object that was actually created. The API does not provide a general mutation idempotency key.

State, credentials, and rotation

Store Terraform state in an access-controlled backend with encryption, locking, and restricted backups. Group names, descriptions, IDs, and memberships can be sensitive. A sensitive field hides display output but does not encrypt saved plans or state; prefer environment-supplied provider credentials.

Rotate the service-account secret through the authorized O42 portal workflow, update the secret manager, and restart Terraform with the new credential. Verify existing grants and account status. Use separate administrator credentials for provider authentication; managed accounts rotate through explicit revisions, while the provider refuses to rotate its own acting credential. Revoked accounts are rejected even if an access token has not expired.

Multiple tenants and environments

Use explicit provider aliases and separate credentials/customer UUIDs for separate tenants. Consider separate state backends for stronger administrative isolation. A managed group or membership refuses a configured tenant change; restore its original provider configuration before modifying it. Moving a resource between tenants is not a provider reconfiguration shortcut.

The provider's checks are defense in depth. Backend permissions remain authoritative. An account cannot acquire platform privileges through metadata, its creator's permissions, or a Terraform configuration field.

Troubleshooting

  • Certificate or connection error: verify the endpoint, DNS, certificate name/chain, and trusted CA. Do not disable verification.
  • Token endpoint error: check the current client secret, grant type, requested scopes, account expiry, and rate limits. The current API permits 10 token requests per minute per client; separate Terraform invocations obtain separate tokens. A rejected exchange is shared for five seconds within a provider process so concurrent resources do not repeatedly retry invalid credentials or scopes; current resource authorization is still checked on every request.
  • HTTP 401/403: verify live activity, explicit scopes, tenant-wide authority, and resource policy. Retrying cannot create permissions.
  • Tenant change refused: restore the provider's original customer/credentials. Do not remove state merely to hide an authorization mismatch.
  • User not in customer: the membership API currently checks the user's primary customer. Do not promote or move the user to force a test to pass.
  • Missing imported object: check its UUID, tenant, and whether another system owns it. SCIM and portal authorization groups require their own management workflows.

Explicitly delegated global social credentials

oauth42_platform_social_provider manages shared external OAuth credentials used by application platform-provider selections. Use the separate platform_only provider alias and dedicated expiring platform service account. A fresh human administrator must approve independent social_providers_read and social_providers_write capabilities; normal refresh/apply also needs corresponding read/write scopes or admin. Feature-policy grants cannot administer these credentials.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read", "write"]
}
variable "external_social_secret" {
  type      = string
  sensitive = true
  ephemeral = true
}
resource "oauth42_platform_social_provider" "google" {
  provider         = oauth42.platform
  provider_name    = "google"
  client_id        = "your-external-google-client-id"
  client_secret_wo = var.external_social_secret
  secret_revision  = 0
  enabled          = true
  scopes           = ["openid", "email", "profile"]
}

Supply TF_VAR_external_social_secret through your secret manager and process environment. The ephemeral client_secret_wo input is never stored in Terraform plans/state or returned by the API. Creation requires it. Increase secret_revision with the new secret to rotate deliberately; changing only the secret does not schedule an update. An outside rotation changes the opaque credential_version without exposing or restoring the old secret. This external social credential is separate from the O42 service-account secret that authenticates the provider.

provider_name is immutable and supports google, apple, twitter, linkedin, github, gitlab, facebook, discord and slack. Required client_id is the external identifier. enabled defaults to true; optional scopes uses the API provider defaults on creation, while an explicit empty set remains empty. Apple requires ten-character alphanumeric team_id and key_id; its write-only secret is the private signing key. The API preserves omitted fields and permits explicit null metadata only where the provider remains valid.

Import with terraform import oauth42_platform_social_provider.google google. Import initializes the local rotation counter to zero without reading or replacing credentials. Start imported configuration with secret_revision = 0, review its actual client ID/scopes/Apple metadata and omit the secret unless intentionally rotating. Create never overwrites an existing provider. Update and delete use the configuration version observed by Terraform; on a conflict refresh and review a new plan. Mutations and redacted typed audit commit together.

Deletion is refused while active applications select the shared provider. Remove those application selections deliberately before destroying its global credentials. Disabling global availability preserves application selections and makes them unavailable; Terraform must not silently rewrite them as custom credentials. A concurrent application enable cannot leave an orphaned selection after deletion.

Computed resource fields are id (provider name), customer_id, configuration_id (UUID), configuration_version, credential_version, has_credential, usage_count, created_at and updated_at. The usage count includes active application selections across tenants. Keep this global configuration in one Terraform state with protected remote state and separate platform credentials.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_social_providers" "all" {
  provider = oauth42.platform
}
data "oauth42_platform_social_provider" "google" {
  provider      = oauth42.platform
  provider_name = "google"
}
data "oauth42_available_platform_social_providers" "configured" {
  provider = oauth42.platform
}
output "configured_platform_providers" {
  value = data.oauth42_available_platform_social_providers.configured.providers
}

data.oauth42_platform_social_provider requires provider_name and returns complete redacted detail; its id is the configuration UUID. data.oauth42_platform_social_providers returns a complete providers list with the same fields. data.oauth42_available_platform_social_providers returns configured provider names, enabled status and display labels without credential identifiers or use counts. Catalogs may be empty; missing detail is an error. All three require current read approval and read or admin scope. They do not create human approval or perform external social sign-in.

Explicitly delegated platform feature policy

Use a separate provider alias with platform_only = true, the platform customer UUID and a dedicated, explicitly expiring platform service account. First obtain the human-approved capability grants described below. A provider flag, tenant-wide scope or the creator's privileges cannot grant platform authority. The backend and provider both check current identity, scope, grant and expiry for every operation. Platform mode refuses tenant management resources and cannot be combined with scim_only or metadata_only.

oauth42_platform_features manages the existing global feature singleton. Its only configurable attribute is the required signup_enabled boolean. Normal plan/apply runs require separate current features_read/features_write approvals and corresponding read/write scopes, or admin scope together with both approvals. Use at most one resource per API endpoint. Keep platform credentials separate from customer automation and supply the secret through the process environment.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read", "write"]
}
resource "oauth42_platform_features" "global" {
  provider       = oauth42.platform
  signup_enabled = false
}

Computed outputs are id and customer_id (the platform UUID), configuration_version, and nullable last_updated, updated_by and updated_by_principal_id. Machine changes carry their own typed principal; they never borrow a creator's human identity. Unknown feature metadata is preserved. Invalid or missing stored policy fails readback instead of becoming an apparently successful default.

Import with terraform import oauth42_platform_features.global 10000000-0000-0000-0000-000000000001. Import and refresh only observe current configuration. Create applies the explicitly selected policy to the existing singleton. Updates send the version observed by Terraform; a concurrent change returns a conflict rather than being silently overwritten. Refresh, review the new plan and retry. Configuration changes and mandatory audit commit together. Destroy only removes Terraform ownership; it never resets signup policy.

data.oauth42_platform_features has no inputs beyond provider configuration and returns the same computed policy/identity fields. It needs a current read approval and read or admin scope. data.oauth42_platform_context returns the acting customer_id, service_account_id, oauth_client_id, account_expires_at, current scopes, implemented capabilities and explicit grants. Each grant contains grant_id, platform_capability and effective expires_at, bounded by account expiry. An empty list means no approvals; a capability marker is never a permission. Neither data source stores access tokens or client secrets.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_context" "current" {
  provider = oauth42.platform
}
data "oauth42_platform_features" "current" {
  provider = oauth42.platform
}
output "current_platform_grants" {
  value = data.oauth42_platform_context.current.grants
}

Revoked approvals, deactivated accounts, lost tenant-wide authority, changed scopes and missing client/tenant registration deny access immediately, including with an existing token. Rotating the client secret rejects future exchanges using the old secret and preserves the account's independent approvals; update the secret manager. Revoking the creator's human role does not implicitly change an independently approved machine grant. Delete or revoke that machine's grant explicitly when removing its access.

Platform statistics and waitlist

These global read-only data sources require platform_only = true, the explicit platform customer UUID, and a current independent approval for the dedicated service account. Use statistics_read for statistics and waitlist_read for both contact reads and CSV exports, together with an OAuth read or admin scope. Feature or social-provider approvals grant neither capability. A machine cannot approve itself; follow the human platform delegation process below.

oauth42_platform_statistics

Returns customer_id, total_users (active global users), total_applications (active application records with an active paired client, excluding standalone and service-account clients), active_consents (unrevoked records created within 30 days), and recent_logins (distinct global users with stored sessions created within 24 hours, counted once across tenants). Counts share one database statement snapshot; they are not billing or retention metrics.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_statistics" "global" {
  provider = oauth42.platform
}

oauth42_platform_waitlist and oauth42_platform_waitlist_export

Both accept optional query for email/company/note search and repeated filter sets email, company, note and domain. Values match case-insensitively, OR within a field and AND across fields. SQL wildcard patterns are preserved; domain is an email suffix with an optional leading @. Each field permits 50 values of at most 2048 bytes each, with no NUL. Sorting is created_at (default) or email; order is desc (default) or asc, with descending UUID ties.

The page data source takes limit (1–1000, default 100) and nonnegative offset (default 0). It returns the matching total from the same snapshot, customer_id and sensitive submissions containing id, email, nullable company/note, and created_at. It reads one explicit page. A changing waitlist can change page boundaries between separate reads.

The export has no pagination input: sensitive csv includes all matching contacts and row_count verifies completeness. Columns are email, company, note and created_at; CSV escaping protects spreadsheet formula prefixes. Provider responses above 16 MiB fail explicitly. Narrow filters for a large export; a size error never becomes a successful partial file.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_waitlist" "contacts" {
  provider = oauth42.platform
  email  = ["first@", "second@"]
  sort   = "email"
  order  = "asc"
  limit  = 1
  offset = 0
}

data "oauth42_platform_waitlist_export" "contacts" {
  provider = oauth42.platform
  email = ["first@", "second@"]
  sort  = "email"
  order = "asc"
}

Contact filters, page rows and CSV are sensitive in Terraform display, but remain in state and saved plans. Protect remote state, backups and any exported file with appropriate access and encryption. Refresh rechecks live scope, tenant, account and exact approval. These are data sources with no import or destroy lifecycle; removing them from configuration does not delete contacts. Public waitlist submission remains a user interaction, not a Terraform resource.

Organization SCIM settings and activity

oauth42_organization_scim_settings and oauth42_organization_scim_activity use an exact organization_id and selected-tenant credentials. Human profiles use current portal tenant/organization administration or current global administration on the admin surface, with read/admin consent. Machines require current tenant-wide read or admin scope and a separate organization_scim_read approval. The service account must expire. Keep platform_only false even when selecting the admin API surface. The backend advertises organization-scim-read-v1.

A current administrator of that exact organization approves the account through POST /organizations/ORG_ID/read-grants, using the existing fresh independent second-factor requirement and adding "capability": "organization_scim_read" to the service_account_id/expires_at body shown above. Ordinary organization metadata approval does not confer SCIM visibility. Omitting capability retains the original organization_read meaning. Each capability has its own grant UUID, expiry and revocation. Machines cannot approve themselves or rotate SCIM tokens.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_organization_scim_settings" "example" {
  organization_id = "22222222-2222-2222-2222-222222222222"
  surface = "portal"
}
terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_organization_scim_settings" "example" {
  organization_id = "22222222-2222-2222-2222-222222222222"
  surface = "admin"
}

Settings return customer_id, organization_id, enabled, has_token, an opaque UUID configuration_version, a nullable opaque UUID credential_version, nullable last_rotated_at and sensitive nullable last_rotated_by. Existing false and null values are preserved. Tokens and token hashes are never returned. surface selects portal (default) or admin; machine authority remains the same exact approval on either route.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_organization_scim_activity" "example" {
  organization_id = "22222222-2222-2222-2222-222222222222"
  surface = "portal"
  limit = 20
  # Optional cursor, group_id and member; one bounded page per read.
}
terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "11111111-1111-1111-1111-111111111111"
  scopes = ["read"]
}
data "oauth42_organization_scim_activity" "example" {
  organization_id = "22222222-2222-2222-2222-222222222222"
  surface = "admin"
  limit = 20
  # Optional cursor, group_id and member; one bounded page per read.
}

Activity requires an explicit limit of 1–50. Each read returns one page and a sensitive nullable next_cursor; provide it as cursor for the next page. Do not interpret a single page as the complete history. Optional group_id is a UUID. Optional member is a UUID or case-insensitive email/username SQL pattern, at most 256 bytes. The opaque cursor binds the tenant, organization and filters: reset it when changing those inputs. Timestamp and UUID ordering retains tied records exactly once within an unchanged dataset; pages are separate live snapshots.

Sensitive entries contain id, event_type, created_at and scim_membership: organization_id, group_id, nullable group_display_name, members_added and members_removed. Member records contain user_id with nullable email/display_name; profiles resolve only within the selected tenant. Malformed, oversized or incomplete responses fail explicitly. Personal data enters Terraform state; sensitive marking does not encrypt it. Protect the state backend and access. Destroy only removes the local data-source snapshot.

Current human portal authority remains selected-tenant administrator or exact-organization administrator. Admin routes require current platform-admin authority. SCIM deprovisioning overrides retained manual roles. Legacy human reads, rotation and filter telemetry share the same first active selected-tenant organization ordered by creation timestamp then UUID; authorization never silently selects a different organization. Human writes retain server-generated secrets and atomic audit, and recheck authority after database waits. The explicit human preview-record action below covers telemetry. Machine read approval grants no write authority. The protected rotation action below requires current human authority.

Rotate an inbound SCIM token

oauth42_organization_scim_rotate explicitly replaces one organization's provisioning token and delivers the generated value to an OS protected store. Use a selected-tenant human profile, platform_only = false, and backend capability organization-scim-protected-rotation-v1. The portal surface requires current tenant or exact-organization administration and write/admin consent. The admin surface requires current global administration and admin consent. Organization-only portal administrators are supported. Machine read approvals do not authorize rotation.

Read data.oauth42_organization_scim_settings, review the exact organization and current settings, then manually pin its configuration_version. Do not feed a live data-source version directly into the action. Supply surface, organization_id, the original reviewed version, enabled, a new canonical UUID operation_id and an explicit secret_store_profile of 1–100 letters, digits, dots, underscores or hyphens. Portal rotations require enabled=true. Admin rotations may explicitly set false; a delivered disabled token cannot provision until separately enabled.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Read oauth42_organization_scim_settings independently; manually pin its
# exact organization and opaque configuration_version after reviewing settings.
# terraform apply -invoke=action.oauth42_organization_scim_rotate.selected
action "oauth42_organization_scim_rotate" "selected" {
  config {
    surface               = "portal"
    organization_id       = "33333333-3333-4333-8333-333333333333"
    configuration_version = "66666666-6666-4666-8666-666666666666"
    enabled               = true
    operation_id          = "55555555-5555-4555-8555-555555555555"
    secret_store_profile  = "directory-production"
  }
}
# The old token stops working at commit. Recover an uncertain result with the
# SAME operation, original review, surface, enablement and destination within 24h.
# Recovery does not restore changed settings. Read current settings afterward.
# oauth42-terraform-login delivery-inspect --profile directory-production \
#   --operation-id 55555555-5555-4555-8555-555555555555
# oauth42-terraform-login delivery-consume --profile directory-production \
#   --operation-id 55555555-5555-4555-8555-555555555555 -- /absolute/trusted-consumer

The global-administrator variant retains the same exact selected-tenant organization binding:

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Read oauth42_organization_scim_settings independently; manually pin its
# exact organization and opaque configuration_version after reviewing settings.
# terraform apply -invoke=action.oauth42_organization_scim_rotate.selected
action "oauth42_organization_scim_rotate" "selected" {
  config {
    surface               = "admin"
    organization_id       = "33333333-3333-4333-8333-333333333333"
    configuration_version = "66666666-6666-4666-8666-666666666666"
    enabled               = true
    operation_id          = "55555555-5555-4555-8555-555555555555"
    secret_store_profile  = "directory-production"
  }
}
# The old token stops working at commit. Recover an uncertain result with the
# SAME operation, original review, surface, enablement and destination within 24h.
# Recovery does not restore changed settings. Read current settings afterward.
# oauth42-terraform-login delivery-inspect --profile directory-production \
#   --operation-id 55555555-5555-4555-8555-555555555555
# oauth42-terraform-login delivery-consume --profile directory-production \
#   --operation-id 55555555-5555-4555-8555-555555555555 -- /absolute/trusted-consumer

The original login must still carry a fresh independent factor. Refreshing credentials does not renew that proof. Current membership, organization activity, SCIM deprovisioning, role expiry, consent and factor authority remain live through mandatory audit and commit. Configuration changes reject a new operation until you review the new version. Unrelated organization settings and historical extension fields remain intact.

Commit immediately invalidates the previous token. A transport failure or local storage failure can happen after commit. Retain the same original version, operation UUID, surface, enablement, destination and protected recipient to recover the original encrypted result for up to 24 hours. Recovery requires the same current actor, authority and current credential generation. It never rotates again or restores settings changed after the operation. Read current settings before using the recovered token. A later token replacement, including another settings writer, makes the earlier receipt unusable.

The destination uses the same protected delivery workflow as application secrets. The provider saves and verifies the private recipient before sending a mutation, and verifies the returned binding before reporting delivery. delivery-inspect exposes public binding metadata; delivery-consume sends the secret only to your explicit trusted executable through standard input. Losing the local recipient prevents recovery. Protect that store and the trusted consumer.

Tokens, token verifiers, private recipient keys and encrypted delivery capsules never become Terraform action outputs or state. There is no import or inverse destroy. Ordinary plan and apply do not invoke the action, and mutation failures are not automatically retried. Execute the documented terraform apply -invoke=action.oauth42_organization_scim_rotate.selected only after reviewing the operational cutover.

Record a SCIM filter preview event

oauth42_organization_scim_filter_preview_record explicitly records one caller-reported preview event in the selected organization's audit log. It does not execute the filter, verify the supplied counts, return directory results or change provisioning. Use the organization-scim-filter-preview-v1 backend capability with a human profile, an exact organization_id and platform_only false.

The portal surface requires current selected-tenant or exact-organization administration and explicit write or admin consent. The admin surface requires current global administration and explicit admin consent, while still binding the organization to the profile's selected tenant. Actual tenant membership, active account/organization, SCIM deprovisioning, role expiry and consent revocation remain live through mandatory audit commit. A machine's organization_scim_read approval grants no telemetry write.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "write"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
action "oauth42_organization_scim_filter_preview_record" "selected" {
  config {
    surface           = "portal"
    organization_id   = "33333333-3333-4333-8333-333333333333"
    filter            = "displayName pr"
    source            = "terraform"
    member_any_count  = 2
    member_all_count  = 3
    has_display_name  = true
    has_external_id   = false
    has_id_equals     = false
    requires_presence = true
  }
}

filter is required, at most 1,024 characters and nonempty after trimming; surrounding whitespace is removed before recording. The API rejects overlong expressions instead of truncating them. Optional source is at most 128 characters and defaults to unknown when absent or null. Optional member_any_count and member_all_count are nonnegative integers, defaulting to zero. Optional has_display_name, has_external_id, has_id_equals and requires_presence default to false. These fields are caller-reported metadata; the boolean presence flag does not request an authentication ceremony. Unknown or duplicate fields and NUL characters are rejected.

Global administrators use the same action with the admin surface and corresponding consent:

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "22222222-2222-4222-8222-222222222222"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
action "oauth42_organization_scim_filter_preview_record" "selected" {
  config {
    surface           = "admin"
    organization_id   = "33333333-3333-4333-8333-333333333333"
    filter            = "displayName pr"
    source            = "terraform"
    member_any_count  = 2
    member_all_count  = 3
    has_display_name  = true
    has_external_id   = false
    has_id_equals     = false
    requires_presence = true
  }
}
terraform apply -invoke=action.oauth42_organization_scim_filter_preview_record.selected

There is no resource state, import, output or inverse destroy. Each successful explicit invocation records a separate audit event; an ordinary plan or apply does not invoke the action. No automatic retry occurs. After an interrupted request, inspect the organization's authorized audit history before deciding whether to record another event. Filter expressions and labels become audit data and remain in configuration or saved plans; do not include credentials.

Platform subscription-tier catalog

oauth42_platform_subscription_tiers and oauth42_platform_subscription_tier read the full platform catalog, including inactive tiers. Use an expiring tenant-wide platform service account, platform_only, the exact platform customer UUID, OAuth read or admin scope, and a separately approved current subscription_tiers_read grant. A current human platform administrator issues that grant after fresh independent second-factor verification through the established platform approval API. The backend must advertise platform-subscription-tiers-v1. Other read approvals and tenant-wide scope do not confer this authority.

The catalog requires explicit limit (1–100) and offset (nonnegative row offset). It returns total, complete and tiers, ordered by sort order, name and UUID. Each row has id and tier_json. Complete is true only when this page contains the whole catalog from offset zero. Separate offset pages observe current data independently; concurrent changes can move entries. The detail source requires tier_id and returns tier_json. Both return customer_id.

Use jsondecode(tier_json) for every field: id, name, display_name, monthly_price, annual_price, included_mau, overage_price_per_mau, api_calls_limit, monthly_active_users_limit, oauth_clients_limit, arbitrary features, is_active, sort_order, created_at, updated_at, both stripe_monthly_price_id and stripe_annual_price_id, and payment_required. JSON preserves decimal and large integer precision and nullable values. These are snapshots: drift refreshes from O42, and removing a data source removes state without deleting tiers. Missing tiers, malformed data, revoked authority and responses above 16 MiB fail explicitly.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["read"]
}
data "oauth42_platform_subscription_tiers" "example" {
  limit = 20
  offset = 0
}
# Each result has id and complete tier_json; protect state and plans.
# jsondecode(data.oauth42_platform_subscription_tiers.example.tiers[0].tier_json).features
terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["read"]
}
data "oauth42_platform_subscription_tier" "example" {
  tier_id = "11111111-1111-4111-8111-111111111111"
}
# Access any exact field, including nullable limits and nested feature metadata.
# jsondecode(data.oauth42_platform_subscription_tier.example.tier_json).monthly_price

Tier metadata is sensitive in Terraform output but remains present in state and saved plans; protect and encrypt those artifacts. This approval permits no tier creation, edits, deletion, subscription changes or payments. The existing public billing_tiers metadata source remains the active public catalog. Existing human admin callers retain complete no-query catalogs up to 1,000 rows; larger catalogs fail with a paging instruction instead of silently omitting tiers.

Manage subscription tiers

The oauth42_platform_subscription_tier resource manages complete catalog configuration. Use an explicit human profile for the platform customer, current global administrator membership, approved admin scope and fresh independent MFA. The backend must advertise platform-subscription-tier-management-v1. A service account catalog-read approval cannot create, edit or retire tiers. Original primary authentication and independent factor evidence must remain within five minutes through commit; refreshing a token does not renew that window.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Requires current global administrator membership, explicit admin consent and fresh MFA.
# Existing tiers must be imported by UUID before management.
resource "oauth42_platform_subscription_tier" "catalog" {
  name                       = "terraform-catalog-example"
  display_name               = "Managed catalog example"
  monthly_price              = "12.34"
  annual_price               = "123.45"
  included_mau               = 50000
  overage_price_per_mau       = "0.0123"
  api_calls_limit             = 100000
  monthly_active_users_limit = 50000
  oauth_clients_limit        = 20
  features_json              = "{\"adaptive_mfa\":true,\"max_tenants\":10,\"extension_counter\":9007199254740993}"
  stripe_monthly_price_id     = null
  stripe_annual_price_id      = null
  sort_order                 = 90
  is_active                  = true
  payment_required           = true
}
# Destroy retires this tier; existing subscriptions and ledger rows remain.

Import an existing active or retired tier by its UUID: terraform import oauth42_platform_subscription_tier.catalog TIER_UUID. Import only reads configuration. Names are globally unique; creation refuses to adopt a same-name tier. A lost creation response requires inspecting the catalog and explicitly importing the created identity before another apply.

Required configuration is name, display_name, monthly_price, annual_price, features_json, sort_order, is_active and payment_required. Monthly and annual prices are exact nonnegative decimal strings with two places and maximum 99999999.99. Optional overage_price_per_mau has four places and maximum 999999.9999. No price is silently rounded. Name and display name are trimmed, nonempty text of at most 50 and 100 characters; existing Stripe price references are at most 255 characters.

Optional included_mau, api_calls_limit, monthly_active_users_limit and oauth_clients_limit are nonnegative integers up to 2147483647. Omission or null clears these limits, the overage price and either stripe_monthly_price_id or stripe_annual_price_id. Sort order is a signed 32-bit integer. Feature JSON is a complete object up to 64 KiB: extensions and exact numbers are preserved; formatting alone causes no change. Known feature limits audit_retention_days, saml_scim_connections_limit, portal_seats_limit and max_tenants are nonnegative 64-bit integers or null; adaptive_mfa is boolean or null. Ambiguous duplicate JSON keys and nesting beyond 64 levels are rejected.

Updates and retirement use the configuration_version observed during refresh. Concurrent changes fail instead of being overwritten; inspect and refresh before a new explicit apply. Current authority, fresh proof and mandatory audit remain atomic with each write. State also records id, platform_customer_id, created_at and updated_at. Protect state and saved plans; sensitive feature JSON still exists in those artifacts.

Destroy retires the tier by setting is_active=false. The tier row, existing subscriptions, entitlements and financial history remain. Retired tiers disappear from the public selection catalog and cannot be selected for new tier changes. Reusing the same name requires importing its UUID and explicitly setting is_active=true. Catalog prices and existing Stripe price references do not create Stripe prices, charge customers or change an existing Stripe subscription.

Global user profiles

oauth42_platform_users, oauth42_platform_user and oauth42_platform_users_export read global profile metadata. Use an expiring, tenant-wide platform service account, platform_only, the platform customer UUID, current independent users_read approval, and OAuth read or admin scope. The backend must advertise platform-users-v1. Tenant administration and approvals for other families do not grant global reads; read approval does not permit user mutations.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["read"]
}
data "oauth42_platform_users" "example" {
  limit = 20
  offset = 0
  sort = "email"
  order = "asc"
  # Optional: query, email, company, domain.
}

The list reads one explicit page: limit 1–100, default 20; offset is a row offset, default zero. It returns page, total and total_pages from the same database statement as the rows. Request the next page by adding limit to offset. Oversized limits fail instead of being silently clamped. Separate requests are not one database snapshot; concurrent changes can move rows between pages.

Optional query searches email, username, first and last name and company using case-insensitive SQL patterns. Email filters match exactly; company filters are case-insensitive SQL patterns; domain filters match the whole email domain, case-insensitively, without a leading @. Each filter set accepts at most 50 values of 2,048 bytes. Values within a field are ORed, fields are ANDed. Sort is created_at or email, order is desc or asc, with user UUID ascending for ties.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["read"]
}
data "oauth42_platform_user" "example" {
  user_id = "11111111-1111-4111-8111-111111111111"
}

Detail returns the exact UUID. Profile fields include email, username, first and last name, phone, status and verification flags, timestamps, company name, routing company_id and separate profile_owner_customer_id. Historical null values remain null. Routing does not transfer profile ownership. No password hashes, factor secrets, recovery codes, tokens or credential inventories are returned.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["read"]
}
data "oauth42_platform_users_export" "example" {
  domain = ["example.com"]
  sort = "email"
  order = "asc"
  # All matches, bounded at 10,000 rows and 16 MiB; narrow filters on failure.
}

CSV returns all matching rows using the established columns id, email, first_name, last_name, email_verified, is_active, mfa_enabled, created_at and company. Null cells stay empty; formula-like values are escaped. More than 10,000 matches or 16 MiB is an explicit error: narrow filters rather than accepting a partial export. All three data sources refresh current authority and fail after approval revocation or expiry.

Profiles and CSV are sensitive Terraform values but remain in state and saved plans. Protect those artifacts with encryption and least-privilege access. These are read-only data sources: there is no import, credential delivery, user creation or deletion action in this family.

Review and explicitly change financial invoices

Invoice creation, complete draft replacement, send, payment recording and voiding use explicit Terraform actions. Use a platform-tenant human administrator profile, approved read admin offline_access login consent, provider scopes ["read", "admin"], and backend capability platform-financial-invoice-management-v1. The current global role and exact billing-account/company relationship are checked on every request. Writes require original primary authentication and an independent factor within five minutes; refresh does not renew that proof.

Every financial action requires a caller-chosen canonical operation_id UUID, exact target_customer_id and billing_account_id, a manually pinned configuration_version, and explicit confirmation. Keep the operation ID after any error or interruption. New invoice identity equals its creation operation ID. The provider does not invoke an action through ordinary apply, refresh or destroy, retry it automatically, or expose action outputs. These actions own no Terraform resource and have no import or inverse destroy.

Read the complete target

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_creation_configuration" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
}

The creation data source accepts the exact company and account UUIDs. It returns platform_customer_id, billing_name, nullable billing_email and stripe_customer_id, external_service_configured, sensitive normalized policy_json, and the observed version. The policy includes its complete configuration, related companies and current eligibility. Creation and replacement require an active account, enabled invoice billing, and the current subscription with explicit skip-payment and no external subscription. Reading never creates an external customer.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_financial_configuration" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  invoice_id        = "33333333-3333-4333-8333-333333333333"
}

The existing-invoice review additionally requires invoice_id. It returns the exact company cohort, billing account status, external customer reference, version, sensitive invoice_json and exact stored configuration_json, and integer subtotal_cents, tax_cents, total_cents and amount_paid_cents. Use the stored configuration to preserve the original invoice date and line prices; the legacy invoice display includes decimal currency values. Reviews fail explicitly above 1,000 lines, 10,000 related companies, 16 MiB per provider response, or supported exact numeric bounds.

Create or replace a draft

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_creation_configuration" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
}

variable "invoice_configuration" {
  type      = string
  sensitive = true
  default = <<-JSON
  {
    "invoice_date": "2026-01-01T00:00:00Z",
    "due_date": "2026-02-01T00:00:00Z",
    "service_period_start": "2026-01-01T00:00:00Z",
    "service_period_end": "2026-02-01T00:00:00Z",
    "po_number": null,
    "contract_id": null,
    "payment_method": null,
    "tax_amount_cents": 0,
    "line_items": [{
      "kind": "other",
      "description": "Reviewed invoice service",
      "quantity": 3,
      "unit_amount_cents": 101,
      "service_period_start": null,
      "service_period_end": null
    }]
  }
  JSON
}

# Review the exact target, full financial intent and any recorded external effects.
# Copy the observed version; the placeholder is not approval. Keep operation_id after failure.
# Ordinary apply, refresh and destroy never invoke this action.
# Invoke explicitly: terraform apply -invoke=action.oauth42_platform_invoice_create.selected
action "oauth42_platform_invoice_create" "selected" {
  config {
    operation_id = "77777777-7777-4777-8777-777777777777"
    target_customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    configuration_json = var.invoice_configuration
    auto_send = false
    confirm_create_invoice = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_financial_configuration" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  invoice_id        = "33333333-3333-4333-8333-333333333333"
}

variable "invoice_configuration" {
  type      = string
  sensitive = true
  default = <<-JSON
  {
    "invoice_date": "2026-01-01T00:00:00Z",
    "due_date": "2026-02-01T00:00:00Z",
    "service_period_start": "2026-01-01T00:00:00Z",
    "service_period_end": "2026-02-01T00:00:00Z",
    "po_number": null,
    "contract_id": null,
    "payment_method": null,
    "tax_amount_cents": 0,
    "line_items": [{
      "kind": "other",
      "description": "Reviewed invoice service",
      "quantity": 3,
      "unit_amount_cents": 101,
      "service_period_start": null,
      "service_period_end": null
    }]
  }
  JSON
}

# Review the exact target, full financial intent and any recorded external effects.
# Copy the observed version; the placeholder is not approval. Keep operation_id after failure.
# Ordinary apply, refresh and destroy never invoke this action.
# Invoke explicitly: terraform apply -invoke=action.oauth42_platform_invoice_update.selected
action "oauth42_platform_invoice_update" "selected" {
  config {
    operation_id = "77777777-7777-4777-8777-777777777777"
    target_customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    invoice_id = "33333333-3333-4333-8333-333333333333"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    configuration_json = var.invoice_configuration
    confirm_update_invoice = true
  }
}

Both actions require complete configuration_json. Supply invoice_date, due_date, nullable service_period_start/service_period_end, nullable po_number, contract_id and payment_method, nonnegative tax_amount_cents, and one to 1,000 line_items. Explicit nulls clear nullable fields. A line requires kind, nonempty description, integer quantity, integer unit_amount_cents, and both nullable service-period fields. Kinds are subscription, mau_overage, workforce_seats, saml_connection, professional_services, credit and other. Negative line prices are explicit credits. Payment method is wire, ach, check, other or null.

Quantities range from 1 to 1,000,000; descriptions have at most 4,096 characters; PO and contract references have at most 255. Unit amounts, line products, subtotals and totals must remain exact within ±9,007,199,254,740,991 cents. Dates use RFC3339 with at most microsecond precision; due date cannot precede invoice date. Service-period endpoints must both be present or both null, end after start, and span no more than 120 calendar months. External due dates and periods require whole seconds. Line periods inherit invoice periods when omitted; absent periods use the explicit invoice date for deterministic accounting.

Creation requires confirm_create_invoice = true and an explicit auto_send Boolean. Replacement requires the existing invoice_id, confirm_update_invoice = true, a draft status, and the exact original immutable invoice date. Replacement changes the entire line set and accounting entries together with its mandatory audit. It cannot implicitly send an invoice. Linked external drafts are completely paginated and checked against their actual customer, invoice and retained line identities before replacement.

Without an external billing service, the local ledger remains authoritative. A linked account cannot silently fall back to local success when that service is unavailable. External invoices without automatic tax require zero tax. With automatic tax, the supplied tax is the expected reviewed amount; a different external tax or total stops completion and email delivery, leaving the recorded outcome available for reconciliation. Zero or credit invoices can become paid during external finalization; O42 retains the actual paid status instead of reopening them.

Send, record payment or void

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_financial_configuration" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  invoice_id        = "33333333-3333-4333-8333-333333333333"
}

# Review the exact target, full financial intent and any recorded external effects.
# Copy the observed version; the placeholder is not approval. Keep operation_id after failure.
# Ordinary apply, refresh and destroy never invoke this action.
# Invoke explicitly: terraform apply -invoke=action.oauth42_platform_invoice_send.selected
action "oauth42_platform_invoice_send" "selected" {
  config {
    operation_id = "77777777-7777-4777-8777-777777777777"
    target_customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    invoice_id = "33333333-3333-4333-8333-333333333333"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_financial_change = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_financial_configuration" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  invoice_id        = "33333333-3333-4333-8333-333333333333"
}

# Review the exact target, full financial intent and any recorded external effects.
# Copy the observed version; the placeholder is not approval. Keep operation_id after failure.
# Ordinary apply, refresh and destroy never invoke this action.
# Invoke explicitly: terraform apply -invoke=action.oauth42_platform_invoice_paid.selected
action "oauth42_platform_invoice_paid" "selected" {
  config {
    operation_id = "77777777-7777-4777-8777-777777777777"
    target_customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    invoice_id = "33333333-3333-4333-8333-333333333333"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_financial_change = true
    paid_at = "2026-02-01T10:00:00Z"
    payment_method = "wire"
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_invoice_financial_configuration" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  invoice_id        = "33333333-3333-4333-8333-333333333333"
}

# Review the exact target, full financial intent and any recorded external effects.
# Copy the observed version; the placeholder is not approval. Keep operation_id after failure.
# Ordinary apply, refresh and destroy never invoke this action.
# Invoke explicitly: terraform apply -invoke=action.oauth42_platform_invoice_void.selected
action "oauth42_platform_invoice_void" "selected" {
  config {
    operation_id = "77777777-7777-4777-8777-777777777777"
    target_customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    invoice_id = "33333333-3333-4333-8333-333333333333"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_financial_change = true
  }
}

These actions require invoice_id and confirm_financial_change = true. Send accepts an active account and a draft, finalizing it when required before sending. Payment recording accepts open or past-due invoices and additionally requires the explicit received paid_at time and payment_method; it records an out-of-band payment and does not charge a card. Void accepts draft, open, past-due or uncollectible invoices and reverses their local revenue-recognition entries. Payment and void may settle an inactive account. Each response must confirm the exact completed transaction; partial or unknown outcomes are errors.

Inspect interruption and make a separate recovery decision

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_financial_operation" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id      = "77777777-7777-4777-8777-777777777777"
}

The operation data source accepts the exact company, billing account and operation UUIDs. It returns target_kind, target_id, operation_kind, request_sha256, reviewed_target_version, sensitive normalized intent_json and external_steps_json, state, nullable outcome_code, creation/update/completion timestamps and the current operation version. Draft intents include the original request and frozen line/provisioning identities. Steps expose their exact key, state, external object ID, original dispatch/acceptance times, outcome code and a typed receipt with verified identities and applicable financial amounts. Reading never resumes an operation.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_financial_operation" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id      = "77777777-7777-4777-8777-777777777777"
}

# Review the exact target, full financial intent and any recorded external effects.
# Copy the observed version; the placeholder is not approval. Keep operation_id after failure.
# Ordinary apply, refresh and destroy never invoke this action.
# Invoke explicitly: terraform apply -invoke=action.oauth42_platform_financial_operation_resume.selected
action "oauth42_platform_financial_operation_resume" "selected" {
  config {
    operation_id = "77777777-7777-4777-8777-777777777777"
    target_customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_reviewed_operation = true
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_financial_operation" "selected" {
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  billing_account_id = "55555555-5555-4555-8555-555555555555"
  operation_id      = "77777777-7777-4777-8777-777777777777"
}

# Review the exact target, full financial intent and any recorded external effects.
# Copy the observed version; the placeholder is not approval. Keep operation_id after failure.
# Ordinary apply, refresh and destroy never invoke this action.
# Invoke explicitly: terraform apply -invoke=action.oauth42_platform_financial_operation_cancel.selected
action "oauth42_platform_financial_operation_cancel" "selected" {
  config {
    operation_id = "77777777-7777-4777-8777-777777777777"
    target_customer_id = "44444444-4444-4444-8444-444444444444"
    billing_account_id = "55555555-5555-4555-8555-555555555555"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_reviewed_operation = true
  }
}

Recovery requires confirm_reviewed_operation = true and the current operation version. Resume retains the original immutable request, reacquires current authority and fresh proof, reuses accepted receipts, and commits local state with its audit. A failed local commit can follow an accepted external effect; a receipt prevents another email or financial mutation during recovery. Unknown POST outcomes can only reuse the same request and key within 23 hours of their first dispatch. That clock never resets. After the window, an unknown outcome requires read-only external reconciliation; the provider refuses a blind retry or replacement key. A changed target or billing policy also requires reconciliation rather than automatic adoption.

DELETE has separate recovery behavior: an explicitly resumed interrupted line deletion checks the complete exact external invoice inventory before recording an observed absence. Cancellation is allowed only when no external effect may have been dispatched. It never erases a receipt, reverses a financial effect or pretends an uncertain operation did not happen. Terminal operations cannot run again, and another unresolved intent cannot claim the same financial target.

Terraform sensitive display does not encrypt state or saved plans. Invoice data, customer contact details, access-bearing PDF/hosted URLs and complete financial intents remain private artifacts. Use a sensitive input variable for draft JSON and protect configuration, plans, state, backups and exports. Action schemas have no computed secret-delivery output. Keep the durable operation reference when closing the admin review dialog or recovering after a lost response.

Platform service-account inventory

oauth42_platform_service_accounts reads one explicit page of global account metadata. Use an expiring, tenant-wide platform service account, platform_only, the platform customer UUID, independent service_accounts_read approval, and current OAuth read or admin scope. It requires the backend platform-service-accounts-v1 contract. Ordinary tenant administration or an approval for another family does not grant this access.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["read"]
}
data "oauth42_platform_service_accounts" "example" {
  limit = 50
  offset = 0
  # Optional: target_customer_id, search, is_active.
}

Optional filters are target_customer_id (owning customer UUID), is_active (true or false), and search (case-insensitive SQL wildcard matching over name, client ID and customer UUID; at most 2048 bytes, no NUL). limit accepts 1–100, default 50; offset is a zero-based row offset, default 0. The result contains total and service_accounts, ordered by created_at descending then UUID. Read additional offsets explicitly; this data source does not pretend one page is the complete catalog. The admin web page uses the same backend bounds and shows page navigation.

Each account includes id, client_id, name, description, customer_id, scopes, roles, permissions, is_active, tenant_wide, last_used_at, expires_at, created_at, updated_at, created_by, credential_version, and application_access entries with application_id, application_name and roles. Nullable historical fields remain null; credential_version is null if a historical account has no paired OAuth client. No client secret or secret hash is returned. Deleted tombstones are excluded; inactive accounts remain discoverable unless filtered out. Duplicate global UUIDs fail closed.

The backend returns complete application-access entries for each row or an explicit error: at most 1,000 assignments per account and 10,000 per page. Use a smaller page for the page-wide limit; an individual oversized account requires correcting its configuration. Metadata and totals share one query snapshot, while assignments are read afterward in the same transaction; this is not an atomic cross-page export. Current human or machine authority is rechecked after database waits.

Account inventories and search values are sensitive in Terraform display but remain in state and saved plans; protect those artifacts. Refresh observes metadata, credential-version and assignment changes, and fails after approval revocation. This read-only data source has no import or remote destroy operation. Global account creation, deletion and rotation are not authorized by this read approval.

The admin portal rotates an existing active account through POST /admin/service-accounts/{id}/rotate-credentials, with the quoted current credential_version in If-Match. Missing versions fail with 428; stale versions fail with 412 and do not repeat rotation. The server generates the secret and returns it once after credential and audit commit. Machines require independent service_accounts_rotate approval plus write or admin scope; self-rotation is refused. Expired accounts, revoked approvals and invalid client pairings fail closed.

The explicit global rotation action below delivers the generated credential through the native protected store without a Terraform secret output. The tenant oauth42_service_account resource retains its separate sensitive-state lifecycle. Inventory read approval alone authorizes neither rotation path.

Rotate a global service-account credential

action.oauth42_platform_service_account_rotate rotates one exact active account and delivers its generated credential into the explicit native protected-store profile. Manually pin service_account_id, target_customer_id and the current credential_version UUID from authorized inventory. Select a new operation_id for a genuinely new rotation; retain that ID, original version and secret_store_profile after an uncertain response. Planning and ordinary apply do not rotate.

A human uses the platform-tenant profile, explicit admin consent, current global administrator membership and original primary authentication plus an independent factor within five minutes of commit. A machine uses platform_only, the platform tenant, a currently active expiring tenant-wide account, write or admin scope and separate current service_accounts_rotate approval. A read grant, historical creator role or ordinary tenant administration cannot substitute. An operator cannot rotate its own calling account. The backend must advertise platform-service-account-protected-rotation-v1.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Independently inspect oauth42_platform_service_accounts or the authorized
# admin inventory; manually pin the exact account, customer and credential UUID.
# A read approval cannot rotate. The machine needs service_accounts_rotate.
# terraform apply -invoke=action.oauth42_platform_service_account_rotate.selected
action "oauth42_platform_service_account_rotate" "selected" {
  config {
    service_account_id   = "33333333-3333-4333-8333-333333333333"
    target_customer_id   = "44444444-4444-4444-8444-444444444444"
    credential_version   = "66666666-6666-4666-8666-666666666666"
    operation_id         = "55555555-5555-4555-8555-555555555555"
    secret_store_profile = "service-production"
  }
}
# The old secret stops working at commit. Recover uncertain delivery with this
# SAME operation UUID, original version and destination for up to 24 hours.
# oauth42-terraform-login delivery-inspect --profile service-production \
#   --operation-id 55555555-5555-4555-8555-555555555555
# oauth42-terraform-login delivery-consume --profile service-production \
#   --operation-id 55555555-5555-4555-8555-555555555555 -- /absolute/trusted-consumer
terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
# Supply O42_CLIENT_ID and O42_CLIENT_SECRET through the protected process
# environment for the independently approved, expiring platform operator.
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["write"]
}
# Independently inspect oauth42_platform_service_accounts or the authorized
# admin inventory; manually pin the exact account, customer and credential UUID.
# A read approval cannot rotate. The machine needs service_accounts_rotate.
# terraform apply -invoke=action.oauth42_platform_service_account_rotate.selected
action "oauth42_platform_service_account_rotate" "selected" {
  config {
    service_account_id   = "33333333-3333-4333-8333-333333333333"
    target_customer_id   = "44444444-4444-4444-8444-444444444444"
    credential_version   = "66666666-6666-4666-8666-666666666666"
    operation_id         = "55555555-5555-4555-8555-555555555555"
    secret_store_profile = "service-production"
  }
}
# The old secret stops working at commit. Recover uncertain delivery with this
# SAME operation UUID, original version and destination for up to 24 hours.
# oauth42-terraform-login delivery-inspect --profile service-production \
#   --operation-id 55555555-5555-4555-8555-555555555555
# oauth42-terraform-login delivery-consume --profile service-production \
#   --operation-id 55555555-5555-4555-8555-555555555555 -- /absolute/trusted-consumer

The native store must be available before mutation. The old secret stops working when the backend commits; local storage can still fail afterward. Invoke the same original intent to recover its encrypted result for 24 hours, with current authority and the same current credential generation. Recovery does not rotate again, change destination or revive an old credential. Account, scope, approval, consent and factor revocation remain live, including after target and deferred audit waits. Mandatory platform and affected-tenant audits commit atomically with the credential and encrypted receipt.

There is no secret Terraform state or action output, plaintext fallback, automatic consumer or CRUD/import lifecycle. Use the explicit delivery-inspect and trusted delivery-consume commands described in protected secret delivery. Retain the protected original until the intended consumer has adopted and verified its generation. Destruction of Terraform state never rotates or erases the stored credential.

Delete a global service account

action.oauth42_platform_service_account_delete explicitly revokes one account and its credential routing while retaining the account, grants and audit history as an inactive tombstone. It requires platform-only mode, the platform customer UUID, an expiring platform actor, independent service_accounts_delete approval and current write or admin scope. Read and rotation approvals do not grant deletion. The backend must advertise platform-service-account-deletion-v1.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers { oauth42 = { source = "oauth42/oauth42" } }
}
provider "oauth42" {
  endpoint = "https://api.example.com"
  customer_id = "10000000-0000-0000-0000-000000000001"
  platform_only = true
  scopes = ["write"]
}
action "oauth42_platform_service_account_delete" "selected" {
  config {
    service_account_id = "55555555-5555-5555-5555-555555555555"
    target_customer_id = "11111111-1111-1111-1111-111111111111"
    credential_version = "44444444-4444-4444-4444-444444444444"
    # Use "unpaired" only when authorized inventory reports no credential version.
  }
}

Replace all three target inputs with the exact account UUID, owning customer UUID and current credential-version UUID from an authorized inventory. The target customer is separate from the provider's platform customer. For a genuinely clientless account, explicitly set credential_version = "unpaired". A newly paired client invalidates that intent; the action never infers permission to delete an unrelated registration sharing an identifier.

terraform plan -invoke=action.oauth42_platform_service_account_delete.selected
terraform apply -invoke=action.oauth42_platform_service_account_delete.selected

The API requires the target customer and quoted version precondition. Missing versions fail with 428, changed versions with 412, and ambiguous identity or broken foreign linkage fails closed. Review and update a stale intent explicitly; the provider never automatically refreshes the version and retries deletion. A same-version repeat against the retained tombstone returns success without adding another deletion audit record. Missing targets and wrong-customer responses remain errors rather than assumed success, and each retry requires current authority.

Deletion atomically deactivates the exact account/client, removes its routing and writes platform and tenant audit. Existing access tokens and new client-credentials exchanges stop working without relying on post-commit cache cleanup. No secrets are returned or included in diagnostics. Expired accounts and suspended or deleted target tenants can be cleaned up without restoring them; their other identities, applications and history remain intact. The actor cannot delete itself.

This action has no import, resource state or inverse destroy operation. An interrupted call has an unknown outcome: inspect current authorized inventory and retry only the same pinned target/version intent. Terraform destroy does not restore an account. Create a separate new identity if replacement is needed. Use the separate protected rotation action above to replace a credential and deliver its original result to a native OS protected store.

Create companies with explicit initial ownership

oauth42_platform_company creates a standalone active company and its billing account, then manages the same complete contact/status configuration described below. Use current global human administrator authority, explicit admin consent, fresh original independent-factor proof and backend capability platform-company-creation-v1. Creation and the initial independent portal-owner grant commit with mandatory typed audit.

First review the current deterministic active default tier. Its prices are exact decimal strings. Copy its ID and version into the creation inputs after review; a changed tier refuses creation. Selecting the default tier creates neither a paid subscription nor a payment.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_company_creation_context" "current" {}
output "reviewed_default_tier" {
  value = data.oauth42_platform_company_creation_context.current
}

For a new identity, initial_owner_email must not already exist. Explicitly acknowledge grant_initial_portal_owner = true. The owner receives a 24-hour activation link and controls their initial password. SMTP must accept the message before the transaction commits; acceptance is not inbox delivery. A later rollback invalidates the delivered capability but cannot unsend email. No password or activation token enters Terraform output or state.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_company" "managed" {
  name   = "New Managed Company"
  email  = "[email protected]"
  status = "active"
  billing_email = null
  tax_id        = null
  address_line1 = null
  address_line2 = null
  city          = null
  state         = null
  postal_code   = null
  country       = null
  # Copy the separately reviewed current default tier; never buy a subscription implicitly.
  initial_default_tier_id      = "99999999-9999-4999-8999-999999999999"
  initial_default_tier_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  initial_owner_email          = "[email protected]"
  grant_initial_portal_owner   = true
}

To grant an existing active identity, also supply its exact initial_existing_owner_user_id and current canonical email. Omit initial first/last names; existing profiles, primary routing, profile ownership and credentials remain unchanged. An email match alone never adopts or reactivates an identity. Company ownership grants no global administrator authority.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_company" "managed" {
  name   = "Existing Owner Company"
  email  = "[email protected]"
  status = "active"
  billing_email = null
  tax_id        = null
  address_line1 = null
  address_line2 = null
  city          = null
  state         = null
  postal_code   = null
  country       = null
  # Copy the separately reviewed current default tier; never buy a subscription implicitly.
  initial_default_tier_id      = "99999999-9999-4999-8999-999999999999"
  initial_default_tier_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  initial_owner_email          = "[email protected]"
  initial_existing_owner_user_id = "33333333-3333-4333-8333-333333333333"
  grant_initial_portal_owner   = true
}

Initial owner and tier fields apply only at creation. They never restore an externally revoked grant or reconcile a later subscription change. Computed created_owner_user_id, initial_portal_owner_group_id and initial_grant_instance_id are original receipts, not evidence of current access. Manage later grants through the exact platform group-membership resource.

Import with terraform import oauth42_platform_company.managed COMPANY_CUSTOMER_UUID. Omit unknown creation-only fields when importing; import does not infer historical owners or issue a new grant or activation link. Updates retain separate billing ownership and detect stale configuration versions. Destroy explicitly deactivates the company, preserving its identities, grants, billing, schema and history. To reactivate the retained company, review and import its exact UUID. Names can repeat across separate billing accounts. Applying creation again with an explicitly selected existing owner creates a different company and billing account; it never adopts the retained company by name. A retained new-owner email requires explicit existing-owner selection before any new creation. Permanent deletion remains the separately reviewed action below.

Manage company configuration and lifecycle

Use a platform-tenant human profile with explicit read admin offline_access login consent, current global administrator authority and backend capability platform-company-management-v1. Writes require fresh original independent-factor proof and mandatory typed audit through commit. Ordinary tenant administrators and machines cannot acquire this global authority through company association.

Configure an existing company

oauth42_platform_company_configuration manages the complete contact profile and status of one existing company. Its customer_id is the target company, separate from the provider's platform customer. Required fields are name, canonical lowercase email and status (active, inactive or suspended). Omit or set optional contact fields to null to clear them. Contact values remain sensitive in Terraform state and saved plans; protect those artifacts.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_company_configuration" "selected" {
  customer_id   = "44444444-4444-4444-8444-444444444444"
  name          = "Managed Company"
  email         = "[email protected]"
  billing_email = null
  tax_id        = null
  address_line1 = null
  address_line2 = null
  city          = null
  state         = null
  postal_code   = null
  country       = null
  status        = "active"
}

Create configures an existing company. It does not provision a company, grant ownership or change a shared billing account, subscription or payment method. Import with terraform import oauth42_platform_company_configuration.selected COMPANY_CUSTOMER_UUID. Reads expose the separate computed billing_account_id and configuration_version; external billing-account reassignment requires explicit review and reimport. Saved-plan conflicts require a new review and plan. Versions cover company configuration and its billing binding; unrelated activity does not invalidate a contact-edit plan. Deletion checks current dependencies separately inside its transaction.

Status changes gate live tenant access while preserving memberships and unrevoked credentials. Reactivation can restore access for credentials that remain valid; separate credential or consent revocation remains effective. A retired tenant cannot be restored through contact/status configuration. The platform tenant must remain active. Destroy only relinquishes configuration management and preserves the company.

Review and explicitly deactivate or delete

data.oauth42_platform_company_management returns exact company and billing-account IDs, sensitive complete configuration_json, version and timestamps, including retirement metadata. Review counts cover primary/secondary/profile-owner identity references, groups, applications, OAuth registrations, organizations, service accounts, pending/active schedules, audit history, persistent references, billing history and the number of undeleted tenants sharing the billing account. The additional tenant_record_count includes all rows in every physical tenant table, including unlinked history and tables added by later schema migrations. Reading performs no lifecycle or billing operation.

Apply the review, inspect the target and retained dependencies, and manually replace configuration_version with its observed value. The action fixes the requested outcome; it never infers permission for permanent deletion from a primary-user count.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_company_management" "selected" {
  customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_company_deactivate" "selected" {
  config {
    customer_id           = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform apply -invoke=action.oauth42_platform_company_deactivate.selected

Deactivation makes the company inactive and preserves identities, secondary associations, resources, history and billing. It does not revoke global identities or cancel subscriptions. Use complete configuration to reactivate an undeleted company after a separate review.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_company_management" "selected" {
  customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_company_delete_permanently" "selected" {
  config {
    customer_id           = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform apply -invoke=action.oauth42_platform_company_delete_permanently.selected

Permanent deletion removes only an unused company record. Existing identities, role/group/application/service-account records, pending schedules, audit history or other persistent references block deletion. Billing history also blocks removal of its last undeleted tenant. Shared billing accounts survive; this action does not cancel charges or bypass protected-owner rules. Use deactivation when records must be retained. The platform tenant cannot be deleted.

Every action confirms the exact customer and manually pinned version. Missing targets, changed intent and stale versions are errors. There is no automatic replay, secret output, inverse import or implicit ordinary apply/destroy invocation. After an interrupted request, inspect current authorized company state before deciding on another explicit invocation.

Manage global user profiles and lifecycle

These operations require a platform-tenant human profile, explicit read admin offline_access login consent, a current global administrator role and backend capability platform-user-management-v1. Writes retain fresh original independent-factor proof and mandatory typed audit through commit. Ordinary tenant administrators and machines cannot inherit this authority.

Configure an existing identity

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_user_configuration" "selected" {
  user_id             = "33333333-3333-4333-8333-333333333333"
  routing_customer_id = "44444444-4444-4444-8444-444444444444"
  email               = "[email protected]"
  username            = null
  first_name          = "Managed"
  last_name           = null
  phone               = null
  is_active           = true
  email_verified      = false
}

oauth42_platform_user_configuration manages the complete email, nullable username, first/last name, phone, primary routing customer, active flag and email-verification flag. Use a canonical lowercase email; omitted nullable profile fields are cleared. Create updates an existing user and requires its configured routing customer to match current state. Import only reads. To change routing, import the current customer and user first, then edit routing_customer_id; use unassigned to clear primary routing.

terraform import oauth42_platform_user_configuration.selected CURRENT_ROUTING_CUSTOMER_UUID/USER_UUID

Primary routing can change implicit access to a tenant. It never transfers the separate profile_owner_customer_id or changes stored secondary membership rows. A new destination customer must be active. Updates confirm the prior routing customer and reviewed version; external routing or profile-ownership changes require explicit review and reimport. Email, verification, routing and deactivation changes invalidate existing issued credentials across tenants and cancel outstanding password-reset, invitation and email-verification links. Queued email requests recheck the current active account and recipient before issuing another link. The resource does not manage passwords, MFA or role grants. Destroy relinquishes profile management and preserves the identity.

Create a new global administrator deliberately

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
variable "initial_administrator_password" {
  type      = string
  sensitive = true
  ephemeral = true
}
resource "oauth42_platform_administrator_user" "selected" {
  email                        = "[email protected]"
  initial_password_wo          = var.initial_administrator_password
  grant_global_administrator   = true
  routing_customer_id          = "unassigned"
  username                     = null
  first_name                   = "New administrator"
  last_name                    = null
  phone                        = null
  is_active                    = true
  email_verified               = false
  send_initial_invitation      = false
}

oauth42_platform_administrator_user creates a new identity, initial customer association, profile ownership and an independent global administrator grant in one audited transaction. grant_global_administrator = true explicitly acknowledges that privilege. Existing emails or usernames cause conflict; creation never adopts another identity. The initial password must satisfy the selected customer’s policy and is a write-only creation input. Supply an ephemeral variable; it is absent from plans, state, outputs and API responses. Changing that input later does not reset the password.

New accounts require email_verified = false. After creation, the resource manages the same profile fields as the existing-user configuration resource. Do not manage the same user with both resources. has_global_administrator_grant reports current authority; external grant revocation is never automatically reversed. Initial grant identifiers record the creation receipt, not current authority. Import an existing identity with CURRENT_ROUTING_CUSTOMER_UUID/USER_UUID; no password or new grant is recovered or created.

Set send_initial_invitation = true to require SMTP acceptance of a 24-hour user-controlled invitation during creation; the account must be active. Optional invitation_application_url supplies an HTTP(S) destination without URL credentials. These invitation inputs are creation-only; use the explicit resend action later. SMTP acceptance does not guarantee inbox delivery. A failed transaction removes the new identity and grant; a late failure invalidates an already emailed link but cannot unsend the message. An interrupted create is never replayed automatically: inspect current inventory and import a committed identity deliberately.

Destroying the administrator resource deactivates the account and revokes issued credentials; it preserves the identity, profile, grants and tenant-owned resources. Review before using permanent deletion. Changing a creation-only setting requests replacement; the preserved identity can make recreation with the same email conflict, so review the plan and choose an explicit new identity or import.

Review and explicitly activate, deactivate or delete

oauth42_platform_user_management returns the exact identity, primary customer, distinct profile owner, complete configuration, credential cutoff, effective group count, stored tenant and application assignment counts, active/pending schedule reference count and configuration_version. Sensitive profile data remains in state and saved plans; protect those artifacts. Apply the review, inspect the identity and dependencies, and manually pin the observed version in the chosen action. Use target_customer_id = "unassigned" for an unrouted identity.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_user_management" "selected" {
  user_id            = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_user_activate" "selected" {
  config {
    user_id               = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_user_management" "selected" {
  user_id            = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_user_deactivate" "selected" {
  config {
    user_id               = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_user_management" "selected" {
  user_id            = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_user_delete_permanently" "selected" {
  config {
    user_id               = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform apply -invoke=action.oauth42_platform_user_deactivate.selected

Activation does not restore previously revoked credentials. Deactivation invalidates issued access/refresh credentials, codes and sessions across tenants while preserving the identity, password, factors, memberships and grants. Permanent deletion physically removes the global identity and identity-owned records; tenant-owned applications and typed audit attribution survive. Cancel active or pending schedules targeting, created by or authorized by the identity before permanent deletion. Other restrictive persistent references return an explicit conflict and roll back atomically.

Disabling, deleting or removing the primary access of the last active protected owner is refused until another current active owner exists. Self-deactivation or self-deletion invalidates the calling credential after success. Missing targets, wrong routing customers and stale versions are errors; mutations are never automatically retried. Ordinary apply and destroy do not invoke or reverse lifecycle actions. These actions have no secret outputs or inverse import operation.

Review and invoke global user security actions

oauth42_platform_user_security_target reads the exact user, current routing customer, separate profile owner, email/username, account flags and issued-credential cutoff. Email and username are sensitive Terraform attributes; no password hash, factor secret or token is returned. Use a platform-tenant human profile, explicit read admin offline_access login consent, a current global administrator role and backend capability platform-user-security-actions-v1. Mutations require fresh original authentication with an independent factor through mandatory audit and commit.

Confirm user_id and the current routing target_customer_id. Use unassigned for an unrouted account; the response then has a null routing customer. Routing never transfers global profile ownership. Apply the data read, review the target, then manually replace the example version with its observed configuration_version. Identity, routing, ownership or security-state changes require a new review. A data refresh does not rewrite the pinned action value.

Revoke issued credentials across all tenants

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_user_security_target" "selected" {
  user_id            = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_user_sessions_revoke_all" "selected" {
  config {
    user_id               = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform apply -invoke=action.oauth42_platform_user_sessions_revoke_all.selected

This explicitly invalidates the account’s existing issued access and refresh credentials, authorization codes, browser registries and session rows across all tenants. Other accounts in a shared browser registry survive. Passwords, MFA enrollment and role membership remain. Revocation includes sessions created after the review. Self-revocation succeeds once and invalidates the calling credential after commit. Exact single-session removal is a separate capability.

Send user-controlled recovery or activation links

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_user_security_target" "selected" {
  user_id            = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_user_password_recovery_send" "selected" {
  config {
    user_id               = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform apply -invoke=action.oauth42_platform_user_password_recovery_send.selected

The password recovery action sends a link that expires 15 minutes after creation to the reviewed existing active account email. The recipient chooses the password through the normal recovery flow. The action leaves the current password, MFA and issued credentials unchanged and returns no link or token.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_user_security_target" "selected" {
  user_id            = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
action "oauth42_platform_user_invitation_resend" "selected" {
  config {
    user_id               = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}
terraform apply -invoke=action.oauth42_platform_user_invitation_resend.selected

The invitation action resends the existing active account’s activation/recovery email with a 24-hour link. It preserves identities, tenant memberships and role grants; organization invitations are managed separately. Both notification actions verify SMTP acceptance, which does not guarantee inbox delivery. An explicitly repeated invocation can send another message.

Ordinary apply and destroy do not invoke or reverse these actions. There is no automatic mutation replay. Mandatory audit failures are checked before email dispatch where possible. A later authority, proof or commit failure invalidates the link, but an already accepted email cannot be unsent. Terraform reports failure; inspect the current state before another explicit invocation.

Own an exact global application group assignment

oauth42_platform_application_group manages one application-to-group assignment by its durable assignment_id. Use a platform-tenant human profile, explicit read admin offline_access login consent, a current global administrator role and backend capability platform-application-group-ownership-v1. Creation and removal require fresh original authentication with an independent factor; current role, consent and mandatory typed audit remain authoritative through commit.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_application_group" "selected" {
  application_id     = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  group_id           = "55555555-5555-4555-8555-555555555555"
  group_customer_id  = "44444444-4444-4444-8444-444444444444"
}
data "oauth42_platform_application_group" "selected" {
  application_id     = oauth42_platform_application_group.selected.application_id
  target_customer_id = oauth42_platform_application_group.selected.target_customer_id
  group_id           = oauth42_platform_application_group.selected.group_id
  group_customer_id  = oauth42_platform_application_group.selected.group_customer_id
  depends_on         = [oauth42_platform_application_group.selected]
}

Confirm the application owner with target_customer_id and the group owner independently with group_customer_id. Their physical storage must match. A genuine platform-stored portal group can belong to another customer; matching owner UUIDs are not required. A group in a different physical tenant schema cannot be assigned to this application. Both the application and its paired OAuth client must be active for a new assignment.

Create records the assignment from its own committed transaction. Existing assignments require explicit import. Import and refresh read the exact assignment UUID; an external removal and replacement is never silently adopted. If Terraform reports a replacement, review it, remove the old state deliberately, then import the replacement.

terraform import oauth42_platform_application_group.selected APPLICATION_OWNER_UUID/APPLICATION_UUID/GROUP_OWNER_UUID/GROUP_UUID

Destroy removes only the exact owned assignment. It preserves the application, OAuth client, group, memberships and other assignments. A changed assignment UUID causes refusal; an already absent assignment is ordinary resource absence. Identity changes replace the resource. Network uncertainty never triggers an automatic mutation replay: inspect the current assignment and import it deliberately if the earlier create committed.

The same-named data source reports assigned, nullable assignment UUID, assigning actor and timestamp, physical storage customer, group name and SCIM-managed status. An unassigned pair returns assigned = false with null receipt fields. This assignment does not create group membership, tenant membership or management authority; effective membership and application access policies still determine access.

Global application configuration, rotation and deletion

oauth42_platform_application_configuration manages the complete name, nullable description, ordered redirect URIs, scopes and active status of an existing global application and its paired OAuth client. Select the platform tenant in a human profile with explicit read admin offline_access login consent and scopes = ["read", "admin"]. Backend capability platform-application-management-v1, a current global administrator role and fresh original authentication with an independent factor are required for mutations. A tenant administrator or machine cannot inherit global write authority.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_application_configuration" "selected" {
  application_id     = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  name               = "Managed global application"
  description        = null
  redirect_uris      = ["https://app.example.com/callback"]
  scopes             = ["openid", "profile", "email"]
  is_active          = true
}

Set the exact owning target_customer_id and existing application_id. Create updates that existing configuration; it does not register a new application or generate a credential. Import only reads configuration. Omit description to clear it; use explicit lists for redirects and scopes. The resource preserves unrelated first-party, signup, branding, access-control and security policy fields. Sensitive application metadata remains in Terraform state and plans; protect those artifacts.

terraform import oauth42_platform_application_configuration.selected TARGET_CUSTOMER_UUID/APPLICATION_UUID

Refresh detects configuration drift. Writes use the previously observed version, which includes the paired client, credential generation and current assignments. A stale saved plan fails with 412; review and plan again rather than automatically retrying. Ambiguous application identities or inconsistent client routing fail closed. Changing the paired OAuth client requires an explicit review and reimport. Current human authority and mandatory typed audit remain transactional through commit.

Setting is_active = false deactivates both the application and OAuth client. Setting it back to true cannot bypass restoration and credential rotation. Destroy only stops managing the configuration: the application, credentials and assignments remain as they are. Use the separate explicit protected rotation action below to replace an active application credential.

data.oauth42_platform_application_management reports the exact application, owning customer, OAuth client UUID/client ID, credential generation, both active states, first-party status, user/group/service-account assignment counts and observed version. Complete configuration is in sensitive configuration_json. Reading creates no client or grant and returns no secret material.

Protected credential rotation and recovery

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_application_management" "selected" {
  application_id     = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
# Apply the read, inspect the exact active customer/application/client and copy
# its complete configuration_version. The placeholder is not an approval.
# Select an unlocked native OS protected store before explicit invocation:
# terraform apply -invoke=action.oauth42_platform_application_rotate.selected
# The old secret stops working at commit. If delivery is uncertain, keep this
# SAME operation ID, original version and destination to recover for 24 hours.
action "oauth42_platform_application_rotate" "selected" {
  config {
    application_id        = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    operation_id          = "55555555-5555-4555-8555-555555555555"
    secret_store_profile  = "application-production"
  }
}
# Explicitly hand the saved JSON (binding and values) to a trusted consumer:
# oauth42-terraform-login delivery-consume --profile application-production \
#   --operation-id 55555555-5555-4555-8555-555555555555 -- /absolute/trusted-consumer
# No generated credential is returned in Terraform state or an action output.

action.oauth42_platform_application_rotate requires protected-secret-delivery-v1, the current global human role, explicit admin consent and fresh original independent-factor proof. Inspect the exact customer, application, paired client and complete configuration version, then manually pin the version and a new operation UUID. Both application and client must be active. Plan and ordinary apply create no recipient key and perform no rotation.

Select secret_store_profile explicitly. Linux needs an unlocked native Secret Service; macOS needs native cgo builds and Keychain access for the provider and helper; Windows uses user-bound DPAPI. An unsupported or unavailable store fails before rotation. The provider persists and verifies a separate recipient key for each operation. No generated credential, recipient private key or encrypted capsule enters Terraform state, plans or action outputs.

The old credential stops working when the backend commits. Local delivery follows that commit and can fail independently. If the reply or local storage is uncertain, keep the same operation UUID, original configuration version and destination. Invoke the same action to recover its original encrypted result for 24 hours. Recovery requires current authority and the same active credential generation; a changed recipient, revoked authority, expired receipt or newer generation fails. Never change the operation UUID merely to retry an uncertain result.

Use delivery-inspect --profile NAME --operation-id UUID to inspect only the stored public binding and compare its generation with current API metadata. After verified local storage, hand the saved JSON to an explicitly chosen trusted consumer with the helper command in the example. The consumer receives the original binding and credential values on standard input. The helper invokes no shell and places no secret in arguments; protect the consumer's output. Each stored result retains its original generation metadata. Server recovery expiry does not erase an active credential from your OS store, and local possession alone does not prove that an older generation remains current.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_application_management" "selected" {
  application_id     = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
# Deactivate the application first. Apply the read, review both active flags,
# owner, credential generation and assignments, then copy the observed version.
# The placeholder is not an approval. Invoke only after that explicit review:
# terraform apply -invoke=action.oauth42_platform_application_delete.selected
action "oauth42_platform_application_delete" "selected" {
  config {
    application_id        = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}

The separate action.oauth42_platform_application_delete permanently removes the previously deactivated application, OAuth client, routing entry and all of that application's assignments. Review current configuration, credential generation and assignments, then manually pin configuration_version. An active application or client prevents deletion. Assignment changes require a new review even if the count stays the same.

terraform plan -invoke=action.oauth42_platform_application_delete.selected
terraform apply -invoke=action.oauth42_platform_application_delete.selected

Deletion has no import, persistent ownership or inverse destroy operation. The provider never automatically retries an uncertain deletion, never treats not-found as success, and never recreates the application. Inspect authorized current state before deciding whether another explicit invocation is appropriate. Current role, consent and fresh original proof must survive mandatory audit and commit; an audit failure rolls back the entire deletion.

Platform group inventory

oauth42_platform_groups and oauth42_platform_group require an explicitly expiring platform account, platform_only, the platform customer UUID, independently approved groups_read, and current OAuth read or admin scope. Company/application approvals and ordinary tenant-wide administration do not grant this authority. Reads recheck account, token and approval after database waits.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_groups" "catalog" {
  provider           = oauth42.platform
  target_customer_id = "10000000-0000-0000-0000-000000000001"
  limit              = 1
  offset             = 1
}

data "oauth42_platform_group" "example" {
  provider = oauth42.platform
  group_id = "20000000-0000-0000-0000-000000000001"
}

Replace the example group_id with its UUID from the catalog. The catalog accepts optional target_customer_id (owning customer UUID) and search over group/company name (case-insensitive SQL wildcard search, at most 2048 bytes, no NUL). limit is 1–100, default 50; offset is a zero-based row offset, default 0. Rows sort by created_at descending, then UUID. The computed total and groups share one query snapshot. Invalid, repeated or unknown query fields fail explicitly.

Each group includes id, name, description, customer_id, company_name, organization_id, organization_name, is_scim_managed, scim_external_id, member_count, created_at and updated_at. Nullable historical fields remain null. Ownership may differ from physical storage for legacy portal groups; organizations and members are resolved from the actual storage tenant. Ambiguous duplicate group UUIDs fail closed.

The detail returns group plus complete members with user_id, email, first_name, last_name, is_active and added_at. Counts and members use effective grants, so an expired scheduled-only membership disappears immediately while independent access remains. Detail counts and member records share a query snapshot. A collection exceeding 100,000 members or inconsistent stored identities is an explicit error; no successful truncated result.

Names, member identities and SCIM identifiers remain in Terraform state and saved plans even though group/member output is marked sensitive. Protect those artifacts. These data sources only read: removing them does not delete groups or revoke membership. Use the separate human deletion action below for an exact empty group; use the separate membership contract below for independent grants or explicit whole-membership revocation.

Global group memberships

oauth42_platform_group_membership manages one independent grant for an exact existing group, user and owning customer. It requires a human profile for the platform customer, explicit admin consent, a current global administrator role, and the platform-group-memberships-v1 backend capability. Writes require fresh original authentication with an independent factor through mandatory audit and commit. A machine or tenant administrator cannot inherit global authority.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
resource "oauth42_platform_group_membership" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  user_id            = "55555555-5555-4555-8555-555555555555"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  adopt_tenant       = false
}

The target customer can differ from physical storage, including historical portal roles stored in the platform tenant. Duplicate group identities fail closed. The target user must be active and currently belong to the owning tenant; organization and SCIM lifecycle restrictions still apply. Global administrator grants use the exact platform-owned o42admin role. A namesake in another tenant confers no platform authority.

adopt_tenant = true explicitly permits an exact portal owner, admin or read role to establish missing tenant membership and initialize absent default routing. Only platform-stored tenant-qualified roles grant portal administration; tenant-local namesakes remain ordinary groups. Explicit adoption also retains the established first-party platform membership. An existing primary-only member receives a generic membership row so the portal role is usable; it is not promoted to a tenant-admin membership role. Global profile ownership never transfers. Tenant membership and routing remain after destroy. Ordinary groups never adopt a user. Owner/admin grants retain current billing seat capacity; SCIM-managed groups must be managed through their SCIM provider.

Import existing independent grants explicitly. Creation records the exact grant returned by its committed transaction, so a later replacement cannot be adopted during readback. Terraform records independent_grant_id separately from the physical grant_instance_id shared with schedules. If access is removed and independently regranted, Terraform refuses to adopt or revoke the replacement grant. Review it, explicitly remove stale state if appropriate, and import the replacement only when you intend to manage it.

terraform import oauth42_platform_group_membership.selected TARGET_CUSTOMER_UUID/GROUP_UUID/USER_UUID

Destroy removes only the independent grant. Scheduled access remains until its own lease expires or is explicitly revoked. The last active global administrator or portal owner cannot be removed before another active owner exists. An administrator can explicitly relinquish their own role when a current successor remains; later requests lose that authority. Mutation races fail the observed version check and require a fresh review.

data.oauth42_platform_group_membership reports exact ownership, nullable grant identities, independent_grant, separate effective_access, scheduled_lease_count, SCIM status and configuration_version. No grant is represented as false/null, while a missing group or user is an error. Refresh always checks current authority. Removing this data source changes no access.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_group_membership" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  user_id            = "55555555-5555-4555-8555-555555555555"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
# Apply this read and review the exact target and both grant identities.
# Copy the observed configuration_version below after reviewing the loss of
# independent access AND current schedule leases. The hash is a placeholder.
action "oauth42_platform_group_membership_revoke" "selected" {
  config {
    group_id              = "33333333-3333-4333-8333-333333333333"
    user_id               = "55555555-5555-4555-8555-555555555555"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}

The separate action.oauth42_platform_group_membership_revoke revokes the entire reviewed membership instance, including current schedule leases. The example hash is a placeholder. Read the target first, review both grant identities and the attached lease count, then manually pin its observed version. Changes to attached schedule leases invalidate that version. Do not derive irreversible intent from an automatically refreshed data source.

terraform apply -invoke=action.oauth42_platform_group_membership_revoke.selected

This action has no import, undo or automatic retry. Repeated revocation of an absent membership fails. Future independent grants and future schedule activations are separate decisions; cancel the schedule separately to prevent future activation. After an interrupted call, inspect current authorized state before making another explicit decision. UUIDs, role names and grant metadata remain in Terraform state and saved plans; protect those artifacts.

Manage an existing protected role definition

oauth42_platform_protected_group_metadata manages only the description of an existing o42admin or exact tenant-qualified portal owner, admin or read group. Role names and grants remain separate. Use a platform-tenant human profile with current global administration, explicit read admin offline_access consent, scopes = ["read", "admin"], and backend capability protected-group-management-v1. Writes require original primary authentication and an independent factor completed within five minutes. Refresh does not renew that proof.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
# Configure the description of an existing reserved role. Names and grants are separate.
# Import: terraform import oauth42_platform_protected_group_metadata.selected TARGET_CUSTOMER_UUID/GROUP_UUID
# Destroy only relinquishes metadata management; it preserves the role definition.
resource "oauth42_platform_protected_group_metadata" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
  description        = "Reviewed protected role description"
}

Create configures an existing role; it cannot create or rename a role. Omit description or set it to null to clear it; descriptions accept at most 1,000 characters. Import with TARGET_CUSTOMER_UUID/GROUP_UUID. Refresh detects description drift, and apply restores the declared description. Destroy only relinquishes metadata management and preserves the role and its grants.

The owning customer can differ from physical storage for historical portal roles. The resource records both and pins its observed version for updates. Owner mismatches, ambiguous identities, SCIM ownership and physical storage changes fail closed. Inspect a storage change before explicitly reimporting. A tenant-local namesake does not acquire platform-stored portal authority through this resource.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_protected_group_configuration" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}

The read-only review reports group_id, target_customer_id, storage_customer_id, platform_customer_id, name, nullable description, is_scim_managed, member_count, scheduled_reference_count and configuration_version. Counts describe current effective members and pending or active schedules; they are checked again under the deletion lock. Reading and ordinary apply never invoke deletion.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_protected_group_configuration" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
# Review owner, physical storage, role name, members and schedules before confirming.
# Copy the observed configuration_version; this placeholder is not approval.
# Invoke once: terraform apply -invoke=action.oauth42_platform_protected_group_delete.selected
action "oauth42_platform_protected_group_delete" "selected" {
  config {
    group_id                       = "33333333-3333-4333-8333-333333333333"
    target_customer_id              = "44444444-4444-4444-8444-444444444444"
    storage_customer_id             = "10000000-0000-0000-0000-000000000001"
    configuration_version          = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    confirm_delete_role_definition = true
  }
}

Review the exact role, owner, physical storage, members and schedules, then manually pin the observed version and set confirm_delete_role_definition = true. Do not derive irreversible intent from an automatically refreshed data source. Invoke explicitly with terraform apply -invoke=action.oauth42_platform_protected_group_delete.selected. Effective members and pending or active schedules prevent deletion. Remove those references deliberately first; deleting a definition does not revoke a populated role.

Metadata updates and deletion retain current global grants, consent, original proof and typed audit through commit. Ordinary tenant administrators and machine creators cannot supply that authority. The deletion action has no output, import, undo or automatic retry; a repeated invocation fails. After an interrupted request, inspect current authorized state before deciding whether to invoke again. UUIDs, role descriptions and versions remain in Terraform state and saved plans; protect those artifacts.

Delete an exact empty global group

data.oauth42_platform_group_deletion_target reads the exact group, owning customer, physical storage customer, name, SCIM status, effective member count, pending/active schedule count and observed configuration version. Use a human profile selected into the platform tenant, explicit read admin offline_access login consent, scopes = ["read", "admin"], a current global administrator role and backend capability platform-group-deletion-v1. Machine creators and ordinary tenant administrators cannot supply this authority.

terraform {
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  endpoint           = "https://api.example.com"
  human              = true
  client_id          = "REGISTERED_PUBLIC_CLIENT"
  customer_id        = "10000000-0000-0000-0000-000000000001"
  subject_id         = "11111111-1111-4111-8111-111111111111"
  scopes             = ["read", "admin"]
  credential_command = ["/usr/local/bin/oauth42-terraform-login", "credential", "--profile", "work"]
}
data "oauth42_platform_group_deletion_target" "selected" {
  group_id           = "33333333-3333-4333-8333-333333333333"
  target_customer_id = "44444444-4444-4444-8444-444444444444"
}
# Apply the read, review the exact owner, group, members and schedules, then copy
# its configuration_version below. The placeholder is not a usable approval.
# Invoke once: terraform apply -invoke=action.oauth42_platform_group_delete.selected
action "oauth42_platform_group_delete" "selected" {
  config {
    group_id              = "33333333-3333-4333-8333-333333333333"
    target_customer_id    = "44444444-4444-4444-8444-444444444444"
    configuration_version = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  }
}

Apply the read and review the exact target. Copy its configuration_version into the action before invoking it. The example hash is a placeholder. Ownership can differ from physical storage for legacy portal roles; supply the owning customer, not the provider tenant or storage customer. Wrong ownership and ambiguous group identities fail closed. External group edits make the pinned intent stale and require a new review.

Deletion is permanent and requires fresh original primary and independent-factor proof through commit. Effective members prevent deletion. Pending and active permission schedules must be cancelled first, including schedules that have not granted access yet. SCIM-managed groups must be removed through their SCIM provider. Empty protected role definitions may be deleted under this global authority; this action does not rename roles, grant membership or create replacement groups.

Current account, consent, role and factor checks remain live; a role revocation committed while waiting for the target prevents deletion. Mandatory typed audit and deletion commit together. Audit failure or proof expiry rolls the deletion back.

The action has no import, managed resource state or inverse destroy. It never retries automatically. A repeated invocation after deletion fails with not-found. An interrupted request has an unknown outcome: inspect current authorized inventory before making a new explicit decision. Removing the data source or running Terraform destroy does not delete a group. Protect state and saved plans containing private group names and identity metadata.

Effective groups for one user

oauth42_platform_user_groups uses the same explicit groups_read approval, platform account and read/admin scope as group detail. It additionally requires the backend platform-user-groups-v1 contract. Replace user_id below with the exact global user UUID.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_user_groups" "example" {
  provider = oauth42.platform
  user_id  = "30000000-0000-0000-0000-000000000001"
}

The response binds the requested user identity and returns all current effective groups. Each row contains id, name, description, customer_id, member_count, is_scim_managed and added_at. The owning customer remains visible even for legacy portal groups physically stored in the platform tenant. Groups and memberships are correlated by physical tenant as well as UUID, and ambiguous duplicate group identities fail closed.

Rows sort by added_at descending, then group UUID. Empty membership is an empty list; a missing user is an error. Physical memberships without an independent or currently effective scheduled grant are excluded. More than 100,000 groups fails explicitly, never as a truncated successful list. Unknown query parameters fail, and current platform authority is rechecked after database waits.

This data source does not change user profiles or membership. It refreshes when memberships change and fails after approval revocation. Group identities and membership history are sensitive and remain in state and saved plans; secure those artifacts.

Global company catalog and detail

oauth42_platform_companies and oauth42_platform_company require a dedicated expiring platform account, explicit platform_only mode and platform customer UUID, independent companies_read approval, and OAuth read or admin scope. An application/feature approval or ordinary tenant-wide account grants no company read authority. Reads recheck current identity and approval after database waits.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_companies" "catalog" {
  provider   = oauth42.platform
  sort_by    = "name"
  sort_order = "asc"
  limit      = 1
  page       = 2
}

data "oauth42_platform_company" "example" {
  provider   = oauth42.platform
  company_id = "10000000-0000-0000-0000-000000000001"
}

Catalog inputs and output

The catalog accepts optional search over name/email (case-insensitive SQL wildcard search, at most 2048 bytes and no NUL), status (active, inactive or suspended), sort_by (name by default, created_at, user_count, app_count or org_count), and sort_order (asc by default, or desc). Company UUID breaks sorting ties. page is one-based and defaults to 1; limit is 1–100 and defaults to 20. Invalid bounds and overflow fail explicitly.

Computed total, total_pages and sensitive companies share one query snapshot. Each company contains id, name, email, billing_email, status, tax_id, address_line1, address_line2, city, state, postal_code, country, created_at, updated_at, last_activity, user_count, app_count and org_count. Counts describe active users whose current default customer_id matches the company, active paired applications/clients, and active organizations. Standalone OAuth clients and service accounts are excluded from application counts. Last activity is the latest login of an active user whose current default customer_id matches the company.

Exact company detail

Detail requires company_id, the target company UUID; computed provider customer_id remains the platform tenant. It returns sensitive company metadata and complete users, applications and organizations collections, including inactive records. Users contain id, email, nullable username/first_name/last_name, is_active and created_at. Applications contain id, customer_id, client_id, name, is_active and created_at; each retains its exact owning tenant. Organizations contain id, name, slug, nullable description, is_active, created_at and active-user membership count. Secret material is absent.

Detail collections and company metrics share one database statement snapshot. A collection exceeding 100,000 rows fails explicitly; it never returns an apparently complete first 100 rows. The provider also rejects responses above 16 MiB. stats contains total_logins30_d (stored tenant session creations for users whose current default customer_id matches the company), active_users30_d (users with a recent last login), new_users30_d, and nullable total_api_calls30_d. Unmeasured API calls remain null, never a fabricated zero.

Sensitive subscription_json preserves the complete generated CustomerSubscription contract as normalized JSON, or null when no subscription exists. Use jsondecode to inspect subscription/tenant IDs, current tier and feature limits, billing cycle/status/periods, startup/free-tier flags, cancellation and explicit skip-payment policy, Stripe subscription identifier, dunning stage/deadlines, scheduled downgrade tier/cycle/deadlines, active features, pricing and usage/overage fields. Numeric precision is preserved; JSON key order/whitespace does not cause drift. Subscription is read separately and may observe a later billing snapshot. This read creates no Stripe state and changes no billing policy. Subscription readback fails explicitly when usage queries fail or persisted billing status, cycle or tier-feature objects are invalid. Such errors never become zero usage, an active subscription or empty entitlements.

Contact, tax, user and subscription data remain in state and saved plans even when display is sensitive. Protect those artifacts. These are read-only data sources with no import/destroy lifecycle; removing them does not delete a company. Company configuration, creation, retirement and financial changes use the separately documented resources and reviewed actions; these metadata reads do not perform them.

Global application configuration and assignments

These four data sources require the explicit platform provider, a dedicated expiring account, an independently approved applications_read grant and OAuth read or admin scope. Tenant-wide account authority and unrelated platform approvals cannot authorize these reads. Every request checks current account, scope and approval, including after database waits.

oauth42_platform_applications and oauth42_platform_applications_export

Use optional target_customer_id to select an exact owning tenant, or omit it for the global catalog. Optional query searches name/client ID case-insensitively. The name set matches case-insensitive SQL wildcard patterns; client_id matches exact IDs. Values are OR within a field and AND across fields. Each repeated field accepts up to 50 values, each at most 2048 bytes with no NUL. Sort by created_at (default), name or client_id, in desc (default) or asc order; owning customer and application UUID provide stable ascending ties.

The catalog accepts limit (1–100, default 50), nonnegative row offset and one-based page. Explicit offset takes precedence; otherwise offset is (page − 1) × limit. It returns the actual offset, matching total from the same database snapshot, platform customer_id and sensitive applications. Both active and inactive applications are visible. Separate reads can observe changed page boundaries.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_applications" "catalog" {
  provider           = oauth42.platform
  target_customer_id = "10000000-0000-0000-0000-000000000001"
  name               = ["TF platform%"]
  sort               = "name"
  order              = "asc"
  limit              = 1
  page               = 2
}

data "oauth42_platform_applications_export" "catalog" {
  provider           = oauth42.platform
  target_customer_id = "10000000-0000-0000-0000-000000000001"
  name               = ["TF platform%"]
  sort               = "name"
  order              = "asc"
}

Each application includes its owning customer_id, id, organization_id, client_id, credential_version, name, description, redirect URIs, scopes, grant/response types, logo/client/policy/terms URIs, active/first-party/public/signup flags, access-control mode, default group IDs, timestamps, owner name/email and typed security settings. Security settings preserve MFA, email-primary/email-second-factor policy, DPoP, PAR, client authentication method and public JWKS. Invalid persisted policy fails explicitly. Client secrets, hashes and private keys are never returned.

The export accepts the same filters and sorting without pagination. Sensitive csv contains all matching records; row_count verifies completeness. Its first six columns remain id, client_id, name, is_active, is_first_party and created_at; appended columns contain the remaining configuration, with arrays/objects encoded as JSON cells and null values as empty cells. Spreadsheet formula prefixes are escaped. Responses above 16 MiB fail explicitly; narrow filters rather than accepting a partial export.

oauth42_platform_application and oauth42_platform_application_groups

Both require target_customer_id and application_id. These bind the owning tenant and UUID explicitly; provider customer_id remains the platform tenant. Detail returns the complete sensitive application object described above. Groups returns total and assigned groups, each with id, name, nullable description and SCIM-managed flag. An application in a different tenant cannot satisfy the requested identity. No assignment or application mutation is performed.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_application" "example" {
  provider           = oauth42.platform
  target_customer_id = "10000000-0000-0000-0000-000000000001"
  application_id     = "22222222-2222-4222-8222-222222222222"
}

data "oauth42_platform_application_groups" "example" {
  provider           = oauth42.platform
  target_customer_id = "10000000-0000-0000-0000-000000000001"
  application_id     = "22222222-2222-4222-8222-222222222222"
}

Configuration, owner contact information and CSV remain in Terraform state and saved plans even when sensitive display hides them. Protect state, backups and exported files. These data sources have no import or destroy lifecycle; removing configuration does not delete applications or groups.

Platform sessions and audit history

These four global data sources require the explicit platform provider and a dedicated account with an independent sessions_read or audit_read approval plus OAuth read/admin scope. Other platform approvals grant neither capability. They expose stored session records and retained audit history, with no session-revocation or history-deletion action.

Filtering and pagination

Both families accept optional query, an exact email set, and sort/order. Search is case-insensitive with SQL wildcard patterns preserved; audit also searches retained metadata and current SCIM group labels/member emails. Repeated values are OR within a field and AND across fields. Each repeated field allows 50 values; each string allows 2048 bytes with no NUL. Sort defaults to created_at, also accepts email, plus last_activity_at for sessions or event_type for audit. Order defaults to desc; asc is supported. Owning-tenant UUID and record UUID provide stable ascending ties.

Page data sources accept limit (1–100, default 50), a nonnegative row offset, and an optional one-based page. Explicit offset takes precedence; otherwise offset is (page − 1) × limit, with page defaulting to 1. Overflow is rejected. Computed offset is the actual row offset, and total shares the page's statement snapshot. Independent reads may see newly added history. Top-level customer_id identifies the acting platform tenant; each record's customer_id identifies its owning tenant. Record identity is the tenant/UUID pair.

oauth42_platform_sessions and oauth42_platform_sessions_export

The optional status set accepts active, expired and revoked. Active means unrevoked with future expiry; expired means unrevoked with elapsed expiry. A revoked record stays revoked regardless of its expiry. Sensitive sessions include id, owning customer_id, nullable user_id, email, IP address, user agent, creation/last-activity/expiry timestamps, nullable revocation time and risk score. These are stored records, not proof that a client is currently online.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_sessions" "desktop" {
  provider = oauth42.platform
  query    = "managed-desktop"
  status   = ["active", "expired"]
  sort     = "created_at"
  order    = "asc"
  limit    = 1
  page     = 2
}

data "oauth42_platform_sessions_export" "desktop" {
  provider = oauth42.platform
  query    = "managed-desktop"
  status   = ["active", "expired"]
  sort     = "created_at"
  order    = "asc"
}

oauth42_platform_audit and oauth42_platform_audit_export

The optional event_type set accepts case-insensitive patterns. Sensitive entries contain record/tenant UUIDs, event type, creation time, nullable human user UUID/email, client identifier, IP address and user agent. Typed attribution uses actor_principal_id, actor_kind (human, service_account or oauth_client) and actor_native_identity_id. Unattributed legacy records retain null typed fields; a historical creator never becomes the actor. Attribution remains historical and grants no current permission.

Actual SCIM membership events additionally expose nullable scim_membership: group UUID, current display name resolved in that record's tenant, organization UUID, hashed provisioning token identifier, and added/removed members with user UUID plus nullable current email/display name. Ordinary group history has no SCIM label. Removed native identities and null legacy fields remain visible without automatic restoration or inferred ownership.

terraform {
  required_version = ">= 1.14, < 2.0"
  required_providers {
    oauth42 = { source = "oauth42/oauth42" }
  }
}
provider "oauth42" {
  alias         = "platform"
  endpoint      = "https://api.example.com"
  platform_only = true
  customer_id   = "10000000-0000-0000-0000-000000000001"
  scopes        = ["read"]
}
data "oauth42_platform_audit" "groups" {
  provider   = oauth42.platform
  event_type = ["portal.group.created", "scim.group.members.created"]
  sort       = "event_type"
  order      = "asc"
  limit      = 50
  offset     = 0
}

data "oauth42_platform_audit_export" "groups" {
  provider   = oauth42.platform
  event_type = ["portal.group.created", "scim.group.members.created"]
  sort       = "event_type"
  order      = "asc"
}

Exports take the same filters/sort but no pagination inputs, and return sensitive csv, verified row_count and acting customer_id. All matching rows are returned, with spreadsheet formula escaping; responses above 16 MiB fail explicitly. Audit CSV includes a leading column-guide comment. Its trailing columns retain owning tenant, human user and typed actor identity. Session CSV appends owning tenant and user UUID to its session columns.

Every audit export records its own mandatory typed export event. If attribution/audit fails or authority expires while waiting, the export fails and its transaction rolls back. Broad later queries can include earlier export events. Page reads and session exports do not change session state. Sensitive flags hide ordinary Terraform display but do not encrypt state, plans or CSV files; protect each artifact. Removing a data source only discards its snapshot and does not erase history or revoke sessions.

Versioning and current limitations

Provider schemas may evolve. Back up state securely, review the release notes and plan, and test a version change against a disposable environment before changing production automation. Do not edit state JSON to bypass schema or tenant safeguards. Provider version migrations and a final main-backend acceptance run are required before a published release.

Remaining user-administration operations, organization/platform administration and policy, billing, and additional standalone actions remain tracked work. Some need API changes for typed machine actors and current authorization. Browser login, biometric proof, native push delivery, and protocol callbacks are not infrastructure resources; administrative APIs in those families are still inventoried separately.

Organization configuration changes, invitation creation and member removal require a current organization-admin role. Tenant membership, historical creator identity and tenant-wide machine scope do not substitute for that grant. SCIM deprovisioning overrides retained manual roles. Mutations and typed audit commit together, with current token and role expiry checked after audit waits. The organization resource supports reviewed creation, configuration, import and retained-history deactivation. Organization invitations use separately reviewed issuer intent, observed SMTP delivery and authenticated recipient confirmation. Their resource and three data sources are described in the organization invitation section above; unused invitation revocation does not remove an already accepted role.

Platform delegation approval API

The backend provides three approval operations.

  • POST /admin/platform-grants — approve one capability.
  • GET /admin/platform-grants — read paginated approval history.
  • DELETE /admin/platform-grants/GRANT_UUID — revoke an approval.

These APIs require a current human administrator of the platform tenant, 10000000-0000-0000-0000-000000000001, who also holds the actual o42admin group grant. Creation additionally requires genuine primary authentication and an independent factor completed within five minutes. Refreshing a token does not refresh that proof. A service account cannot approve its own platform privileges.

Create a dedicated platform service account with tenant_wide = true, explicit read/write or admin scopes and expires_in_days between 1 and 365. The approval request names its service_account_id, one platform_capability (features_read, features_write, social_providers_read, social_providers_write, statistics_read, waitlist_read, audit_read, sessions_read, applications_read, companies_read, groups_read, users_read, subscription_tiers_read, service_accounts_read, service_accounts_rotate or service_accounts_delete) and an explicit RFC 3339 expires_at. The grant cannot outlive the account or extend beyond 365 days. Tenant-wide scope alone never grants platform authority; read and write approvals are separate. Customer-owned accounts, application-scoped accounts, wildcard capabilities and indefinite delegations are rejected.

Grant identity, capability and expiry are immutable. Revoke an existing approval before replacing or extending it; issuance of the replacement requires fresh human proof. DELETE retains the original attribution and revocation history, returns 204 for an already revoked known grant, and returns 404 for an unknown UUID. Current human platform administrators can remove access without a new factor ceremony. Mandatory audit and each grant mutation commit together. GET returns grants, total, limit and offset; the default page size is 50 and maximum is 100. Responses identify the exact machine and typed approving/revoking principals without exposing credentials.

The human-authorized platform grant resource and history data source expose these approval operations with explicit expiry, import, drift and revocation. Global feature management is available through the explicit platform mode and capability grants described above; other platform families remain tracked work. Existing tenant resources continue to use their current tenant authorization contract.

Provider and API parity tracking (#381) · Machine-principal API dependency (#678)