# Credential Management

Wallet Server stores Verifiable Credentials (VCs) per user. You can import, list, fetch, and delete credentials.

## Endpoints

* POST `/credentials`
  * Imports a credential JSON. Validates schema, proof, and (by default) that the subject matches the holder DID.
  * Body:
    * `credential`: VC JSON
    * `allowForeignSubject` (boolean, default `false`): if `true`, skip subject‑equals‑holder check
* GET `/credentials`
  * Returns `{ count, credentials }` with optional filters:
    * `network`: `mainnet` | `testnet` (derived from VC id DID)
    * `type`: VC type
    * `status`: W3C StatusPurpose
    * `issuedAt`: ISO date
    * `version`: 1 | 2
* GET `/credentials/:id`
  * Returns a specific credential by id.
* DELETE `/credentials`
  * Deletes all credentials for the authenticated user.
* DELETE `/credentials/:id`
  * Deletes a specific credential by id.

## Examples

Import a credential:

```
curl -X POST http://localhost:3000/credentials \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"credential": { ... }, "allowForeignSubject": false}'
```

List testnet credentials of a given type:

```
curl -H 'Authorization: Bearer <token>' \
  'http://localhost:3000/credentials?network=testnet&type=UniversityDegreeCredential'
```

Fetch by id:

```
curl -H 'Authorization: Bearer <token>' http://localhost:3000/credentials/<vc-id>
```

Delete all:

```
curl -X DELETE -H 'Authorization: Bearer <token>' http://localhost:3000/credentials
```

Delete by id:

```
curl -X DELETE -H 'Authorization: Bearer <token>' http://localhost:3000/credentials/<vc-id>
```

## Validation Rules (high level)

* Credential must have a recipient (holder)
* Unless `allowForeignSubject=true`, `credentialSubject.id` must equal holder DID
* Credential must have a `credentialSchema`
* Proof verification and schema validation must pass


---

# 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://docs.empe.io/develop/wallet-server/credential-management.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.
