> For the complete documentation index, see [llms.txt](https://docs.xverse.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xverse.app/sats-connect/spark-methods/flashnet-trading/spark_flashnet_getjwt.md).

# spark\_flashnet\_getJWT

Use the `spark_flashnet_getJWT` method to request a [**Flashnet JWT**](https://docs.flashnet.xyz/api-reference/auth/challenge) for the user’s Spark wallet.\
The wallet handles challenge/response with Flashnet:

* Fetches the challenge
* Signs it with the user’s Spark identity key
* Exchanges it for a JWT

Your app receives the JWT directly, without having to manage the user's authentication flow on Flashnet.

## **Parameters**

No parameters are required.

## **Example**

```ts
import { request } from "sats-connect";

try {
  const response = await request("spark_flashnet_getJWT", {});
  if ("result" in response) {
    console.log("JWT:", response.result.jwt);
  } else {
    console.error("Error:", response.error.message);
  }
} catch (err) {
  console.error("Unexpected error:", err);
}
```

## **Response**

### :white\_check\_mark: Success

On success, the method resolves to a JWT token that the dApp can use for authenticated Flashnet API calls.

```json
{
  "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expiresAt": "2025-09-17T12:34:56Z"
}
```

* **`jwt`** — the Flashnet access token, to be passed as `Authorization: Bearer <jwt>` in API calls
* **`expiresAt`** — ISO timestamp when the token expires (token must be renewed afterwards)

### :x: Errors

If the request fails, the method will reject with an error object:

```json
{
  "errorCode": "FSAG-2001",
  "message": "Signature verification failed: Invalid nonce",
  "requestId": "01H8Z0HMVXJN6A8Q9GR1J6Z34E"
}
```

Common failure cases encountered with Flashnet [authentication](https://docs.flashnet.xyz/api-reference/auth/verify) include:

* **Validation errors** (malformed data)
* **Security errors** (invalid signature, wrong nonce)
* **Not found** (no active challenge for the public key)

These errors are surfaced as standard Sats Connect errors for your App to handle.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.xverse.app/sats-connect/spark-methods/flashnet-trading/spark_flashnet_getjwt.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.
