# Get /weather with X-PAYMENT

The user can directly call the `/weather` with a `X-PAYMENT` header containing the Payment Payload encoded with base 64 (definition here: <https://github.com/coinbase/x402?tab=readme-ov-file#type-specifications>).

To do this, the client will have to generate this kind of JSON:

```json
{
  "x402Version": 1,
  "scheme": "exact",
  "network": "base-sepolia",
  "payload": {
    "signature": "0x2d6a7588d6acca505cbf0d9a4a227e0c52c6c34008c8e8986a1283259764173608a2ce6496642e377d6da8dbbf5836e9bd15092f9ecab05ded3d6293af148b571c",
    "authorization": {
      "from": "0x857b06519E91e3A54538791bDbb0E22373e36b66",
      "to": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
      "value": "10000",
      "validAfter": "1740672089",
      "validBefore": "1740672154",
      "nonce": "0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f13480"
      }
  }
}
```

In this JSON, there are two things : \
\- Payment Payload (included as the X-PAYMENT header in base64 encoded JSON).\
\- Inside this Payment payload, there is the payload field. This field is specific and depends on the scheme you set. For example, you can find read the exact payload specification here : <https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md#x-payment-header-payload>.

Once you have build this JSON, use the code below to encode it and then, add it to the `X-PAYMENT` header of your query.

```java
String encodedPaymentHeader = Base64
.getEncoder()
.withoutPadding()
.encodeToString(paymentHeader.getBytes(UTF_8));
```

If the payment is accepted and all the verification succeed, the query result will be displayed (in our case, it will be the weather).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mogami.gitbook.io/mogami/learning/protocol-explanation-v1/get-weather-with-x-payment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
