{"uid":"cap_mQQBYEHZtVye34XlT45jJ","slug":"x402-dev-tools-encode-header-f828f774","name":"x402 Dev Tools – Encode Header","description":"Encodes a PaymentRequired, PaymentPayload or settlement response object as the base64 value of its x402 header, for hand-written servers, clients and tests, and reports the same problems /v1/decode finds.","url":"https://dev.kagurazaka.dev/v1/encode?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"kind":{"enum":["payment-required","payment-signature","payment-response","auto"],"type":"string","description":"default auto"},"value":{"type":"object","description":"the header's JSON object"}}},"responseSchema":{"type":"json","example":{"kind":"payment-response","header":"eyJ4NDAyVmVyc2lvbiI6Miwic3VjY2VzcyI6dHJ1ZSwi...","findings":[],"header_name":"PAYMENT-RESPONSE"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_uBc6UQvvMm6qI7PcpzOt2","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Encodes an x402 PaymentRequired, PaymentPayload, or settlement response object into its base64 header value and reports validation findings.","exampleAgentPrompt":"Encode this JSON object as an x402 payment-response header for me: {\"x402Version\":2,\"success\":true,\"transaction\":\"0xabc123\"} — give me the base64 header value and flag any problems.","exampleUseCases":[{"title":"Hand-written x402 server header","prompt":"I'm building an x402 server by hand and need to encode this PaymentRequired JSON into its base64 header value — can you run it through the encoder and tell me if there are any issues? The object is {\"x402Version\":2,\"accepts\":[{\"scheme\":\"exact\",\"network\":\"base-sepolia\",\"amount\":\"1000\",\"asset\":\"0x...\"}]}"},{"title":"Test client settlement response","prompt":"For my x402 integration test I need the base64 PAYMENT-RESPONSE header for this settlement object: {\"x402Version\":2,\"success\":true,\"transaction\":\"0xdeadbeef\"}. Encode it as a payment-response kind and show me any validation findings."},{"title":"Debug malformed payment signature","prompt":"I think my payment-signature header is malformed — can you encode this JSON as a payment-signature x402 header and tell me what problems it finds? Here's the object: {\"x402Version\":2,\"scheme\":\"exact\",\"network\":\"base\",\"payload\":{\"signature\":\"0xbad\",\"authorization\":{}}}"}],"resultDescription":"Returns a JSON object containing the kind of header detected, the base64-encoded header string ready to use as an HTTP header value, the canonical header name (e.g. PAYMENT-REQUIRED), and a findings array listing any validation problems found in the input object.","failureModes":["Invalid or unrecognizable JSON object returns findings with error details","Unknown kind enum value results in a 400-level error","Malformed input schema (missing required fields) causes validation findings to be populated","Auto-detection of kind may misclassify ambiguous objects"],"whenToPreferThis":"Use this endpoint when you need to serialize an x402 header object into its base64 wire format for hand-written servers, custom clients, or integration tests, and you also want simultaneous validation of the object's structure. Prefer this over manual base64 encoding because it also reports structural problems and returns the correct canonical header name.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-30T12:32:10.791Z","isFirstParty":false,"canonicalSlug":"x402-dev-tools-encode-header-f828f774"}