> For the complete documentation index, see [llms.txt](https://docs.empe.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.empe.io/getting-started/tutorial/testing-issuance.md).

# Testing Credential Issuance

**What We Are Doing:**

* Running the server.
* Using the reference Empe DID Wallet to claim the issued credential.
* Confirming the credential was claimed by inspecting the issuance session.

**Why:** To make sure the end-to-end issuance flow works before we add the Verifier. A successful test proves that our backend can authenticate to the Issuer API, create a credential offer, and that a wallet can claim the offered credential.

**Before you start:** Two things must be true for the offer to reach the wallet:

* **The server must be authenticated to the Issuer API.** Every call our backend makes to the Issuer carries an OIDC access token as `Authorization: Bearer <token>` (the `ISSUER_ACCESS_TOKEN` from your `.env`). If the token is missing or invalid, the offer call fails and no QR code is produced. (Running locally with `AUTH_DISABLED=true`? Then no token is needed — see [Authenticating to the API](/getting-started/tutorial/authentication.md).)
* **The offer must be reachable from the phone.** The credential offer is an `openid-credential-offer://` URI that points the wallet back at the Issuer's `ISSUER_BASE_URL`. Your phone resolves that URL directly, so it cannot be `localhost` — use a host the device can reach (a LAN IP or a public HTTPS URL). In production, OpenID4VCI requires HTTPS.

**Steps:**

1. Run the application:

   ```bash
   node src/index.js
   ```
2. Open `http://localhost:4000/` in your browser.
3. Fill out the form (age, firstName, lastName) and submit. Your backend calls the Issuer to create a credential offer and returns a QR code rendering that offer.
4. A QR code appears. Open the Empe DID Wallet on your phone and scan it. The wallet resolves the offer, contacts the Issuer, and stores the issued credential.

## Confirming the credential was claimed

When you created the offer, the Issuer returned an `issuanceSessionId`. You can use it to check the session state and confirm the wallet completed the claim:

**Endpoint:** `GET /issuance-sessions/:sessionId`

```bash
curl https://your-issuer.evdi.app/issuance-sessions/d07d0df5-0d64-4f1a-9aa7-7e7f9c2a1d70 \
  -H "Authorization: Bearer $ISSUER_ACCESS_TOKEN"
```

**Response Body:**

```json
{
  "id": "d07d0df5-0d64-4f1a-9aa7-7e7f9c2a1d70",
  "issuerId": "did:web:your-issuer.evdi.app:8f3c...",
  "state": "Completed",
  "credentialOfferUri": "openid-credential-offer://?credential_offer=...",
  "expiresAt": "2026-06-22T12:34:56.789Z",
  "createdAt": "2026-06-22T12:04:56.789Z",
  "issuedCredentials": ["urn:uuid:abc123"]
}
```

The session starts at `OfferCreated`. Once the wallet claims the credential, `state` becomes `Completed` and `issuedCredentials` lists the issued credential IDs. If something goes wrong, `state` is `Error` and `errorMessage` explains why.

If the QR scan succeeded and the session reports `Completed`, you have successfully issued a credential. Next, we will deploy and integrate the Verifier to check this credential.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.empe.io/getting-started/tutorial/testing-issuance.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
