API Reference
PUT /machine/{key}/monetization
Opt a machine into or out of monetization with a signed request.
PUT
PUT /machine/{key}/monetization
Endpoint
personal_sign) signature over a canonical message. A machine’s owner, its , or its on-chain operator may sign (the same authorization triple as EventRegistry.submitEvent). No on-chain transaction is made.
Opting in requires the machine to be and not deactivated. Opting out is always allowed (a machine can always exit), so it skips those checks.
Path parameters
string
required
Machine DID (
did:peaq:0x...) or a decimal machine ID (e.g. 42).Request body
boolean
required
true to opt in, false to opt out. Must be a JSON boolean (not "true" or 1).integer
required
Unix seconds when the message was signed. Must be a positive JSON integer inside the freshness window (see below).
string
required
The EIP-191 signature:
0x followed by exactly 130 hex characters (65 bytes).Canonical message
The client must build and sign this exact string, byte for byte. Fields are LF-separated (\n) with no trailing newline:
registryis the server’s identity registry address, lowercased.chain_idis the chain the server reads from. Together with the registry it binds the signature to one deployment, so a signature captured on one chain does not authorize the same action on another.machine_idis the numeric machine ID. Even when the URLkeyis a DID, the signed message uses the resolved numeric ID.opted_inis the lowercase stringtrueorfalse, matching the body field.
personal_sign (JS) or eth_account’s encode_defunct(text=message) (Python).
Freshness window
Thetimestamp must fall within the freshness window (by default up to 300 seconds in the past and 30 seconds of future clock skew). Replaying an old signature after the window closes is rejected, and within the window a strictly newer timestamp is required to overwrite a previously applied decision (see STALE_SIGNATURE).
Response
200 OKError responses
Errors use a coded envelope:{"detail": {"code", "message"}}. Branch on code, never on message. The one exception is a body that is not valid JSON: that returns 422 with detail as a list of validation objects carrying no code.
Example
SDK and CLI support
Both SDKs wrap this endpoint, building and signing the canonical message for you: see the opt-in SDK reference (optIn / optOut in JS, opt_in / opt_out in Python). The CLI exposes it as peaqos monetize opt-in | opt-out.
Related endpoints
- GET /machine//monetization reads the current state without a signature.
- GET /mcr/ returns the machine’s credit rating.
PUT /machine/{key}/monetization

