> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CredentialService

Service for managing and retrieving verifiable credentials from different sources. By default, it includes procedures for IPFS and Crossmint, but additional procedures can be added by the user.

* CredentialService().getById(credentialId: string) : Fetches the credential from crossmint using the credentialId.
* CredentialService().getCredential(collection: CredentialsCollection, tokenId: string) : Fetches the credential from the source that matches the storage location of the credential.

## Remarks

To use the Crossmint procedure, a Crossmint API key with the `credentials.read` scope must be set.

## Extends

* `CredentialService`

## Constructors

### new CredentialService()

> **new CredentialService**(`retrievalProcedures`): [`CredentialService`](./CredentialService)

#### Parameters

| Parameter             | Type                              |
| --------------------- | --------------------------------- |
| `retrievalProcedures` | `CredentialRetrievalProcedure`\[] |

#### Returns

[`CredentialService`](./CredentialService)

#### Overrides

`CredentialServiceRaw.constructor`

#### Defined in

[presentation/getCredential.ts:100](https://github.com/Crossmint/crossmint-sdk/blob/main/packages/client/verifiable-credentials/src/presentation/getCredential.ts#L100)

## Properties

| Property              | Type                              | Inherited from                             | Defined in                                                                                                                                                                                                              |
| --------------------- | --------------------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `retrievalProcedures` | `CredentialRetrievalProcedure`\[] | `CredentialServiceRaw.retrievalProcedures` | [verifiableCredentialsSDK/presentation/getCredential.ts:45](https://github.com/Crossmint/crossmint-sdk/blob/main/packages/client/verifiable-credentials/src/verifiableCredentialsSDK/presentation/getCredential.ts#L45) |

## Methods

### getById()

> **getById**(`credentialId`): `Promise`\<`null` | [`VerifiableCredentialType`](../type-aliases/VerifiableCredentialType)>

Retrieves a verifiable credential from Crossmint using its credential ID.

#### Parameters

| Parameter      | Type     | Description                           |
| -------------- | -------- | ------------------------------------- |
| `credentialId` | `string` | The ID of the credential to retrieve. |

#### Returns

`Promise`\<`null` | [`VerifiableCredentialType`](../type-aliases/VerifiableCredentialType)>

A promise that resolves to a `VerifiableCredentialType` or `null` if the credential is not found.

#### Throws

Will throw an error if the credential retrieval fails.

#### Defined in

[presentation/getCredential.ts:112](https://github.com/Crossmint/crossmint-sdk/blob/main/packages/client/verifiable-credentials/src/presentation/getCredential.ts#L112)

***

### getCredential()

> **getCredential**(`collection`, `tokenId`): `Promise`\<[`VerifiableCredentialType`](../type-aliases/VerifiableCredentialType)>

Retrieves a Verifiable Credential from a given collection and token ID.

This function finds the appropriate retrieval procedure based on the collection's metadata and uses it to fetch the credential.

#### Parameters

| Parameter    | Type                                                           | Description                                                       |
| ------------ | -------------------------------------------------------------- | ----------------------------------------------------------------- |
| `collection` | [`CredentialsCollection`](../interfaces/CredentialsCollection) | The `CredentialsCollection` containing the credential's metadata. |
| `tokenId`    | `string`                                                       | The token ID of the credential to retrieve.                       |

#### Returns

`Promise`\<[`VerifiableCredentialType`](../type-aliases/VerifiableCredentialType)>

A promise that resolves to a `VerifiableCredentialType`.

#### Throws

Will throw an error if the collection is not a verifiable credential collection or if the retrieval endpoint is unsupported.

#### Inherited from

`CredentialServiceRaw.getCredential`

#### Defined in

[verifiableCredentialsSDK/presentation/getCredential.ts:65](https://github.com/Crossmint/crossmint-sdk/blob/main/packages/client/verifiable-credentials/src/verifiableCredentialsSDK/presentation/getCredential.ts#L65)
