Skip to content
LogoLogo

Use an access key in scripts, CI and MCP

A script, a CI job or an MCP server has no browser session in the wallet. Instead, an admin of your organisation gives it an access key (pxk_…) with exactly the rights it needs. nautilus exchanges the key at the wallet UI's API gateway for access tokens (pxt_…) that live about 10 minutes. DPoP binds each token to a key that exists only in your process's memory. nautilus uses these tokens for every wallet call. The access key itself never goes to a wallet route.

Access keys work with nodes that run the native SSI module (walt.id wallet-api2). Policy-server nodes (OceanProtocolEnterprise ocean-node) need 2.0.0-beta.3. See Upgrading to 2.0.0-beta.4.

1. Get a key from your organisation's admin

An admin of your organisation creates the key on the wallet UI's Access keys page. A new key has no rights. The admin turns on each one, so tell them what your script needs.

  • The wallet the key acts from. Pick the wallet of the address your script orders with.
  • Present, if you order credential-gated assets. The admin also adds the credentials the assets ask for. A key may present to any verifier.
  • Answer unbound requests, only if a node sends presentation requests without a consumer binding. Today's Pontus-X nodes do that for Gaia-X (jwt_vc_json) sessions. See Unbound presentation requests.
  • Sign DDOs, only if you publish with a DID issuer. Publishing as the organisation's did:web also needs "present as the organisation".
  • An IP allowlist, if your runner has fixed egress IPs, and an expiry.

The wallet UI shows the key once. Store it in your secret manager straight away. If you lose it, the admin rotates the key, because nobody can show it again.

2. Set the environment variables

VariableValue
PONTUSX_ACCESS_KEYThe key, pxk_….
PONTUSX_ACCESS_KEY_FILEA file that holds the key (a mounted secret), instead of PONTUSX_ACCESS_KEY. Setting both is an error.
PONTUSX_WALLET_URLYour organisation's wallet UI, for example https://wallet.example.org. The gateway is <PONTUSX_WALLET_URL>/api/gateway.

3. Minimal code

const  = .({ 
  : . 
}) 
 
try {
  // Optional dry run. Shows what the key may do before you order anything.
  .(await ..())
 
  const  = await .(, { ,  })
  const {  } = await .({ : 'did:ope:1234abcd...' })
  .()
} finally {
  await ..() 
}

What happens:

  • fromEnv() reads the variables once and checks the key's form and checksum offline. A key that was cut or mistyped fails here with access_key_malformed, and nautilus does not send it anywhere.
  • Before nautilus opens a node session, prepare() gets a token for the consumer (the address of signer) and asks the gateway what the key may do (GET auth/account). A key without a wallet for that address, without present or without credentials fails here, before you order or pay anything.
  • nautilus caches the token and renews it 30 seconds before it expires. Concurrent calls share one renewal.
  • address pins the wallet the token acts from. check() needs it for a key with several wallets, because without it the gateway does not know which wallet to issue the token for and answers wallet_required. Leave address out when one provider orders for several addresses: nautilus then asks for a token per consumer, at the first order of each.

To pass the values in code instead of the environment, use WalletApi2CredentialProvider.withAccessKey with gateway and accessKey (or accessKeyFile).

Publishing with a DID issuer

If the admin allowed sign DDOs, sign the DDO with the key's wallet key. The gateway returns the signing key and DID (auth/account), so you do not have to look them up:

const  = .()
const  = .({
  , // signs the DDO address proof, and its address picks the key's wallet
  // Trusted public keys of the issuer's verification methods, for example from a pinned file
  : () => .()
})
 
const  = await .(, { , ,  })

The signer uses a token of its own with the scope sign_ddo. The presenting token never carries that scope.

wallet-api2 signs a DDO for an access key only when the key's own address approved it. With every signing request nautilus sends an EIP-191 address proof that signer signs. So signer is required, and its address must be the address of the key's wallet, the account that publishes. A stolen key alone can then sign nothing. The proof is the text below, signed with personal_sign:

Pontus-X DDO signing v1
chainId: <credentialSubject.chainId>
did: <the asset DID>
payloadSha256: <hex SHA-256 of the DDO credential's RFC 8785 (JCS) canonical JSON>
issuedAt: <ISO-8601 UTC, seconds>

Both sides hash the canonical JSON (JCS), so the key order and number forms of the sent JSON don't change the hash. Each entry of additionalDdos gets a proof of its own, in the same order, over that entry's JCS. wallet-api2 accepts a proof only within 5 minutes of issuedAt.

getIssuer() checks the setup before publish mints anything. It fails when the key may not sign DDOs (ddo_signing_disabled), when the issuer is a did:web and "present as the organisation" is off (did_web_holder_disabled, also for the key's own default DID), and when signer is missing or is not the token's address (signer_failed).

4. In CI

Store the key as a masked secret of the pipeline, and pass it only to the step that needs it. Child processes inherit the environment, so a key set for the whole job reaches every tool the job runs.

# GitHub Actions
- name: Order the dataset
  run: node scripts/order.js
  env:
    PONTUSX_ACCESS_KEY: ${{ secrets.PONTUSX_ACCESS_KEY }}
    PONTUSX_WALLET_URL: https://wallet.example.org
  • End the job's token in finally with tokenSource.revoke(), as above. The key keeps working. Only the token ends, so it stops counting toward the key's live tokens (maxLiveTokens) now instead of when it expires.
  • Shared runners have changing IPs. If the admin set an IP allowlist, run on runners with fixed egress IPs, or the token request fails with ip_not_allowed.
  • Use one token source per process. Parallel jobs work up to the key's maxLiveTokens (default 20).

5. A local MCP server (stdio)

An MCP client starts a local stdio server as a child process and passes it environment variables. Put the key there, not in the server's arguments:

{
  "mcpServers": {
    "pontusx": {
      "command": "node",
      "args": ["/opt/pontusx-mcp/dist/server.js"],
      "env": {
        "PONTUSX_ACCESS_KEY": "pxk_…",
        "PONTUSX_WALLET_URL": "https://wallet.example.org"
      }
    }
  }
}

command and args name a server you installed yourself, from a source you trust, at a pinned version. The path above is an example. Don't start the server with npx -y <package>. npx runs whatever the registry answers for that name, and that program gets the key in its environment.

Use a key with only present and only the credentials the agent needs. A local agent acts without a confirmation step, so the agent can do whatever the key allows.

6. A deployed MCP server

A deployed, long-running MCP server (one per organisation) uses the same kind of access key, handed to the server. Nothing in the key is specific to servers. The difference is how the server holds it.

  • Use one key per organisation, with the rights the server's tools need.

  • Mount the key as a secret file and set PONTUSX_ACCESS_KEY_FILE, for example /run/secrets/pontusx-access-key. nautilus reads the file at start, trims it and never logs its path or contents.

  • Ask the admin to restrict the key to the server's egress IPs. A leaked key then works from nowhere else.

  • Run as many replicas as you need, up to the key's maxLiveTokens (default 20). Each process makes its own DPoP key and gets its own token. A token source holds one token and one DPoP key per process and nothing else, so it can run for days. It renews the token when it is due, and concurrent requests share one renewal.

  • To rotate, the admin rotates the key with an overlap, for example 24 hours, and you replace the mounted file. When the gateway then refuses the old key (invalid_client, key_revoked or another key_* code), nautilus reads the file once more and continues with the new key, without a restart. With PONTUSX_ACCESS_KEY instead of a file, restart the server within the overlap. A suspended or disabled key that the admin resumed works again after at most 60 seconds, without a restart.

  • One provider can serve several consumers at once. Without a pinned address or walletId, nautilus keeps a token per consumer address, so concurrent orders for different addresses never use each other's wallet.

  • A server with many users can name the user behind each call, for the organisation's audit log. nautilus sends the value as X-Access-Key-Actor on wallet calls. wallet-api2 records it as claimed and unverified. It grants nothing.

    const credentials = WalletApi2CredentialProvider.fromEnv({
      actor: () => currentRequest().userId // an opaque id, or undefined for none
    })

    The value must be printable ASCII (0x20 to 0x7e, spaces allowed), 1 to 128 characters and not blank. nautilus refuses a value that contains pxk_ or pxt_ in any letter case, or a JWT, with invalid_request before it sends anything. The wallet UI's gateway and wallet-api2 apply the same rule.

  • Never forward the tokens your server receives from its own clients to the wallet, for example a Keycloak access token, and never put them in actor. The server acts with its access key only. The MCP authorization spec calls this the no-passthrough rule.

Unbound presentation requests

A presentation request is bound when its transaction_data names the consumer's address (consumer_address). wallet-api2 then presents only for the token's own address. Some requests carry no binding. Today's Pontus-X nodes send such requests for Gaia-X (jwt_vc_json) sessions.

A key answers an unbound request only when the admin turned on Answer requests that are not bound to a consumer address for it. Anyone who holds such a key can answer an unbound request for any account. With the right off, wallet-api2 refuses the request at preview with consumer_binding_required (reason out-of-scope). Either the admin turns the right on, or the node operator adds transaction_data to the node's requests.

check() returns the right as unboundRequests. prepare() does not check it in advance, because only the request shows whether it is bound.

7. Revoke

CallEndsUse
tokenSource.revoke()The current token. The key keeps working.At the end of every job, in finally.
tokenSource.revokeKey()The key itself and all its tokens. You cannot undo it.When the key leaked. The organisation's audit log records the key as revoked by the key holder.

An admin can also revoke or rotate the key on the Access keys page.

Errors

A failed presentation is a CredentialPresentationError. With an access key, details.code says what failed, and details.hint says who fixes it. The details also carry status and retryAfter when they are known. The token source and WalletApi2VcSigner throw WaltIdWalletError with the same code and hint.

reasoncodeCauseWho fixes it
access-keyaccess_key_missingPONTUSX_ACCESS_KEY (or …_FILE) or PONTUSX_WALLET_URL is not set, or nautilus cannot read the key fileDeveloper
access-keyaccess_key_malformedThe key was cut or mistyped (wrong length, alphabet or checksum), or the value is a pxt_ tokenDeveloper
access-keyinvalid_clientThe gateway does not know the key, or the secret is wrongDeveloper copies the key again, or the admin rotates it
access-keykey_expired, key_revoked, key_suspended, key_disabledThe key no longer works. A key is suspended when its creator left or the organisation switch went off, and disabled when it was unused for too long.Admin
access-keyaccess_keys_not_allowed_for_organizationAccess keys are off for the organisationPlatform operator
access-keyip_not_allowedThis machine's IP is not in the key's allowlistAdmin, or run from an allowed network
access-keytoken_invalid, token_expiredThe token ended. nautilus gets a new one once by itself.Admin, if they narrowed or rotated the key
access-keydpop_invalid, dpop_required, invalid_targetThe gateway refused the proof or the resource. The clock is off by more than 60 s, or the gateway's public URL differs.Developer checks the clock, or the operator checks ACCESS_KEYS_PUBLIC_URL
access-keywrong_endpoint, not_foundThe URL is not the API gateway, or the gateway is offDeveloper checks PONTUSX_WALLET_URL, or the operator sets API_GATEWAY_ENABLED
access-keyorganization_mismatchThe key belongs to another organisation than organizationDeveloper
access-keyinvalid_requestThe request is malformed, or the actor breaks the actor ruleDeveloper
access-keydpop_signer_failedThe DPoP signer you passed (an HSM or KMS) could not sign a proofOperator
out-of-scopeconsumer_mismatch, wallet_not_in_scope, wallet_mismatch, wallet_requiredThe key has no wallet for the address that ordersDeveloper orders with the key's address, or the admin adds the wallet
out-of-scopeverifier_unsigned_requestThe node's verifier sent an unsigned presentation request, which wallet-api2 refuses for access keysNode operator makes the verifier sign its requests
out-of-scopeverifier_url_not_allowed, response_mode_not_allowedThe verifier's request_uri or did:web client id is not on a public https host, or it asks for a response mode other than direct_postNode operator
out-of-scopeconsumer_binding_requiredThe request is not bound to a consumer address, and the key may not answer unbound requestsAdmin allows unbound requests on the key, or the node operator adds transaction_data
out-of-scopecredential_not_in_scopeA credential the asset asks for is not in the key's scopeAdmin
out-of-scopeinvalid_scope, scope_not_enabled, ddo_signing_disabledThe key may not present, or may not sign DDOsAdmin
out-of-scopedid_web_holder_disabledPresenting or signing as the organisation is off for the keyAdmin
out-of-scopepresentation_budget_exhaustedThe key has used up its daily limitAdmin, or wait
out-of-scopeddo_address_proof_invalidwallet-api2 refused the DDO address proof: the signer is not the token's address, or the proof does not match the DDODeveloper signs with the wallet's address, the same account that publishes
out-of-scopeddo_publisher_mismatch, ddo_shape_invalidThe DDO names another owner or publisher than the token's address, or has fields wallet-api2 does not signDeveloper
no-matching-credentialno_presentable_credentialsThe key has no credentials in its scopeAdmin
wallet-failedrate_limitedToo many requests. Wait retryAfter seconds.Developer
wallet-failedgateway_unreachableDNS, connection or TLS to the wallet UI failedDeveloper or operator
wallet-failedtimeout, network_errorThe request timed out or the connection droppedDeveloper retries or raises timeoutMs
wallet-failedsigner_failedThe chain signer is missing, could not give its address or sign the address proof, or is not the address of the key's walletDeveloper
wallet-failedaccess_keys_unavailable, unavailablewallet-api2 cannot issue tokens right now, or the gateway cannot reach itOperator

Retries

The token source does not send the key again for a refusal that another request would only repeat. It answers the refusal from memory:

RefusalAnswered from memory
invalid_client, key_revoked, key_expiredFor the life of the token source.
key_suspended, key_disabled, access_keys_not_allowed_for_organization, ip_not_allowed, invalid_target, invalid_scope, organization_mismatchFor 60 seconds, or until you call check().
wallet_not_in_scope, wallet_required, wallet_mismatch, consumer_mismatchFor 60 seconds, for the address asked for. Another address is asked at once.
rate_limited (429)Until Retry-After has passed (seconds or an HTTP date), and at least 1 s, doubled for each 429 in a row, up to 60 s. A token that still works is used meanwhile.

With PONTUSX_ACCESS_KEY_FILE, the token source reads the file again while it answers a refusal of the key from memory, and uses a changed key at once. After an admin resumed a key or widened its scope, call check() to ask again without waiting.

On a wallet call, nautilus renews a refused token (token_invalid, token_expired) once and repeats a call refused with dpop_invalid once with a fresh proof. The token request and revocation do the same for dpop_invalid, which wallet-api2 answers to a proof made before its last restart. It retries no other refusal. A refused presentation, for example consumer_binding_required, keeps the token, so the next call does not send the key.

A token that the token source refuses after the gateway issued it (another organisation, wallet, address or scope) is revoked at once, so it does not count toward maxLiveTokens. A revocation that fails for a passing reason (unavailable, a timeout, a cancelled call) is tried again by the next revoke().

Cancelling

getToken, authorize, check and revoke take an AbortSignal. timeoutMs bounds every request (default 30 s, 1 to 2147483647 ms). The provider's prepare() and present() take no signal. timeoutMs bounds each of their requests.

Security notes

  • A key may present its credentials to any verifier that signs its requests. wallet-api2 records the verifier's client_id and origin in the key's activity for every presentation. The credentials you put in the key's scope limit what a leaked key can disclose.
  • The key is a bearer secret. Anyone who has it can get tokens until it expires, from any IP the allowlist permits, with a DPoP key of their own. Keep it in a secret manager. Give it the fewest rights, an IP allowlist and a short expiry, and revoke it at once if it leaks.
  • nautilus sends the key only in the body of the token request (and of revokeKey()) to <PONTUSX_WALLET_URL>/api/gateway, over https://, and never after a redirect. Plain http:// works only on localhost with allowInsecureTransport. The key never goes into a header, a URL or a wallet route.
  • A token lives about 10 minutes. wallet-api2 binds it to a DPoP key that nautilus generates in memory and cannot export, one per token source. A logged token is useless without that key.
  • nautilus masks pxk_… and pxt_… values, DPoP proofs and DPoP credentials in every log line and at every NAUTILUS_DEBUG level, including secrets. console.log of a token source shows the key id (ak_…) only.
  • Child processes inherit PONTUSX_ACCESS_KEY. Pass it to the one step or process that needs it, or use PONTUSX_ACCESS_KEY_FILE.