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
| Variable | Value |
|---|---|
PONTUSX_ACCESS_KEY | The key, pxk_…. |
PONTUSX_ACCESS_KEY_FILE | A file that holds the key (a mounted secret), instead of PONTUSX_ACCESS_KEY. Setting both is an error. |
PONTUSX_WALLET_URL | Your 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 withaccess_key_malformed, and nautilus does not send it anywhere.- Before nautilus opens a node session,
prepare()gets a token for the consumer (the address ofsigner) and asks the gateway what the key may do (GET auth/account). A key without a wallet for that address, withoutpresentor 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.
addresspins 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 answerswallet_required. Leaveaddressout 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
finallywithtokenSource.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_revokedor anotherkey_*code), nautilus reads the file once more and continues with the new key, without a restart. WithPONTUSX_ACCESS_KEYinstead 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
addressorwalletId, 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-Actoron 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_orpxt_in any letter case, or a JWT, withinvalid_requestbefore 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
| Call | Ends | Use |
|---|---|---|
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.
reason | code | Cause | Who fixes it |
|---|---|---|---|
access-key | access_key_missing | PONTUSX_ACCESS_KEY (or …_FILE) or PONTUSX_WALLET_URL is not set, or nautilus cannot read the key file | Developer |
access-key | access_key_malformed | The key was cut or mistyped (wrong length, alphabet or checksum), or the value is a pxt_ token | Developer |
access-key | invalid_client | The gateway does not know the key, or the secret is wrong | Developer copies the key again, or the admin rotates it |
access-key | key_expired, key_revoked, key_suspended, key_disabled | The 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-key | access_keys_not_allowed_for_organization | Access keys are off for the organisation | Platform operator |
access-key | ip_not_allowed | This machine's IP is not in the key's allowlist | Admin, or run from an allowed network |
access-key | token_invalid, token_expired | The token ended. nautilus gets a new one once by itself. | Admin, if they narrowed or rotated the key |
access-key | dpop_invalid, dpop_required, invalid_target | The 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-key | wrong_endpoint, not_found | The URL is not the API gateway, or the gateway is off | Developer checks PONTUSX_WALLET_URL, or the operator sets API_GATEWAY_ENABLED |
access-key | organization_mismatch | The key belongs to another organisation than organization | Developer |
access-key | invalid_request | The request is malformed, or the actor breaks the actor rule | Developer |
access-key | dpop_signer_failed | The DPoP signer you passed (an HSM or KMS) could not sign a proof | Operator |
out-of-scope | consumer_mismatch, wallet_not_in_scope, wallet_mismatch, wallet_required | The key has no wallet for the address that orders | Developer orders with the key's address, or the admin adds the wallet |
out-of-scope | verifier_unsigned_request | The node's verifier sent an unsigned presentation request, which wallet-api2 refuses for access keys | Node operator makes the verifier sign its requests |
out-of-scope | verifier_url_not_allowed, response_mode_not_allowed | The 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_post | Node operator |
out-of-scope | consumer_binding_required | The request is not bound to a consumer address, and the key may not answer unbound requests | Admin allows unbound requests on the key, or the node operator adds transaction_data |
out-of-scope | credential_not_in_scope | A credential the asset asks for is not in the key's scope | Admin |
out-of-scope | invalid_scope, scope_not_enabled, ddo_signing_disabled | The key may not present, or may not sign DDOs | Admin |
out-of-scope | did_web_holder_disabled | Presenting or signing as the organisation is off for the key | Admin |
out-of-scope | presentation_budget_exhausted | The key has used up its daily limit | Admin, or wait |
out-of-scope | ddo_address_proof_invalid | wallet-api2 refused the DDO address proof: the signer is not the token's address, or the proof does not match the DDO | Developer signs with the wallet's address, the same account that publishes |
out-of-scope | ddo_publisher_mismatch, ddo_shape_invalid | The DDO names another owner or publisher than the token's address, or has fields wallet-api2 does not sign | Developer |
no-matching-credential | no_presentable_credentials | The key has no credentials in its scope | Admin |
wallet-failed | rate_limited | Too many requests. Wait retryAfter seconds. | Developer |
wallet-failed | gateway_unreachable | DNS, connection or TLS to the wallet UI failed | Developer or operator |
wallet-failed | timeout, network_error | The request timed out or the connection dropped | Developer retries or raises timeoutMs |
wallet-failed | signer_failed | The chain signer is missing, could not give its address or sign the address proof, or is not the address of the key's wallet | Developer |
wallet-failed | access_keys_unavailable, unavailable | wallet-api2 cannot issue tokens right now, or the gateway cannot reach it | Operator |
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:
| Refusal | Answered from memory |
|---|---|
invalid_client, key_revoked, key_expired | For the life of the token source. |
key_suspended, key_disabled, access_keys_not_allowed_for_organization, ip_not_allowed, invalid_target, invalid_scope, organization_mismatch | For 60 seconds, or until you call check(). |
wallet_not_in_scope, wallet_required, wallet_mismatch, consumer_mismatch | For 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_idand 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, overhttps://, and never after a redirect. Plainhttp://works only onlocalhostwithallowInsecureTransport. 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_…andpxt_…values, DPoP proofs andDPoPcredentials in every log line and at everyNAUTILUS_DEBUGlevel, includingsecrets.console.logof 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 usePONTUSX_ACCESS_KEY_FILE.