> ## 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.

# Issue Credentials

> Specify the credential's values and a recipient to send it to

With both a credential type and template defined, we can proceed to issue a credential.

## 1. Issue a Credential

First and foremost, the issuer must specify a valid recipient for the credential:

* **recipient** (required): Issuer must specify a credential recipient. This can be done via `email:${userEmail}:${chain}` or `{wallet address}`.

In addition, the issuer must specify a **credential** object containing:

* **subject** (required): Object matching a defined credential type's schema, with values relevant to the recipient. The credential's contents are identified by the "subject" key within the credential, following [W3C naming standards](https://www.w3.org/TR/vc-data-model-2.0/#credential-subject).

<Warning>
  The credential subject (credential.subject) must respect the schema of the chosen Verifiable Credential type. You
  cannot add additional fields, nor exclude any that were previously set.
</Warning>

* **expiresAt** (required): Specify date, in form such as `2034-02-02` (ISO) or `none` to imply infinite expiration.

<Warning>If you don't include an expiration date, you must revoke the credential via burning to invalidate it.</Warning>

Finally, the issuer can provide optional public metadata related to the specific credential, as such:

* **metadata** (optional): NFT metadata is inherited from the VC template metadata. Metadata attributes can be set by the customer to override metadata definition inherited by baseURI.

To issue your first credential, copy the `issueCredential.js` file from below, add your API key, and templateId (that was returned to you in the previous step), and run the file from your terminal.

<CodeGroup>
  ```javascript issueCredential.js theme={null}
  const userEmail = "user@email.com"; // Replace with recipient email
  const templateId = "YOUR_TEMPLATE_ID"; // Replace with ID from previous step

  const credentialParams = {
      recipient: `email:${userEmail}:polygon-amoy`,
      credential: {
          // The CourseCompletionCertificate credential type requires course and grade declarations
          subject: {
              course: "Blockchain 101",
              grade: "A",
          },
          expiresAt: "2034-02-02",
      },
  };

  const options = {
      method: "POST",
      headers: {
          "X-API-KEY": "YOUR_API_KEY",
          "Content-Type": "application/json",
      },
      body: JSON.stringify(credentialParams),
  };

  fetch(`https://staging.crossmint.com/api/v1-alpha1/credentials/templates/${templateId}/vcs`, options)
      .then((response) => response.json())
      .then((response) => console.log(JSON.stringify(response)))
      .catch((err) => console.error(err));
  ```

  ```json Response theme={null}
  {
      "id": "d7eb777b-e9b4-4f34-ab5f-ce199111166a",
      "onChain": {
          "status": "pending",
          "chain": "polygon-amoy",
          "contractAddress": "0xdC444A3F4768185497Dae6250E2F348b99bE89F3"
      },
      "credentialId": "urn:uuid:64f9877d-a19a-4205-8d61-f8c2abed5766",
      "actionId": "d7eb777b-e9b4-4f34-ab5f-ce199111166a"
  }
  ```
</CodeGroup>

```shell theme={null}
node issueCredential.js
```

## 2. Check the status of your credential

You can [set up a webhook](/minting/verifiable-credentials/integrate/webhooks) to know when the Verifiable Credential NFT minting is completed, or call the
[action status API](/api-reference/common/get-action-status) with the returned `actionId`.

To check the template's status you will need the `nfts.create` API scope and run the following code.

```typescript checkTemplateStatus.js theme={null}
const actionId = "<YOUR_ACTION_ID>"; // Returned from previous step
const options = { method: "GET", headers: { "X-API-KEY": "<YOUR_API_KEY>" } };

fetch(`https://staging.crossmint.com/api/2022-06-09/actions/${actionId}`, options)
    .then((response) => response.json())
    .then((response) => console.log(response))
    .catch((err) => console.error(err));
```

<CardGroup cols={2}>
  <Card title="API Reference" icon="terminal" color="#B56710" href="/api-reference/verifiable-credentials/credentials/issue-credential">
    Test any API in seconds directly from the docs.
  </Card>

  <Card title="Talk to an expert" icon="message" iconType="duotone" color="#ADD8E6" href="https://www.crossmint.com/contact/sales">
    Contact our sales team for support.
  </Card>
</CardGroup>
