Python: Registry
LogRegistry
Section titled “LogRegistry”from dnsid import LogRegistryHolds one factory per log method; constructs bound LogReader instances on demand.
For C2SP, prefer create_dnsid_managed_verification_registry() or
create_c2sp_tlog_verification_registry(...) over manual registration.
IdentityManager uses the registry to bind the local log and to construct
counterparty readers during verification. Factories remain synchronous and
return LogReader instances; readers may additionally implement AsyncLogReader.
Factory construction must not block the event loop when used by native async
verification. Synchronous verification constructs readers in workers.
Convenience factories own their default resource fetchers. After all managers
using a registry have drained, close it with async with or aclose()
after async reads, or with / close() for synchronous-only use. Injected
fetchers remain caller-owned. Keep HTTP-owning event loops running until
async shutdown completes.
LogRegistry constructor
Section titled “LogRegistry constructor”LogRegistry() -> NoneInitialize an empty registry with no registered log method factories.
LogRegistry.close() -> NoneClose factory-owned resources after synchronous use.
aclose
Section titled “aclose”LogRegistry.async aclose() -> NoneClose factory-owned resources after all verification work drains.
register
Section titled “register”LogRegistry.register(method: str, factory: LogReaderFactory) -> NoneRegister a factory for method (e.g. ‘c2sp-tlog’).
Arguments:
method(str): Log method name; must match[a-z][a-z0-9-]*.factory(LogReaderFactory): Callable that builds a LogReader bound to a full lr string.
Raises:
ArgumentError: If method does not match[a-z][a-z0-9-]*.
new_reader
Section titled “new_reader”LogRegistry.new_reader(lr: str) -> LogReaderConstruct a LogReader bound to the full log reference lr.
Splits lr on the first ’:’ to extract the method prefix, then calls the registered factory.
Arguments:
lr(str): Full log reference string, e.g."c2sp-tlog:public:https://log.dnsid.ai#<stream-id>".
Returns:
LogReader— A LogReader bound to lr, or a NoopLogReader when the method has no registered factory.
Raises:
ParseError: If lr is malformed.
RegistryClient
Section titled “RegistryClient”from dnsid import RegistryClientBases: AbstractRegistryClient
Operator-side client for managing the local agent’s own registration.
The primary contract is the DNSid registry API under /api/v1:
POST /api/v1/agent— register an agentPOST /api/v1/agent/{fqdn}/verify— request verificationPOST /api/v1/agent/{fqdn}/challenge— submit the signed challenge noncePOST /api/v1/agent/{fqdn}/proof— submit managed Live proofPOST /api/v1/agent/{fqdn}/proof/reissue— reissue managed Live proofGET /api/v1/agent/{fqdn}/status— fetch lifecycle statePOST /api/v1/agent/{fqdn}/record— fetch canonical record contentPOST /api/v1/agent/{fqdn}/signature— submit signature for publicationPOST /api/v1/agent/{fqdn}/retire— retire an agentDELETE /api/v1/agent/{fqdn}— unregister
NOT used by VerifyDomain; protocol verification always fetches the signed su endpoint.
Hosted mutation calls require owner credentials (an organization session or
API key), supplied as api_key and sent as an Authorization: Bearer
header. Loopback registry calls do not require credentials. An agent bearer
token is not sufficient. Legacy status reads are public, but Live status
requires the same owner authentication because it
may expose a proof challenge. A configured credential is sent on all reads.
The credential is never included in repr()/str(), exceptions, or logs.
Requests share a protected connection pool, including when transport settings
are omitted. Every registry operation has an async_ variant using
native async HTTP and the same validation, credentials and error handling.
Use a with block or close() for synchronous use; use async with
or await aclose() after async use. Async requests share a separate pool
on one event loop. Finish outstanding requests before closing either pool.
Cancellation stops the local request, not mutations already accepted by
the server. Reconcile uncertain results before retrying with the same
request and idempotency key; methods never retry mutations automatically.
Restore/reactivation operations (un-retiring or un-revoking an agent) are
deliberately not exposed: the registry treats RETIRED and REVOKED as
terminal, so recovery is an operator/registry-console action, not an SDK
call. The signed _dnsid TXT record is authoritative in DNS, not in
the registry API — read the effective published values (e.g. ku/su) by
resolving and verifying the record with IdentityManager.verify_domain.
RegistryClient constructor
Section titled “RegistryClient constructor”RegistryClient(base_url: str | None = None, *, api_key: str | None = None, transport_config: TransportConfig | None = None) -> NoneInitialize the client with a registry base URL and optional credential.
Arguments:
base_url(str | None): HTTPS registry base URL, or HTTP loopback URL for the local registry; defaults toDEFAULT_REGISTRY_URL(the local registry fromdnsid local up). Hosted use requires an explicit URL; seednsid.registry_client_from_environment. A trailing slash is stripped. — defaultNonetransport_config(TransportConfig | None): Effective DNS/TLS settings for SDK-managed requests. — defaultNoneapi_key(str | None): Owner session or organization API-key credential sent as anAuthorization: Bearerheader. Whitespace-only values are treated as absent; without one hosted clients can only read legacy status. The loopback registry does not require a credential. Constructors never read the environment themselves. — defaultNone
Raises:
ValueError: If base_url is not a safe HTTPS or loopback HTTP URL, or api_key contains control characters that could corrupt the Authorization header.
RegistryClient.close() -> NoneClose synchronous connections; use aclose after async requests.
aclose
Section titled “aclose”RegistryClient.async aclose() -> NoneClose both pools after the last request, on the async pool’s event loop.
register_agent
Section titled “register_agent”RegistryClient.register_agent(input: AgentRegistrationInput, idempotency_key: str | None = None) -> AgentRegistrationCreate an identity using exact-domain, GI/root, or public-key-only input.
Omitted selectors generate a sandbox name. The registry resolves hosting; an exact domain does not imply client-controlled publication. Explicit legacy selectors are sent unchanged. Managed Live uses register_live_agent.
An optional idempotency key is transport metadata. Retry with the same complete request and key; this method never retries automatically. SDK errors retain registration_request, registration_idempotency_key, and registration_response (known creation facts), without exposing credentials. The returned publication snapshot does not establish counterparty trust.
async_register_agent
Section titled “async_register_agent”RegistryClient.async async_register_agent(input: AgentRegistrationInput, idempotency_key: str | None = None) -> AgentRegistrationAsync variant of register_agent with the same validation and errors.
register_live_agent
Section titled “register_live_agent”RegistryClient.register_live_agent(input: LiveAgentRegistrationInput, idempotency_key: str) -> LiveProvisioningResponseStart managed Live registration and return its validated proof challenge.
POST /api/v1/agent sends fixed tier="live" and managed=true
discriminators. Sign the exact base64url-decoded challenge_message
bytes; use the derived LiveProvisioningResponse.domain for the
proof route.
async_register_live_agent
Section titled “async_register_live_agent”RegistryClient.async async_register_live_agent(input: LiveAgentRegistrationInput, idempotency_key: str) -> LiveProvisioningResponseAsync variant of register_live_agent with the same validation and errors.
verify_agent
Section titled “verify_agent”RegistryClient.verify_agent(domain: str) -> AgentRegistrationRequest registry verification for a registered self-managed agent.
POST /api/v1/agent/{domain}/verify
async_verify_agent
Section titled “async_verify_agent”RegistryClient.async async_verify_agent(domain: str) -> AgentRegistrationAsync variant of verify_agent with the same validation and errors.
revoke_agent
Section titled “revoke_agent”RegistryClient.revoke_agent(domain: str, agent_id: str, reason: RegistryRevocationReason) -> LifecycleResultRevoke an agent through the registry-owned terminal lifecycle flow.
POST /api/v1/agent/{domain}/revoke
The registry owns persistence and the transparency-log append; this convenience method does not prepare or append a second local event.
Arguments:
domain(str): Agent FQDN to revoke.agent_id(str): Immutable registry agent ID for safe retries after domain re-registration.reason(RegistryRevocationReason): Typed owner-authorized registry revocation reason.
Returns:
LifecycleResult— The registry lifecycle transition result.
Raises:
ArgumentError: If reason is not aRegistryRevocationReason.
async_revoke_agent
Section titled “async_revoke_agent”RegistryClient.async async_revoke_agent(domain: str, agent_id: str, reason: RegistryRevocationReason) -> LifecycleResultAsync variant of revoke_agent with the same validation and errors.
retire_agent
Section titled “retire_agent”RegistryClient.retire_agent(domain: str, agent_id: str) -> LifecycleResultRetire an agent while retaining its key for historical verification.
POST /api/v1/agent/{domain}/retire with the immutable agent_id.
async_retire_agent
Section titled “async_retire_agent”RegistryClient.async async_retire_agent(domain: str, agent_id: str) -> LifecycleResultAsync variant of retire_agent with the same validation and errors.
cancel_agent
Section titled “cancel_agent”RegistryClient.cancel_agent(domain: str) -> LifecycleResultCancel an agent that is still inside the registration workflow.
POST /api/v1/agent/{domain}/cancel. A PENDING agent cannot be
revoked (the registry answers 409 INVALID_TRANSITION); cancelling
is the transition that removes it. Mirrors cancelAgent in the
TypeScript SDK and CancelAgent in Go.
async_cancel_agent
Section titled “async_cancel_agent”RegistryClient.async async_cancel_agent(domain: str) -> LifecycleResultAsync variant of cancel_agent with the same validation and errors.
submit_challenge_signature
Section titled “submit_challenge_signature”RegistryClient.submit_challenge_signature(domain: str, nonce: str, signature: bytes | str) -> LifecycleResultSubmit the signed verification challenge to prove key possession.
POST /api/v1/agent/{domain}/challenge
During the VERIFICATION lifecycle state the registry exposes a
challenge nonce on the status document (raw["challenge"]). The
agent signs the base64url-decoded nonce bytes with its active signing
key and submits the signature here. The registry accepts the
challenge and completes verification asynchronously; use
wait_for_status with target_state="VERIFIED" afterwards.
The nonce is single-use — a fresh one must be fetched before retrying.
Arguments:
domain(str): Agent FQDN.nonce(str): Challenge nonce exactly as returned by the status endpoint.signature(bytes | str): Raw signature bytes (base64url-encoded automatically), or an already base64url-encoded signature string.
async_submit_challenge_signature
Section titled “async_submit_challenge_signature”RegistryClient.async async_submit_challenge_signature(domain: str, nonce: str, signature: bytes | str) -> LifecycleResultAsync variant of submit_challenge_signature.
submit_live_proof
Section titled “submit_live_proof”RegistryClient.submit_live_proof(domain: str, request: LiveProofRequest) -> LiveProofResponseSubmit signed proof for managed Live provisioning.
POST /api/v1/agent/{domain}/proof requires owner/session/API-key
credentials, not an agent bearer token. request.request_id is sent
as the required Idempotency-Key header.
async_submit_live_proof
Section titled “async_submit_live_proof”RegistryClient.async async_submit_live_proof(domain: str, request: LiveProofRequest) -> LiveProofResponseAsync variant of submit_live_proof with the same validation and errors.
reissue_live_proof
Section titled “reissue_live_proof”RegistryClient.reissue_live_proof(domain: str, request: LiveProofReissueRequest) -> LiveProofReissueResponseRequest a replacement challenge for an expired managed Live proof.
POST /api/v1/agent/{domain}/proof/reissue requires owner/session/API-key
credentials, not an agent bearer token. request.request_id is sent
as the required Idempotency-Key header. The original public key is
validated locally and binds the replacement transcript, but is not sent.
The replacement challenge supersedes every earlier challenge; only the
latest message may be signed.
async_reissue_live_proof
Section titled “async_reissue_live_proof”RegistryClient.async async_reissue_live_proof(domain: str, request: LiveProofReissueRequest) -> LiveProofReissueResponseAsync variant of reissue_live_proof with the same validation and errors.
get_status
Section titled “get_status”RegistryClient.get_status(domain: str) -> str | NoneFetch the raw lifecycle status string from the registry.
GET /api/v1/agent/{domain}/status
Returns the uppercased status string (e.g. "ACTIVE", "VERIFIED"),
or None if the agent is not registered (HTTP 404). Live status
requires owner/session/API-key authentication; legacy status is public.
async_get_status
Section titled “async_get_status”RegistryClient.async async_get_status(domain: str) -> str | NoneAsync variant of get_status with the same validation and errors.
get_agent_status
Section titled “get_agent_status”RegistryClient.get_agent_status(domain: str) -> RegistryAgentStatus | NoneFetch registry lifecycle state.
GET /api/v1/agent/{domain}/status
Returns None if the agent is not registered (HTTP 404). Live status
requires owner/session/API-key authentication; legacy status is public.
Returns a RegistryAgentStatus with computed boolean flags that
mirror the TypeScript RegistryAgentStatus interface.
async_get_agent_status
Section titled “async_get_agent_status”RegistryClient.async async_get_agent_status(domain: str) -> RegistryAgentStatus | NoneAsync variant of get_agent_status with the same validation and errors.
get_organization_onboarding
Section titled “get_organization_onboarding”RegistryClient.get_organization_onboarding(*, expected_org_id: str | None = None, expected_gi: str | None = None) -> dict[str, Any]Read account/GI proofs and delegation using authenticated effective transport.
Compare saved/configured IDs when supplied; derive bindings_ready
only from matching verified GI proof and verified entity delegation.
Pending proofs are not ready bindings. This read supplies no entity JWKS
URL and makes no claim about named creation or permanent replay support.
async_get_organization_onboarding
Section titled “async_get_organization_onboarding”RegistryClient.async async_get_organization_onboarding(*, expected_org_id: str | None = None, expected_gi: str | None = None) -> dict[str, Any]Async variant of get_organization_onboarding.
get_registration
Section titled “get_registration”RegistryClient.get_registration(domain: str) -> AgentRegistration | NoneRead authenticated management status without conflating status namespaces.
Owner credentials are required on hosted registries. Failed authenticated reads are never retried anonymously. This is not the public protocol su route.
async_get_registration
Section titled “async_get_registration”RegistryClient.async async_get_registration(domain: str) -> AgentRegistration | NoneAsync variant of get_registration with the same validation and errors.
get_agent_detail
Section titled “get_agent_detail”RegistryClient.get_agent_detail(domain: str) -> AgentRegistration | NoneRead authenticated management detail to obtain publication authority.
The product exposes agent detail on the management status route, not GET /api/v1/agent/{domain}. This does not read the public protocol su URL.
async_get_agent_detail
Section titled “async_get_agent_detail”RegistryClient.async async_get_agent_detail(domain: str) -> AgentRegistration | NoneAsync variant of get_agent_detail with the same validation and errors.
wait_for_status
Section titled “wait_for_status”RegistryClient.wait_for_status(domain: str, *, timeout: float = 120.0, interval: float = 5.0, target_state: str | None = None) -> RegistryAgentStatusPoll the registry until the agent reaches a settled or target state.
Returns when the agent is published, failed, or terminal — or when
target_state (a raw registry status string such as "VERIFIED") is
reached. Raises VerificationError(LOG_ERROR) on timeout or if a
failed/terminal state is reached before target_state.
Arguments:
domain(str): Agent FQDN.timeout(float): Maximum seconds to wait before raising. — default120.0interval(float): Seconds between status polls. — default5.0target_state(str | None): Raw registry status string to wait for specifically. — defaultNone
async_wait_for_status
Section titled “async_wait_for_status”RegistryClient.async async_wait_for_status(domain: str, *, timeout: float = 120.0, interval: float = 5.0, target_state: str | None = None) -> RegistryAgentStatusAsync variant of wait_for_status.
Uses native async HTTP and sleeps without blocking the event loop. Cancellation closes the current response and stops polling.
unregister_agent
Section titled “unregister_agent”RegistryClient.unregister_agent(domain: str) -> NoneBest-effort unregister. Silently ignores 404 and 405.
DELETE /api/v1/agent/{domain}
async_unregister_agent
Section titled “async_unregister_agent”RegistryClient.async async_unregister_agent(domain: str) -> NoneAsync variant of unregister_agent with the same validation and errors.
canonical_record_content
Section titled “canonical_record_content”RegistryClient.canonical_record_content(domain: str, signing_kid: str) -> CanonicalRecordContentResponseFetch the registry’s canonical TXT record content for signing.
POST /api/v1/agent/{domain}/record
Returns a CanonicalRecordContentResponse with the canonical
byte string and the registry’s view of the active signing key ID.
The SDK MUST validate both before signing; this response is not trusted input.
async_canonical_record_content
Section titled “async_canonical_record_content”RegistryClient.async async_canonical_record_content(domain: str, signing_kid: str) -> CanonicalRecordContentResponseAsync variant of canonical_record_content with the same validation and errors.
publish_signature
Section titled “publish_signature”RegistryClient.publish_signature(domain: str, sig: str) -> PublishedRecordSubmit the record signature to complete the publish workflow.
POST /api/v1/agent/{domain}/signature
sig MUST be the profile-owned sg value. For draft 01 this is the bare unpadded base64url signature bytes.
async_publish_signature
Section titled “async_publish_signature”RegistryClient.async async_publish_signature(domain: str, sig: str) -> PublishedRecordAsync variant of publish_signature with the same validation and errors.
prepare_issuance
Section titled “prepare_issuance”RegistryClient.prepare_issuance(domain: str, idempotency_key: str) -> PreparedRegistryEventFetch exact raw ISSUANCE bytes for operational countersigning.
GET /api/v1/agent/{domain}/tlog/issuance/prepare has no request
body. The response bytes are untrusted. Use
dnsid.c2sp_tlog.parse_prepared_issuance with the expected identity
and keys to validate them against the entry’s signed lr before
countersigning.
async_prepare_issuance
Section titled “async_prepare_issuance”RegistryClient.async async_prepare_issuance(domain: str, idempotency_key: str) -> PreparedRegistryEventAsync variant of prepare_issuance with the same validation and errors.
prepare_key_rotation
Section titled “prepare_key_rotation”RegistryClient.prepare_key_rotation(domain: str, request: KeyRotationPreparationRequest, idempotency_key: str) -> PreparedRegistryEventRequest a registry-prepared KEY_ROTATION envelope.
POST /api/v1/agent/{domain}/tlog/key-rotation/prepare
This operation requires owner/session/API-key credentials, not an
agent bearer token. The idempotency key travels as transport metadata
(Idempotency-Key header); reusing it with different key material fails server-side, as
does a second preparation against the same previous key. Only public
JWK members are sent — a request.public_key carrying private
material is rejected locally before any request.
Returns the exact prepared-envelope bytes as UNTRUSTED input. The
caller must parse them against the identity’s verified log reference
(dnsid.c2sp_tlog.parse_prepared_event), independently reproduce
the signed bytes, and verify domain, previous key, new key, log
context, and stream-chain fields before adding any signature.
async_prepare_key_rotation
Section titled “async_prepare_key_rotation”RegistryClient.async async_prepare_key_rotation(domain: str, request: KeyRotationPreparationRequest, idempotency_key: str) -> PreparedRegistryEventAsync variant of prepare_key_rotation with the same validation and errors.
submit_prepared_event
Section titled “submit_prepared_event”RegistryClient.submit_prepared_event(domain: str, entry_bytes: bytes, idempotency_key: str) -> SubmissionResultSubmit exact complete canonical entry bytes for append.
POST /api/v1/agent/{domain}/tlog/events
The bytes are sent unchanged as the application/json request body; a timeout or indeterminate result is retried with the same bytes and the same idempotency key. The registry’s durable idempotency mapping returns the original pending/accepted result for the same (identity, key, byte-hash) triple and rejects key reuse with different bytes.
async_submit_prepared_event
Section titled “async_submit_prepared_event”RegistryClient.async async_submit_prepared_event(domain: str, entry_bytes: bytes, idempotency_key: str) -> SubmissionResultAsync variant of submit_prepared_event with the same validation and errors.
AgentRegistrationInput
Section titled “AgentRegistrationInput”from dnsid import AgentRegistrationInputUnified registration selectors and optional legacy settings.
Use domain for an exact FQDN, root_domain for an assigned name under an active delegated zone, or governance_domain for GI-selected creation. domain and root_domain are mutually exclusive. Assigned names require a public key; public-key-only input selects the sandbox root. The registry determines hosting and publication authority, not the request shape. Legacy environment, tier, managed, and zone_id are not defaulted by the SDK. idempotency_key is retained for compatibility; prefer the method argument.
AgentRegistration
Section titled “AgentRegistration”from dnsid import AgentRegistrationAgent registration record returned by the registry.
LiveAgentRegistrationInput
Section titled “LiveAgentRegistrationInput”from dnsid import LiveAgentRegistrationInputInput for the dedicated managed Live registration operation.
LiveChallengeTranscript
Section titled “LiveChallengeTranscript”from dnsid import LiveChallengeTranscriptValidated transcript encoded by a managed Live proof challenge.
LiveProvisioningResponse
Section titled “LiveProvisioningResponse”from dnsid import LiveProvisioningResponseProof challenge returned when managed Live provisioning starts.
LiveProofRequest
Section titled “LiveProofRequest”from dnsid import LiveProofRequestSigned proof submitted after managed Live registration.
LiveProofResponse
Section titled “LiveProofResponse”from dnsid import LiveProofResponseDurable handoff status returned after managed Live proof.
LiveProofReissueRequest
Section titled “LiveProofReissueRequest”from dnsid import LiveProofReissueRequestRequest for a replacement managed Live proof challenge.
The original public key is local validation context and is not sent to the registry.
LiveProofReissueResponse
Section titled “LiveProofReissueResponse”from dnsid import LiveProofReissueResponseReplacement challenge returned for an expired managed Live proof.
LifecycleResult
Section titled “LifecycleResult”from dnsid import LifecycleResultLifecycle transition result.
Returned by registry mutation endpoints such as submit_challenge_signature.
RegistryAgentStatus
Section titled “RegistryAgentStatus”from dnsid import RegistryAgentStatusRegistry workflow status, kept separate from protocol AgentStatus.
CanonicalRecordContentResponse
Section titled “CanonicalRecordContentResponse”from dnsid import CanonicalRecordContentResponseRegistry-prepared canonical TXT record content for a local identity signing workflow.
PublishedRecord
Section titled “PublishedRecord”from dnsid import PublishedRecordRecord returned after a successful publish_to_registry call.
PreparedRegistryEvent
Section titled “PreparedRegistryEvent”from dnsid import PreparedRegistryEventExact untrusted response bytes returned by a prepare endpoint.
KeyRotationPreparationRequest
Section titled “KeyRotationPreparationRequest”from dnsid import KeyRotationPreparationRequestInput for RegistryClient.prepare_key_rotation.
previous_key_id is the RFC 7638 thumbprint of the current operational key — the registry rejects a stale or concurrent rotation. public_key is one pending public signing key including kid and alg; private JWK members are forbidden and never leave the SDK.
KeyRotationResult
Section titled “KeyRotationResult”from dnsid import KeyRotationResultDurable recovery state for a managed operational-key rotation.
Entry bytes, their hash, key bindings, and the idempotency key are fixed
once first persisted. When activated is False, call
IdentityManager.resume_key_rotation(registry_client, result) to retry
the exact same bytes under the same idempotency key. Application signing
remains paused until accepted submission, local activation/supersession,
and durable state reconciliation all complete.
SubmissionResult
Section titled “SubmissionResult”from dnsid import SubmissionResultTyped result of RegistryClient.submit_prepared_event.
state is one of “pending”, “submitting”, “accepted”, or “rejected”. A pending or otherwise indeterminate submission is retried with the exact same entry bytes and idempotency key; the entry is never regenerated.
Attributes:
accepted(bool): Return True when the registry reported the appended entry as accepted.