# Issue a Verifiable Credential

Using the `/issue-credential-2.0` API endpoints, it is possible to issue Verifiable Credentials, signed by a cheqd DID, in a few clicks or lines of code. By following the following steps, you can effectively issue verifiable credentials using ACA-Py integrated with the cheqd ecosystem.

## Pre-requisite

For JSON-LD Credential Issuance, the Issuer DID must have `assertionMethod`  set to the `verificationMethod.id` . If your DID does not have `assertionMethod`, execute `POST /did/cheqd/update` API call to add new assertion method matching the `verificationMethod.id`.

## Step 1: Create a Connection with Holder

Use any supported method to create a connection with the Holder of the credential. Automated [out-of-band protocol](https://identity.foundation/didcomm-messaging/spec/#out-of-band-messages) is recommended.

### 1a: Issuer Creates Connection Invite

The Issuer agent will create a new connection invite for the Holder. This is needed to securely communicate between the Issuer and the Holder agents.

## POST /out-of-band/create-invitation

> Create a new connection invitation

```json
{"openapi":"3.1.1","info":{"title":"cheqd","version":"v1.1.1"},"tags":[{"name":"out-of-band","description":"Out-of-band connections"}],"paths":{"/out-of-band/create-invitation":{"post":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationRecord"}}}}},"parameters":[{"in":"query","name":"auto_accept","type":"boolean","description":"Auto-accept connection (defaults to configuration)","required":false},{"in":"query","name":"create_unique_did","type":"boolean","description":"Create unique DID for this invitation (default false)","required":false},{"in":"query","name":"multi_use","type":"boolean","description":"Create invitation for multiple use (default false)","required":false}],"tags":["out-of-band"],"summary":"Create a new connection invitation","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationCreateRequest"}}},"required":false}}}},"components":{"schemas":{"InvitationRecord":{"properties":{"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"invi_msg_id":{"description":"Invitation message identifier","type":"string"},"invitation":{"allOf":[{"$ref":"#/components/schemas/InvitationMessage"}],"description":"Out of band invitation message"},"invitation_id":{"description":"Invitation record identifier","type":"string"},"invitation_url":{"description":"Invitation message URL","type":"string"},"oob_id":{"description":"Out of band record identifier","type":"string"},"state":{"description":"Out of band message exchange state","type":"string"},"trace":{"description":"Record trace information, based on agent configuration","type":"boolean"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"InvitationMessage":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"accept":{"description":"List of mime type in order of preference","items":{"type":"string"},"type":"array"},"goal":{"description":"A self-attested string that the receiver may want to display to the user about the context-specific goal of the out-of-band message","type":"string"},"goal_code":{"description":"A self-attested code the receiver may want to display to the user or use in automatically deciding what to do with the out-of-band message","type":"string"},"handshake_protocols":{"items":{"description":"Handshake protocol","type":"string"},"type":"array"},"imageUrl":{"description":"Optional image URL for out-of-band invitation","format":"url","type":"string"},"label":{"description":"Optional label","type":"string"},"requests~attach":{"description":"Optional request attachment","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"services":{"items":{"description":"Either a DIDComm service object (as per RFC0067) or a DID string."},"type":"array"}},"type":"object"},"AttachDecorator":{"properties":{"@id":{"description":"Attachment identifier","type":"string"},"byte_count":{"description":"Byte count of data included by reference","type":"integer"},"data":{"$ref":"#/components/schemas/AttachDecoratorData"},"description":{"description":"Human-readable description of content","type":"string"},"filename":{"description":"File name","type":"string"},"lastmod_time":{"description":"Hint regarding last modification datetime, in ISO-8601 format","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"mime-type":{"description":"MIME type","type":"string"}},"required":["data"],"type":"object"},"AttachDecoratorData":{"properties":{"base64":{"description":"Base64-encoded data","pattern":"^[a-zA-Z0-9+/]*={0,2}$","type":"string"},"json":{"description":"JSON-serialized data"},"jws":{"allOf":[{"$ref":"#/components/schemas/AttachDecoratorDataJWS"}],"description":"Detached Java Web Signature"},"links":{"description":"List of hypertext links to data","items":{"type":"string"},"type":"array"},"sha256":{"description":"SHA256 hash (binhex encoded) of content","pattern":"^[a-fA-F0-9+/]{64}$","type":"string"}},"type":"object"},"AttachDecoratorDataJWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signatures":{"description":"List of signatures","items":{"$ref":"#/components/schemas/AttachDecoratorData1JWS"},"type":"array"}},"type":"object"},"AttachDecoratorDataJWSHeader":{"properties":{"kid":{"description":"Key identifier, in W3C did:key or DID URL format","pattern":"^did:(?:key:z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+|sov:[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}(;.*)?(\\?.*)?#.+)$","type":"string"}},"required":["kid"],"type":"object"},"AttachDecoratorData1JWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"}},"required":["header","signature"],"type":"object"},"InvitationCreateRequest":{"properties":{"accept":{"description":"List of mime type in order of preference that should be use in responding to the message","items":{"type":"string"},"type":"array"},"alias":{"description":"Alias for connection","type":"string"},"attachments":{"description":"Optional invitation attachments","items":{"$ref":"#/components/schemas/AttachmentDef"},"type":"array"},"goal":{"description":"A self-attested string that the receiver may want to display to the user about the context-specific goal of the out-of-band message","type":"string"},"goal_code":{"description":"A self-attested code the receiver may want to display to the user or use in automatically deciding what to do with the out-of-band message","type":"string"},"handshake_protocols":{"items":{"description":"Handshake protocol to specify in invitation","type":"string"},"type":"array"},"mediation_id":{"description":"Identifier for active mediation record to be used","pattern":"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}","type":"string"},"metadata":{"description":"Optional metadata to attach to the connection created with the invitation","type":"object"},"my_label":{"description":"Label for connection invitation","type":"string"},"protocol_version":{"description":"OOB protocol version","type":"string"},"use_did":{"description":"DID to use in invitation","type":"string"},"use_did_method":{"description":"DID method to use in invitation","enum":["did:peer:2","did:peer:4"],"type":"string"},"use_public_did":{"description":"Whether to use public DID in invitation","type":"boolean"}},"type":"object"},"AttachmentDef":{"properties":{"id":{"description":"Attachment identifier","type":"string"},"type":{"description":"Attachment type","enum":["credential-offer","present-proof"],"type":"string"}},"type":"object"}}}}
```

#### Parameters and Request Body

For automated acceptance, pass the following parameters:

<details>

<summary>auto_accept</summary>

Set this to true

</details>

A simple request body is below:

```json
{
    "alias": "Holder",
    "handshake_protocols": ["https://didcomm.org/didexchange/1.0"],
    "use_public_did": false,
    "my_label": "Invitation to Holder"
}
```

### 1b: Holder receives invitation

The above request will have an `invitation` in the response. Holder will have to copy that invitation and pass in the body of the following API call.

## POST /out-of-band/receive-invitation

> Receive a new connection invitation

```json
{"openapi":"3.1.1","info":{"title":"cheqd","version":"v1.1.1"},"tags":[{"name":"out-of-band","description":"Out-of-band connections"}],"paths":{"/out-of-band/receive-invitation":{"post":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OobRecord"}}}}},"parameters":[{"in":"query","name":"alias","type":"string","description":"Alias for connection","required":false},{"in":"query","name":"auto_accept","type":"boolean","description":"Auto-accept connection (defaults to configuration)","required":false},{"in":"query","name":"mediation_id","type":"string","pattern":"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}","description":"Identifier for active mediation record to be used","required":false},{"in":"query","name":"use_existing_connection","type":"boolean","description":"Use an existing connection, if possible","required":false}],"tags":["out-of-band"],"summary":"Receive a new connection invitation","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationMessage"}}},"required":false}}}},"components":{"schemas":{"OobRecord":{"properties":{"attach_thread_id":{"description":"Connection record identifier","type":"string"},"connection_id":{"description":"Connection record identifier","type":"string"},"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"invi_msg_id":{"description":"Invitation message identifier","type":"string"},"invitation":{"allOf":[{"$ref":"#/components/schemas/InvitationMessage"}],"description":"Out of band invitation message"},"multi_use":{"description":"Allow for multiple uses of the oob invitation","type":"boolean"},"oob_id":{"description":"Oob record identifier","type":"string"},"our_recipient_key":{"description":"Recipient key used for oob invitation","type":"string"},"role":{"description":"OOB Role","enum":["sender","receiver"],"type":"string"},"state":{"description":"Out of band message exchange state","enum":["initial","prepare-response","await-response","reuse-not-accepted","reuse-accepted","done","deleted"],"type":"string"},"their_service":{"$ref":"#/components/schemas/ServiceDecorator"},"trace":{"description":"Record trace information, based on agent configuration","type":"boolean"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"required":["invi_msg_id","invitation","oob_id","state"],"type":"object"},"InvitationMessage":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"accept":{"description":"List of mime type in order of preference","items":{"type":"string"},"type":"array"},"goal":{"description":"A self-attested string that the receiver may want to display to the user about the context-specific goal of the out-of-band message","type":"string"},"goal_code":{"description":"A self-attested code the receiver may want to display to the user or use in automatically deciding what to do with the out-of-band message","type":"string"},"handshake_protocols":{"items":{"description":"Handshake protocol","type":"string"},"type":"array"},"imageUrl":{"description":"Optional image URL for out-of-band invitation","format":"url","type":"string"},"label":{"description":"Optional label","type":"string"},"requests~attach":{"description":"Optional request attachment","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"services":{"items":{"description":"Either a DIDComm service object (as per RFC0067) or a DID string."},"type":"array"}},"type":"object"},"AttachDecorator":{"properties":{"@id":{"description":"Attachment identifier","type":"string"},"byte_count":{"description":"Byte count of data included by reference","type":"integer"},"data":{"$ref":"#/components/schemas/AttachDecoratorData"},"description":{"description":"Human-readable description of content","type":"string"},"filename":{"description":"File name","type":"string"},"lastmod_time":{"description":"Hint regarding last modification datetime, in ISO-8601 format","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"mime-type":{"description":"MIME type","type":"string"}},"required":["data"],"type":"object"},"AttachDecoratorData":{"properties":{"base64":{"description":"Base64-encoded data","pattern":"^[a-zA-Z0-9+/]*={0,2}$","type":"string"},"json":{"description":"JSON-serialized data"},"jws":{"allOf":[{"$ref":"#/components/schemas/AttachDecoratorDataJWS"}],"description":"Detached Java Web Signature"},"links":{"description":"List of hypertext links to data","items":{"type":"string"},"type":"array"},"sha256":{"description":"SHA256 hash (binhex encoded) of content","pattern":"^[a-fA-F0-9+/]{64}$","type":"string"}},"type":"object"},"AttachDecoratorDataJWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signatures":{"description":"List of signatures","items":{"$ref":"#/components/schemas/AttachDecoratorData1JWS"},"type":"array"}},"type":"object"},"AttachDecoratorDataJWSHeader":{"properties":{"kid":{"description":"Key identifier, in W3C did:key or DID URL format","pattern":"^did:(?:key:z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+|sov:[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}(;.*)?(\\?.*)?#.+)$","type":"string"}},"required":["kid"],"type":"object"},"AttachDecoratorData1JWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"}},"required":["header","signature"],"type":"object"},"ServiceDecorator":{"properties":{"recipientKeys":{"description":"List of recipient keys","items":{"description":"Recipient public key","pattern":"^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}$","type":"string"},"type":"array"},"routingKeys":{"description":"List of routing keys","items":{"description":"Routing key","pattern":"^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}$","type":"string"},"type":"array"},"serviceEndpoint":{"description":"Service endpoint at which to reach this agent","type":"string"}},"required":["recipientKeys","serviceEndpoint"],"type":"object"}}}}
```

#### Parameters and Request Body

<details>

<summary>auto_accept</summary>

Set this to true

</details>

<details>

<summary>alias</summary>

Pass an alias for the connection

</details>

<details>

<summary>use_existing_connection</summary>

Set this to true

</details>

The request body should be the `invitation` value from the `/create-invitation` call by the Issuer.

## Step 2: Holder creates local DID

For JSON-LD Credentials, the verification needs a Holder did as well. The Holder DID can be created locally by using the following API Call.

## POST /wallet/did/create

> Create a local DID

```json
{"openapi":"3.1.1","info":{"title":"cheqd","version":"v1.1.1"},"tags":[{"name":"wallet","description":"DID and tag policy management"}],"paths":{"/wallet/did/create":{"post":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DIDResult"}}}}},"tags":["wallet"],"summary":"Create a local DID","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DIDCreate"}}},"required":false}}}},"components":{"schemas":{"DIDResult":{"properties":{"result":{"$ref":"#/components/schemas/DID"}},"type":"object"},"DID":{"properties":{"did":{"description":"DID of interest","pattern":"^(did:sov:)?[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}$|^did:([a-zA-Z0-9_]+)(:[a-zA-Z0-9_.%-]+)?:([a-zA-Z0-9_.%-]+(:[a-zA-Z0-9_.%-]+)*)((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(\\/[^#?]*)?([?][^#]*)?(\\#.*)?$$","type":"string"},"key_type":{"description":"Key type associated with the DID","enum":["ed25519","bls12381g2"],"type":"string"},"metadata":{"description":"Additional metadata associated with the DID","type":"object"},"method":{"description":"Did method associated with the DID","type":"string"},"posture":{"description":"Whether DID is current public DID, posted to ledger but not current public DID, or local to the wallet","enum":["public","posted","wallet_only"],"type":"string"},"verkey":{"description":"Public verification key","pattern":"^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}$","type":"string"}},"required":["did","key_type","method","posture","verkey"],"type":"object"},"DIDCreate":{"properties":{"method":{"description":"Method for the requested DID.Supported methods are 'key', 'sov', and any other registered method.","type":"string"},"options":{"allOf":[{"$ref":"#/components/schemas/DIDCreateOptions"}],"description":"To define a key type and/or a did depending on chosen DID method."},"seed":{"description":"Optional seed to use for DID, Must be enabled in configuration before use.","type":"string"}},"type":"object"},"DIDCreateOptions":{"properties":{"did":{"description":"Specify final value of the did (including did:<method>: prefix)if the method supports or requires so.","pattern":"^(did:sov:)?[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}$|^did:([a-zA-Z0-9_]+)(:[a-zA-Z0-9_.%-]+)?:([a-zA-Z0-9_.%-]+(:[a-zA-Z0-9_.%-]+)*)((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(\\/[^#?]*)?([?][^#]*)?(\\#.*)?$$","type":"string"},"key_type":{"description":"Key type to use for the DID keypair. Validated with the chosen DID method's supported key types.","enum":["ed25519","bls12381g2"],"type":"string"}},"required":["key_type"],"type":"object"}}}}
```

**Request Body**

You can use the following request body to create the local did. Ensure the `key_type` matches the Issuer DID Key Type.

```json
{
  "method": "key",
  "options": {
    "key_type": "ed25519"
  }
}
```

## Step 3: Request Credential from Issuer

For this example, the Credential is requested from the Holder to the Issuer using the `/issue-credential-2.0/send-request` API. This request is sent to the Issuer, informing them about the credential request and its attributes in a JSON format.

## POST /issue-credential-2.0/send-request

> Send issuer a credential request not bound to an existing thread. Indy credentials cannot start at a request

```json
{"openapi":"3.1.1","info":{"title":"cheqd","version":"v1.1.1"},"tags":[{"name":"issue-credential v2.0","description":"Credential issue v2.0"}],"paths":{"/issue-credential-2.0/send-request":{"post":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/V20CredExRecord"}}}}},"tags":["issue-credential v2.0"],"summary":"Send issuer a credential request not bound to an existing thread. Indy credentials cannot start at a request","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/V20CredRequestFree"}}},"required":false}}}},"components":{"schemas":{"V20CredExRecord":{"properties":{"auto_issue":{"description":"Issuer choice to issue to request in this credential exchange","type":"boolean"},"auto_offer":{"description":"Holder choice to accept offer in this credential exchange","type":"boolean"},"auto_remove":{"description":"Issuer choice to remove this credential exchange record when complete","type":"boolean"},"by_format":{"allOf":[{"$ref":"#/components/schemas/V20CredExRecordByFormat"}],"description":"Attachment content by format for proposal, offer, request, and issue","readOnly":true},"connection_id":{"description":"Connection identifier","type":"string"},"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"cred_ex_id":{"description":"Credential exchange identifier","type":"string"},"cred_issue":{"allOf":[{"$ref":"#/components/schemas/V20CredIssue"}],"description":"Serialized credential issue message"},"cred_offer":{"allOf":[{"$ref":"#/components/schemas/V20CredOffer"}],"description":"Credential offer message"},"cred_preview":{"allOf":[{"$ref":"#/components/schemas/V20CredPreview"}],"description":"Credential preview from credential proposal","readOnly":true},"cred_proposal":{"allOf":[{"$ref":"#/components/schemas/V20CredProposal"}],"description":"Credential proposal message"},"cred_request":{"allOf":[{"$ref":"#/components/schemas/V20CredRequest"}],"description":"Serialized credential request message"},"error_msg":{"description":"Error message","type":"string"},"initiator":{"description":"Issue-credential exchange initiator: self or external","enum":["self","external"],"type":"string"},"parent_thread_id":{"description":"Parent thread identifier","type":"string"},"role":{"description":"Issue-credential exchange role: holder or issuer","enum":["issuer","holder"],"type":"string"},"state":{"description":"Issue-credential exchange state","enum":["proposal-sent","proposal-received","offer-sent","offer-received","request-sent","request-received","credential-issued","credential-received","done","credential-revoked","abandoned","deleted"],"type":"string"},"thread_id":{"description":"Thread identifier","type":"string"},"trace":{"description":"Record trace information, based on agent configuration","type":"boolean"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"V20CredExRecordByFormat":{"properties":{"cred_issue":{"type":"object"},"cred_offer":{"type":"object"},"cred_proposal":{"type":"object"},"cred_request":{"type":"object"}},"type":"object"},"V20CredIssue":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credentials~attach":{"description":"Credential attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"formats":{"description":"Acceptable attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"replacement_id":{"description":"Issuer-unique identifier to coordinate credential replacement","type":"string"}},"required":["credentials~attach","formats"],"type":"object"},"AttachDecorator":{"properties":{"@id":{"description":"Attachment identifier","type":"string"},"byte_count":{"description":"Byte count of data included by reference","type":"integer"},"data":{"$ref":"#/components/schemas/AttachDecoratorData"},"description":{"description":"Human-readable description of content","type":"string"},"filename":{"description":"File name","type":"string"},"lastmod_time":{"description":"Hint regarding last modification datetime, in ISO-8601 format","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"mime-type":{"description":"MIME type","type":"string"}},"required":["data"],"type":"object"},"AttachDecoratorData":{"properties":{"base64":{"description":"Base64-encoded data","pattern":"^[a-zA-Z0-9+/]*={0,2}$","type":"string"},"json":{"description":"JSON-serialized data"},"jws":{"allOf":[{"$ref":"#/components/schemas/AttachDecoratorDataJWS"}],"description":"Detached Java Web Signature"},"links":{"description":"List of hypertext links to data","items":{"type":"string"},"type":"array"},"sha256":{"description":"SHA256 hash (binhex encoded) of content","pattern":"^[a-fA-F0-9+/]{64}$","type":"string"}},"type":"object"},"AttachDecoratorDataJWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signatures":{"description":"List of signatures","items":{"$ref":"#/components/schemas/AttachDecoratorData1JWS"},"type":"array"}},"type":"object"},"AttachDecoratorDataJWSHeader":{"properties":{"kid":{"description":"Key identifier, in W3C did:key or DID URL format","pattern":"^did:(?:key:z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+|sov:[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}(;.*)?(\\?.*)?#.+)$","type":"string"}},"required":["kid"],"type":"object"},"AttachDecoratorData1JWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"}},"required":["header","signature"],"type":"object"},"V20CredFormat":{"properties":{"attach_id":{"description":"Attachment identifier","type":"string"},"format":{"description":"Attachment format specifier","type":"string"}},"required":["attach_id","format"],"type":"object"},"V20CredOffer":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credential_preview":{"$ref":"#/components/schemas/V20CredPreview"},"formats":{"description":"Acceptable credential formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"offers~attach":{"description":"Offer attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"replacement_id":{"description":"Issuer-unique identifier to coordinate credential replacement","type":"string"}},"required":["formats","offers~attach"],"type":"object"},"V20CredPreview":{"properties":{"@type":{"description":"Message type identifier","type":"string"},"attributes":{"items":{"$ref":"#/components/schemas/V20CredAttrSpec"},"type":"array"}},"required":["attributes"],"type":"object"},"V20CredAttrSpec":{"properties":{"mime-type":{"description":"MIME type: omit for (null) default","type":"string"},"name":{"description":"Attribute name","type":"string"},"value":{"description":"Attribute value: base64-encode if MIME type is present","type":"string"}},"required":["name","value"],"type":"object"},"V20CredProposal":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credential_preview":{"allOf":[{"$ref":"#/components/schemas/V20CredPreview"}],"description":"Credential preview"},"filters~attach":{"description":"Credential filter per acceptable format on corresponding identifier","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"formats":{"description":"Attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"}},"required":["filters~attach","formats"],"type":"object"},"V20CredRequest":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"formats":{"description":"Acceptable attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"requests~attach":{"description":"Request attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"}},"required":["formats","requests~attach"],"type":"object"},"V20CredRequestFree":{"properties":{"auto_remove":{"description":"Whether to remove the credential exchange record on completion (overrides --preserve-exchange-records configuration setting)","type":"boolean"},"comment":{"description":"Human-readable comment","type":"string"},"connection_id":{"description":"Connection identifier","type":"string"},"filter":{"allOf":[{"$ref":"#/components/schemas/V20CredFilterLDProof"}],"description":"Credential specification criteria by format"},"holder_did":{"description":"Holder DID to substitute for the credentialSubject.id","type":"string"},"trace":{"description":"Whether to trace event (default false)","type":"boolean"}},"required":["connection_id","filter"],"type":"object"},"V20CredFilterLDProof":{"properties":{"ld_proof":{"allOf":[{"$ref":"#/components/schemas/LDProofVCDetail"}],"description":"Credential filter for linked data proof"}},"required":["ld_proof"],"type":"object"},"LDProofVCDetail":{"additionalProperties":true,"properties":{"credential":{"allOf":[{"$ref":"#/components/schemas/Credential"}],"description":"Detail of the JSON-LD Credential to be issued"},"options":{"allOf":[{"$ref":"#/components/schemas/LDProofVCOptions"}],"description":"Options for specifying how the linked data proof is created."}},"required":["credential","options"],"type":"object"},"Credential":{"additionalProperties":true,"properties":{"@context":{"description":"The JSON-LD context of the credential","items":{},"type":"array"},"credentialStatus":{},"credentialSubject":{},"expirationDate":{"description":"The expiration date","pattern":"^([0-9]{4})-([0-9]{2})-([0-9]{2})([Tt ]([0-9]{2}):([0-9]{2}):([0-9]{2})(\\.[0-9]+)?)?(([Zz]|([+-])([0-9]{2}):([0-9]{2})))?$","type":"string"},"id":{"description":"The ID of the credential","pattern":"\\w+:(\\/?\\/?)[^\\s]+","type":"string"},"issuanceDate":{"description":"The issuance date","pattern":"^([0-9]{4})-([0-9]{2})-([0-9]{2})([Tt ]([0-9]{2}):([0-9]{2}):([0-9]{2})(\\.[0-9]+)?)?(([Zz]|([+-])([0-9]{2}):([0-9]{2})))?$","type":"string"},"issuer":{"description":"The JSON-LD Verifiable Credential Issuer. Either string of object with id field."},"proof":{"allOf":[{"$ref":"#/components/schemas/LinkedDataProof"}],"description":"The proof of the credential"},"type":{"description":"The JSON-LD type of the credential","items":{"type":"string"},"type":"array"}},"required":["@context","credentialSubject","issuanceDate","issuer","type"],"type":"object"},"LinkedDataProof":{"additionalProperties":true,"properties":{"challenge":{"description":"Associates a challenge with a proof, for use with a proofPurpose such as authentication","type":"string"},"created":{"description":"The string value of an ISO8601 combined date and time string generated by the Signature Algorithm","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"domain":{"description":"A string value specifying the restricted domain of the signature.","type":"string"},"jws":{"description":"Associates a Detached Json Web Signature with a proof","type":"string"},"nonce":{"description":"The nonce","type":"string"},"proofPurpose":{"description":"Proof purpose","type":"string"},"proofValue":{"description":"The proof value of a proof","type":"string"},"type":{"description":"Identifies the digital signature suite that was used to create the signature","type":"string"},"verificationMethod":{"description":"Information used for proof verification","pattern":"\\w+:(\\/?\\/?)[^\\s]+","type":"string"}},"required":["proofPurpose","type","verificationMethod"],"type":"object"},"LDProofVCOptions":{"additionalProperties":true,"properties":{"challenge":{"description":"A challenge to include in the proof. SHOULD be provided by the requesting party of the credential (=holder)","type":"string"},"created":{"description":"The date and time of the proof (with a maximum accuracy in seconds). Defaults to current system time","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"credentialStatus":{"allOf":[{"$ref":"#/components/schemas/CredentialStatusOptions"}],"description":"The credential status mechanism to use for the credential. Omitting the property indicates the issued credential will not include a credential status"},"domain":{"description":"The intended domain of validity for the proof","type":"string"},"proofPurpose":{"description":"The proof purpose used for the proof. Should match proof purposes registered in the Linked Data Proofs Specification","type":"string"},"proofType":{"description":"The proof type used for the proof. Should match suites registered in the Linked Data Cryptographic Suite Registry","type":"string"},"verificationMethod":{"description":"The verification method to use for the proof. Should match a verification method in the wallet","type":"string"}},"type":"object"},"CredentialStatusOptions":{"additionalProperties":true,"properties":{"type":{"description":"Credential status method type to use for the credential. Should match status method registered in the Verifiable Credential Extension Registry","type":"string"}},"required":["type"],"type":"object"}}}}
```

**Request Body**

The following request is a sample for creating a Citizenship credential.

```json
{
    "auto_remove": true,
    "comment": "Holder asking for Citizenship credential.",
    "connection_id": "{{holder-conn-id}}",
    "filter": {
        "ld_proof": {
            "credential": {
                "@context": [
                    "https://www.w3.org/2018/credentials/v1",
                    "https://w3id.org/citizenship/v1"
                ],
                "type": [
                    "VerifiableCredential",
                    "PermanentResident"
                ],
                "identifier": "{{$randomAlphaNumeric}}",
                "issuer": "{{issuer-did}}",
                "issuanceDate": "2020-01-01T12:00:00Z",
                "credentialSubject": {
                    "type": [
                        "PermanentResident",
                        "Person"
                    ],
                    "givenName": "ALICE",
                    "familyName": "SMITH",
                    "gender": "Female",
                    "birthCountry": "Bahamas",
                    "birthDate": "1958-07-17"
                }
            },
            "options": {
                "proofType": "Ed25519Signature2020"
            }
        }
    },
    "holder_did": "{{holder-local-did}}",
  "trace": false
}
```

## Step 4: Issuer accepts and issues credential

After the Issuer received and validated the request, they can issue the credential using the `/issue-credential-2.0/records/<credential-exchange-id>/issue` API endpoint. The `credential-exchange-id` can be retrieved by calling `GET /issue-credential-2.0/records?state=request-received` API.

## POST /issue-credential-2.0/records/{cred\_ex\_id}/issue

> Send holder a credential

```json
{"openapi":"3.1.1","info":{"title":"cheqd","version":"v1.1.1"},"tags":[{"name":"issue-credential v2.0","description":"Credential issue v2.0"}],"paths":{"/issue-credential-2.0/records/{cred_ex_id}/issue":{"post":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/V20CredExRecordDetail"}}}}},"parameters":[{"in":"path","name":"cred_ex_id","type":"string","pattern":"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}","description":"Credential exchange identifier","required":true}],"tags":["issue-credential v2.0"],"summary":"Send holder a credential","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/V20CredIssueRequest"}}},"required":false}}}},"components":{"schemas":{"V20CredExRecordDetail":{"properties":{"cred_ex_record":{"allOf":[{"$ref":"#/components/schemas/V20CredExRecord"}],"description":"Credential exchange record"},"indy":{"$ref":"#/components/schemas/V20CredExRecordIndy"},"ld_proof":{"$ref":"#/components/schemas/V20CredExRecordLDProof"},"vc_di":{"$ref":"#/components/schemas/V20CredExRecord"}},"type":"object"},"V20CredExRecord":{"properties":{"auto_issue":{"description":"Issuer choice to issue to request in this credential exchange","type":"boolean"},"auto_offer":{"description":"Holder choice to accept offer in this credential exchange","type":"boolean"},"auto_remove":{"description":"Issuer choice to remove this credential exchange record when complete","type":"boolean"},"by_format":{"allOf":[{"$ref":"#/components/schemas/V20CredExRecordByFormat"}],"description":"Attachment content by format for proposal, offer, request, and issue","readOnly":true},"connection_id":{"description":"Connection identifier","type":"string"},"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"cred_ex_id":{"description":"Credential exchange identifier","type":"string"},"cred_issue":{"allOf":[{"$ref":"#/components/schemas/V20CredIssue"}],"description":"Serialized credential issue message"},"cred_offer":{"allOf":[{"$ref":"#/components/schemas/V20CredOffer"}],"description":"Credential offer message"},"cred_preview":{"allOf":[{"$ref":"#/components/schemas/V20CredPreview"}],"description":"Credential preview from credential proposal","readOnly":true},"cred_proposal":{"allOf":[{"$ref":"#/components/schemas/V20CredProposal"}],"description":"Credential proposal message"},"cred_request":{"allOf":[{"$ref":"#/components/schemas/V20CredRequest"}],"description":"Serialized credential request message"},"error_msg":{"description":"Error message","type":"string"},"initiator":{"description":"Issue-credential exchange initiator: self or external","enum":["self","external"],"type":"string"},"parent_thread_id":{"description":"Parent thread identifier","type":"string"},"role":{"description":"Issue-credential exchange role: holder or issuer","enum":["issuer","holder"],"type":"string"},"state":{"description":"Issue-credential exchange state","enum":["proposal-sent","proposal-received","offer-sent","offer-received","request-sent","request-received","credential-issued","credential-received","done","credential-revoked","abandoned","deleted"],"type":"string"},"thread_id":{"description":"Thread identifier","type":"string"},"trace":{"description":"Record trace information, based on agent configuration","type":"boolean"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"V20CredExRecordByFormat":{"properties":{"cred_issue":{"type":"object"},"cred_offer":{"type":"object"},"cred_proposal":{"type":"object"},"cred_request":{"type":"object"}},"type":"object"},"V20CredIssue":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credentials~attach":{"description":"Credential attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"formats":{"description":"Acceptable attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"replacement_id":{"description":"Issuer-unique identifier to coordinate credential replacement","type":"string"}},"required":["credentials~attach","formats"],"type":"object"},"AttachDecorator":{"properties":{"@id":{"description":"Attachment identifier","type":"string"},"byte_count":{"description":"Byte count of data included by reference","type":"integer"},"data":{"$ref":"#/components/schemas/AttachDecoratorData"},"description":{"description":"Human-readable description of content","type":"string"},"filename":{"description":"File name","type":"string"},"lastmod_time":{"description":"Hint regarding last modification datetime, in ISO-8601 format","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"mime-type":{"description":"MIME type","type":"string"}},"required":["data"],"type":"object"},"AttachDecoratorData":{"properties":{"base64":{"description":"Base64-encoded data","pattern":"^[a-zA-Z0-9+/]*={0,2}$","type":"string"},"json":{"description":"JSON-serialized data"},"jws":{"allOf":[{"$ref":"#/components/schemas/AttachDecoratorDataJWS"}],"description":"Detached Java Web Signature"},"links":{"description":"List of hypertext links to data","items":{"type":"string"},"type":"array"},"sha256":{"description":"SHA256 hash (binhex encoded) of content","pattern":"^[a-fA-F0-9+/]{64}$","type":"string"}},"type":"object"},"AttachDecoratorDataJWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signatures":{"description":"List of signatures","items":{"$ref":"#/components/schemas/AttachDecoratorData1JWS"},"type":"array"}},"type":"object"},"AttachDecoratorDataJWSHeader":{"properties":{"kid":{"description":"Key identifier, in W3C did:key or DID URL format","pattern":"^did:(?:key:z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+|sov:[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}(;.*)?(\\?.*)?#.+)$","type":"string"}},"required":["kid"],"type":"object"},"AttachDecoratorData1JWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"}},"required":["header","signature"],"type":"object"},"V20CredFormat":{"properties":{"attach_id":{"description":"Attachment identifier","type":"string"},"format":{"description":"Attachment format specifier","type":"string"}},"required":["attach_id","format"],"type":"object"},"V20CredOffer":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credential_preview":{"$ref":"#/components/schemas/V20CredPreview"},"formats":{"description":"Acceptable credential formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"offers~attach":{"description":"Offer attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"replacement_id":{"description":"Issuer-unique identifier to coordinate credential replacement","type":"string"}},"required":["formats","offers~attach"],"type":"object"},"V20CredPreview":{"properties":{"@type":{"description":"Message type identifier","type":"string"},"attributes":{"items":{"$ref":"#/components/schemas/V20CredAttrSpec"},"type":"array"}},"required":["attributes"],"type":"object"},"V20CredAttrSpec":{"properties":{"mime-type":{"description":"MIME type: omit for (null) default","type":"string"},"name":{"description":"Attribute name","type":"string"},"value":{"description":"Attribute value: base64-encode if MIME type is present","type":"string"}},"required":["name","value"],"type":"object"},"V20CredProposal":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credential_preview":{"allOf":[{"$ref":"#/components/schemas/V20CredPreview"}],"description":"Credential preview"},"filters~attach":{"description":"Credential filter per acceptable format on corresponding identifier","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"formats":{"description":"Attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"}},"required":["filters~attach","formats"],"type":"object"},"V20CredRequest":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"formats":{"description":"Acceptable attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"requests~attach":{"description":"Request attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"}},"required":["formats","requests~attach"],"type":"object"},"V20CredExRecordIndy":{"properties":{"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"cred_ex_id":{"description":"Corresponding v2.0 credential exchange record identifier","type":"string"},"cred_ex_indy_id":{"description":"Record identifier","type":"string"},"cred_id_stored":{"description":"Credential identifier stored in wallet","type":"string"},"cred_request_metadata":{"description":"Credential request metadata for indy holder","type":"object"},"cred_rev_id":{"description":"Credential revocation identifier within revocation registry","pattern":"^[1-9][0-9]*$","type":"string"},"rev_reg_id":{"description":"Revocation registry identifier","pattern":"^([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):4:([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):3:CL:(([1-9][0-9]*)|([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}:2:.+:[0-9.]+))(:.+)?:CL_ACCUM:(.+$)","type":"string"},"state":{"description":"Current record state","type":"string"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"V20CredExRecordLDProof":{"properties":{"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"cred_ex_id":{"description":"Corresponding v2.0 credential exchange record identifier","type":"string"},"cred_ex_ld_proof_id":{"description":"Record identifier","type":"string"},"cred_id_stored":{"description":"Credential identifier stored in wallet","type":"string"},"state":{"description":"Current record state","type":"string"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"V20CredIssueRequest":{"properties":{"comment":{"description":"Human-readable comment","type":"string"}},"type":"object"}}}}
```

## Step 5: Holder stores Credential

The Holder has to store the issued credential into their wallet using the following API. The `cred_ex_id` can be retrieved by running API `GET /issue-credential-2.0/records?state=credential-received` on the Holder side.

## POST /issue-credential-2.0/records/{cred\_ex\_id}/store

> Store a received credential

```json
{"openapi":"3.1.1","info":{"title":"cheqd","version":"v1.1.1"},"tags":[{"name":"issue-credential v2.0","description":"Credential issue v2.0"}],"paths":{"/issue-credential-2.0/records/{cred_ex_id}/store":{"post":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/V20CredExRecordDetail"}}}}},"parameters":[{"in":"path","name":"cred_ex_id","type":"string","pattern":"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}","description":"Credential exchange identifier","required":true}],"tags":["issue-credential v2.0"],"summary":"Store a received credential","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/V20CredStoreRequest"}}},"required":false}}}},"components":{"schemas":{"V20CredExRecordDetail":{"properties":{"cred_ex_record":{"allOf":[{"$ref":"#/components/schemas/V20CredExRecord"}],"description":"Credential exchange record"},"indy":{"$ref":"#/components/schemas/V20CredExRecordIndy"},"ld_proof":{"$ref":"#/components/schemas/V20CredExRecordLDProof"},"vc_di":{"$ref":"#/components/schemas/V20CredExRecord"}},"type":"object"},"V20CredExRecord":{"properties":{"auto_issue":{"description":"Issuer choice to issue to request in this credential exchange","type":"boolean"},"auto_offer":{"description":"Holder choice to accept offer in this credential exchange","type":"boolean"},"auto_remove":{"description":"Issuer choice to remove this credential exchange record when complete","type":"boolean"},"by_format":{"allOf":[{"$ref":"#/components/schemas/V20CredExRecordByFormat"}],"description":"Attachment content by format for proposal, offer, request, and issue","readOnly":true},"connection_id":{"description":"Connection identifier","type":"string"},"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"cred_ex_id":{"description":"Credential exchange identifier","type":"string"},"cred_issue":{"allOf":[{"$ref":"#/components/schemas/V20CredIssue"}],"description":"Serialized credential issue message"},"cred_offer":{"allOf":[{"$ref":"#/components/schemas/V20CredOffer"}],"description":"Credential offer message"},"cred_preview":{"allOf":[{"$ref":"#/components/schemas/V20CredPreview"}],"description":"Credential preview from credential proposal","readOnly":true},"cred_proposal":{"allOf":[{"$ref":"#/components/schemas/V20CredProposal"}],"description":"Credential proposal message"},"cred_request":{"allOf":[{"$ref":"#/components/schemas/V20CredRequest"}],"description":"Serialized credential request message"},"error_msg":{"description":"Error message","type":"string"},"initiator":{"description":"Issue-credential exchange initiator: self or external","enum":["self","external"],"type":"string"},"parent_thread_id":{"description":"Parent thread identifier","type":"string"},"role":{"description":"Issue-credential exchange role: holder or issuer","enum":["issuer","holder"],"type":"string"},"state":{"description":"Issue-credential exchange state","enum":["proposal-sent","proposal-received","offer-sent","offer-received","request-sent","request-received","credential-issued","credential-received","done","credential-revoked","abandoned","deleted"],"type":"string"},"thread_id":{"description":"Thread identifier","type":"string"},"trace":{"description":"Record trace information, based on agent configuration","type":"boolean"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"V20CredExRecordByFormat":{"properties":{"cred_issue":{"type":"object"},"cred_offer":{"type":"object"},"cred_proposal":{"type":"object"},"cred_request":{"type":"object"}},"type":"object"},"V20CredIssue":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credentials~attach":{"description":"Credential attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"formats":{"description":"Acceptable attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"replacement_id":{"description":"Issuer-unique identifier to coordinate credential replacement","type":"string"}},"required":["credentials~attach","formats"],"type":"object"},"AttachDecorator":{"properties":{"@id":{"description":"Attachment identifier","type":"string"},"byte_count":{"description":"Byte count of data included by reference","type":"integer"},"data":{"$ref":"#/components/schemas/AttachDecoratorData"},"description":{"description":"Human-readable description of content","type":"string"},"filename":{"description":"File name","type":"string"},"lastmod_time":{"description":"Hint regarding last modification datetime, in ISO-8601 format","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"mime-type":{"description":"MIME type","type":"string"}},"required":["data"],"type":"object"},"AttachDecoratorData":{"properties":{"base64":{"description":"Base64-encoded data","pattern":"^[a-zA-Z0-9+/]*={0,2}$","type":"string"},"json":{"description":"JSON-serialized data"},"jws":{"allOf":[{"$ref":"#/components/schemas/AttachDecoratorDataJWS"}],"description":"Detached Java Web Signature"},"links":{"description":"List of hypertext links to data","items":{"type":"string"},"type":"array"},"sha256":{"description":"SHA256 hash (binhex encoded) of content","pattern":"^[a-fA-F0-9+/]{64}$","type":"string"}},"type":"object"},"AttachDecoratorDataJWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signatures":{"description":"List of signatures","items":{"$ref":"#/components/schemas/AttachDecoratorData1JWS"},"type":"array"}},"type":"object"},"AttachDecoratorDataJWSHeader":{"properties":{"kid":{"description":"Key identifier, in W3C did:key or DID URL format","pattern":"^did:(?:key:z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+|sov:[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}(;.*)?(\\?.*)?#.+)$","type":"string"}},"required":["kid"],"type":"object"},"AttachDecoratorData1JWS":{"properties":{"header":{"$ref":"#/components/schemas/AttachDecoratorDataJWSHeader"},"protected":{"description":"protected JWS header","pattern":"^[-_a-zA-Z0-9]*$","type":"string"},"signature":{"description":"signature","pattern":"^[-_a-zA-Z0-9]*$","type":"string"}},"required":["header","signature"],"type":"object"},"V20CredFormat":{"properties":{"attach_id":{"description":"Attachment identifier","type":"string"},"format":{"description":"Attachment format specifier","type":"string"}},"required":["attach_id","format"],"type":"object"},"V20CredOffer":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credential_preview":{"$ref":"#/components/schemas/V20CredPreview"},"formats":{"description":"Acceptable credential formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"offers~attach":{"description":"Offer attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"replacement_id":{"description":"Issuer-unique identifier to coordinate credential replacement","type":"string"}},"required":["formats","offers~attach"],"type":"object"},"V20CredPreview":{"properties":{"@type":{"description":"Message type identifier","type":"string"},"attributes":{"items":{"$ref":"#/components/schemas/V20CredAttrSpec"},"type":"array"}},"required":["attributes"],"type":"object"},"V20CredAttrSpec":{"properties":{"mime-type":{"description":"MIME type: omit for (null) default","type":"string"},"name":{"description":"Attribute name","type":"string"},"value":{"description":"Attribute value: base64-encode if MIME type is present","type":"string"}},"required":["name","value"],"type":"object"},"V20CredProposal":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"credential_preview":{"allOf":[{"$ref":"#/components/schemas/V20CredPreview"}],"description":"Credential preview"},"filters~attach":{"description":"Credential filter per acceptable format on corresponding identifier","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"},"formats":{"description":"Attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"}},"required":["filters~attach","formats"],"type":"object"},"V20CredRequest":{"properties":{"@id":{"description":"Message identifier","type":"string"},"@type":{"description":"Message type","type":"string"},"comment":{"description":"Human-readable comment","type":"string"},"formats":{"description":"Acceptable attachment formats","items":{"$ref":"#/components/schemas/V20CredFormat"},"type":"array"},"requests~attach":{"description":"Request attachments","items":{"$ref":"#/components/schemas/AttachDecorator"},"type":"array"}},"required":["formats","requests~attach"],"type":"object"},"V20CredExRecordIndy":{"properties":{"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"cred_ex_id":{"description":"Corresponding v2.0 credential exchange record identifier","type":"string"},"cred_ex_indy_id":{"description":"Record identifier","type":"string"},"cred_id_stored":{"description":"Credential identifier stored in wallet","type":"string"},"cred_request_metadata":{"description":"Credential request metadata for indy holder","type":"object"},"cred_rev_id":{"description":"Credential revocation identifier within revocation registry","pattern":"^[1-9][0-9]*$","type":"string"},"rev_reg_id":{"description":"Revocation registry identifier","pattern":"^([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):4:([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):3:CL:(([1-9][0-9]*)|([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}:2:.+:[0-9.]+))(:.+)?:CL_ACCUM:(.+$)","type":"string"},"state":{"description":"Current record state","type":"string"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"V20CredExRecordLDProof":{"properties":{"created_at":{"description":"Time of record creation","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"},"cred_ex_id":{"description":"Corresponding v2.0 credential exchange record identifier","type":"string"},"cred_ex_ld_proof_id":{"description":"Record identifier","type":"string"},"cred_id_stored":{"description":"Credential identifier stored in wallet","type":"string"},"state":{"description":"Current record state","type":"string"},"updated_at":{"description":"Time of last record update","pattern":"^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$","type":"string"}},"type":"object"},"V20CredStoreRequest":{"properties":{"credential_id":{"type":"string"}},"type":"object"}}}}
```

## Step 6: Check the received Credential

As this is a JSON-LD Credential, Holder must use `POST /credentials/w3c` API to check the credential.

## POST /credentials/w3c

> Fetch W3C credentials from wallet

```json
{"openapi":"3.1.1","info":{"title":"cheqd","version":"v1.1.1"},"tags":[{"name":"credentials","description":"Holder credential management"}],"paths":{"/credentials/w3c":{"post":{"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VCRecordList"}}}}},"parameters":[{"in":"query","name":"count","type":"string","pattern":"^[1-9][0-9]*$","description":"Maximum number to retrieve","required":false},{"in":"query","name":"start","type":"string","pattern":"^[0-9]*$","description":"Start index","required":false},{"in":"query","name":"wql","type":"string","pattern":"^{.*}$","description":"(JSON) WQL query","required":false}],"tags":["credentials"],"summary":"Fetch W3C credentials from wallet","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/W3CCredentialsListRequest"}}},"required":false}}}},"components":{"schemas":{"VCRecordList":{"properties":{"results":{"items":{"$ref":"#/components/schemas/VCRecord"},"type":"array"}},"type":"object"},"VCRecord":{"properties":{"contexts":{"items":{"description":"Context","pattern":"^[A-Za-z0-9\\.\\-\\+]+://([A-Za-z0-9][.A-Za-z0-9-_]+[A-Za-z0-9])+(:[1-9][0-9]*)?(/[^?&#]+)?$","type":"string"},"type":"array"},"cred_tags":{"additionalProperties":{"description":"Retrieval tag value","type":"string"},"type":"object"},"cred_value":{"description":"(JSON-serializable) credential value","type":"object"},"expanded_types":{"items":{"description":"JSON-LD expanded type extracted from type and context","type":"string"},"type":"array"},"given_id":{"description":"Credential identifier","type":"string"},"issuer_id":{"description":"Issuer identifier","type":"string"},"proof_types":{"items":{"description":"Signature suite used for proof","type":"string"},"type":"array"},"record_id":{"description":"Record identifier","type":"string"},"schema_ids":{"items":{"description":"Schema identifier","type":"string"},"type":"array"},"subject_ids":{"items":{"description":"Subject identifier","type":"string"},"type":"array"}},"type":"object"},"W3CCredentialsListRequest":{"properties":{"contexts":{"items":{"description":"Credential context to match","pattern":"^[A-Za-z0-9\\.\\-\\+]+://([A-Za-z0-9][.A-Za-z0-9-_]+[A-Za-z0-9])+(:[1-9][0-9]*)?(/[^?&#]+)?$","type":"string"},"type":"array"},"given_id":{"description":"Given credential id to match","type":"string"},"issuer_id":{"description":"Credential issuer identifier to match","type":"string"},"max_results":{"description":"Maximum number of results to return","type":"integer"},"proof_types":{"items":{"description":"Signature suite used for proof","type":"string"},"type":"array"},"schema_ids":{"description":"Schema identifiers, all of which to match","items":{"description":"Credential schema identifier","pattern":"^[A-Za-z0-9\\.\\-\\+]+://([A-Za-z0-9][.A-Za-z0-9-_]+[A-Za-z0-9])+(:[1-9][0-9]*)?(/[^?&#]+)?$","type":"string"},"type":"array"},"subject_ids":{"description":"Subject identifiers, all of which to match","items":{"description":"Subject identifier","type":"string"},"type":"array"},"tag_query":{"additionalProperties":{"description":"Tag value","type":"string"},"description":"Tag filter","type":"object"},"types":{"items":{"description":"Credential type to match","pattern":"^[A-Za-z0-9\\.\\-\\+]+://([A-Za-z0-9][.A-Za-z0-9-_]+[A-Za-z0-9])+(:[1-9][0-9]*)?(/[^?&#]+)?$","type":"string"},"type":"array"}},"type":"object"}}}}
```

**Request Body**

For our citizenship credential example, the following request can be used

```json
{
    "contexts": [
        "https://www.w3.org/2018/credentials/v1",
        "https://w3id.org/citizenship/v1"
    ],
    "proof_types": [
        "Ed25519Signature2020"
    ]
}
```
