Listing credential offers

After the issuer1 sends a credential offer to user1, user1 can view all their credential offers.

To list all credential offers in the inbound_offer state, use the following command:

curl --location 'https://${service_url}/v1.0/diagency/credentials?state=inbound_offer' \
--header 'Authorization: Bearer ${user1_verifiable_credentials_access_token}'

This command returns a list of credentials, where each credential has a unique id field value. The following is an example response:

{
    "count": 1,
    "items": [
        {
            "id": "daa66cd9-7186-406c-9aa1-7ce4df616a97",
            "role": "holder",
            "state": "inbound_offer",
            "offer": {
                "attributes": {
                    "schema_id": "CRG4orwzg21CmvhErsyyjk:2:course:1.0",
                    "cred_def_id": "CRG4orwzg21CmvhErsyyjk:3:CL:33:TAG1",
                    ...
                }
            },
            "issuer_did": "CRG4orwzg21CmvhErsyyjk",
            "connection": {
                "id": "e06ca23f-2b17-4e17-b668-040c2f53bf63",
                ...,
                "role": "inviter",
                "state": "connected",
                "local": {
                    ...
                },
                "remote": {
                    ...
                },
                ...,
                "did_exchange": true,
                ...
            },
            "preview": {
                ...
            },
            "cred_def_id": "CRG4orwzg21CmvhErsyyjk:3:CL:33:TAG1",
            "format": "indy",
            ...,
            "schema_id": "CRG4orwzg21CmvhErsyyjk:2:course:1.0",
            "schema_name": "course",
            "schema_version": "1.0"
        }
    ]
}

To retrieve a specific credential offer, use the following GET request:

GET https://${service_url}/v1.0/diagency/credentials/${id}

Accepting a credential offer

The offer.attributes section is used to determine whether the user agrees with the attribute values that are being offered.

If user1 agrees with the attribute values in the credential offer, they can accept the offer by sending a PATCH request with the id of the offer:

curl --location --request PATCH 'https://${service_url}/v1.0/diagency/credentials/daa66cd9-7186-406c-9aa1-7ce4df616a97' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${user1_verifiable_credentials_access_token}' \
--data '{
    "state": "accepted"
}'

This changes the credential state to stored for user1.

{
    "id": "daa66cd9-7186-406c-9aa1-7ce4df616a97",
    "role": "holder",
    "state": "stored",
    "offer": {
        ...
    }
}

It also changes the credential state to issued for issuer1.

curl --location 'https://${service_url}/v1.0/diagency/credentials/daa66cd9-7186-406c-9aa1-7ce4df616a97' \
--header 'Authorization: Bearer ${issuer1_verifiable_credentials_access_token}'

With a response similar to:

{
    "id": "daa66cd9-7186-406c-9aa1-7ce4df616a97",
    "role": "issuer",
    "state": "issued",
    "offer": {
        "attributes": {
            "class": "Math 100",
            "grade": "A",
            "rank": "2",
            "instructor": "Dr. Math"
        }
    },
    "issuer_did": "CRG4orwzg21CmvhErsyyjk",
    "connection": {
        "id": "e06ca23f-2b17-4e17-b668-040c2f53bf63",
        ...
    },
    ...,
    "schema_id": "CRG4orwzg21CmvhErsyyjk:2:course:1.0",
    ...
}

Rejecting or deleting a credential offer

If user1 does not agree with the attribute values or does not want to accept the credential offer, they have two options. Using the ${user1_verifiable_credentials_access_token}.

  1. Reject the credential offer. Retain the credential object but change its state to "rejected" for both user1 and issuer1.
    PATCH https://${service_url}/v1.0/diagency/credentials/daa66cd9-7186-406c-9aa1-7ce4df616a97 -d '{"state":"rejected"}'
  2. Delete the credential offer. Delete the credential object for user1 and change the state to "deleted" for issuer1.
    DELETE https://${service_url}/v1.0/diagency/credentials/daa66cd9-7186-406c-9aa1-7ce4df616a97