Wallets

Our Wallet API was created for any use case that requires a self-sovereign identity wallet in the cloud. This might include cases where the subject of the wallet is not the holder of the wallet. For example, pets or IoT devices.

In some cases, users may not have the ability to maintain a mobile wallet on their phone, and instead it would be more useful to have the wallet hosted on a server.

Here are some useful resources to get started:

Authentication

To begin using the Wallet API, an organization will need to be created on Trinsic Studio and that access token and subscription key should be included in the headers of each API call.

curl -X POST "https://api.streetcred.id/custodian/v1/api/wallets" \
-H "accept: text/plain" \
-H "Authorization: bearer <Access Token>" \
-H "X-Streetcred-Subscription-Key: <Subscription Key>" \
-H "Content-Type: application/json-patch+json" \
-d "{ \"ownerName\": \"Test Wallet\"}"

Create a Wallet

POST /api/wallets

To begin using the Wallet API, first you'll need to create a new custodian wallet. This wallet is hosted on the Trinsic Agency, and will be associated with whichever organization's accessToken was used to create the wallet.

curl -X POST "https://api.streetcred.id/custodian/v1/api/wallets" \
-H "accept: text/plain" \
-H "Authorization: bearer <Access Token>" \
-H "X-Streetcred-Subscription-Key: <Subscription Key>" \
-H "Content-Type: application/json-patch+json" \
-d "{ \"ownerName\": \"Fluffy's Wallet\"}"

API Reference

Parameters

You can specify the following optional parameters.

  • ownerName [string] - The name of the wallet. This should be a human readable alias that will be displayed as the name of wallet with new connections.

Response

Creating a wallet responds with a WalletContract object:

{
"walletId": "string",
"ownerName": "string"
}
  • walletId [string] - The GUID that represents the wallet internally

Accept an Invitation

POST /api/{walletId}/connections/invitation

Once your wallet has been created, you can use your wallet to accept connection invitations and begin receiving credentials.

To accept an invitation, simply input the base64 escaped invitation data and the wallet ID. This invitation data is formatted according to the Aries Connection Protocol.

curl -X POST "https://api.streetcred.id/custodian/v1/api/pYKD7HThQXtescDYFOHiV9bGRo7c7xJr/connections/invitation" \
-H "accept: text/plain" \
-H "Authorization: bearer <Access Token>" \
-H "X-Streetcred-Subscription-Key: <Subscription Key>" \
-H "Content-Type: multipart/form-data" \
-F "invitation=<Encoded Invitation>"

API Reference

Parameters

You can specify the following optional parameters.

  • walletId [string] - The id of the wallet. Can be found in the response body of the Create Wallet or List Wallets endpoints.
  • invitation [string] - The invitation data as a base64 encoded json string. Trinsic Studio or Credentials API can create invitations to test out making a connection.

Response

The response body will include a ConnectionContract:

{
"connectionId": "string",
"name": "string",
"imageUrl": "string",
"myDid": "string",
"theirDid": "string",
"myKey": "string",
"theirKey": "string",
"state": "Invited",
"invitation": "string",
"invitationUrl": "string",
"endpoint": {
"did": "string",
"verkey": "string",
"uri": "string"
},
"createdAtUtc": "2020-03-10T04:29:07.573Z"
}

List Credentials

GET /api/{walletId}/credentials

Any credentials that have been sent to the wallet can be listed with this endpoint. The credentialId and state of the credential can be discovered here.

curl -X GET "https://api.streetcred.id/custodian/v1/api/{walletId}/credentials" \
-H "accept: text/plain" \
-H "Authorization: bearer <Access Token>" \
-H "X-Streetcred-Subscription-Key: <Subscription Key>"

API Reference

Response

[
{
"credentialId": "6084a484-1f5c-4fbb-b43c-77d2b1e84ba2",
"state": "Offered",
"connectionId": "9bd4932a-168e-46fe-a569-21c3aec20aaf",
"definitionId": "AM4ebVB3zHjwRvJJaQCUzN:3:CL:83519:Default",
"schemaId": "AM4ebVB3zHjwRvJJaQCUzN:2:Example:1.0",
"values": {
"Name": "Johnny Appleseed",
"Apples Picked": "5,041"
}
}
]

Accept a Credential Offer

POST /api/{walletId}/credentials/{credentialId}

Any of the credentials in state "Offered" are ready to be accepted. Once a credential is accepted it will be issued directly to the wallet.

curl -X POST "https://api.streetcred.id/custodian/v1/api/{walletId}/credentials/{credentialId}" \
-H "accept: application/json" \
-H "Authorization: bearer <Access Token>" \
-H "X-Streetcred-Subscription-Key: <Subscription Key>"

API Reference

Parameters

You must specify the following parameters:

  • walletId [string] - The id of the wallet. Can be found in the response body of the Create Wallet or List Wallets endpoints.
  • credentialId [string] - The id of the credential that has been sent to the wallet. Can be found with the List Credentials endpoint.

List Verifications for Connection

GET /api/{walletId}/verifications/connection/{connectionId}

Whenever an organization has sent a verification request to a custodian wallet, there is a three step process for the custody wallet to respond to the verification request. The first step is to list the verifications that have been sent to the wallet. The connectionId should be included in this request. This can be found in the List Connections endpoint.

API Reference

Response

[
{
"connectionId": "string",
"verificationId": "string",
"state": "Requested",
"createdAtUtc": "2020-03-10T22:59:41.009Z",
"updatedAtUtc": "2020-03-10T22:59:41.009Z",
"isValid": true,
"verifiedAtUtc": "2020-03-10T22:59:41.009Z",
"proof": {
"additionalProp1": {
"name": "string",
"value": "string",
"revealed": true,
"selfAttested": true,
"conditional": true
},
"additionalProp2": {
"name": "string",
"value": "string",
"revealed": true,
"selfAttested": true,
"conditional": true
},
"additionalProp3": {
"name": "string",
"value": "string",
"revealed": true,
"selfAttested": true,
"conditional": true
}
}
}
]

Respond to a Verification Request Automatically

PUT /api/{walletId}/verifications/{verificationId}/autoSelect

The last step is to respond to a verification request with the correct credentials. Each verification includes a list of requested attributes and a list of restrictions for which credentials will be accepted.

To respond easily, an automatic selection endpoint will choose the first credential that matches the verification policies. If there are no credentials that match, the verification will be sent back with an empty response for that attribute.

curl -X PUT "https://api.azurewebsites.net/custodian/api/{WalletId}/verifications/{VerificationId}/autoSelect" \
-H "accept: application/json" \
-H "Authorization: bearer <Access Token>" \
-H "X-Streetcred-Subscription-Key: <Subscription Key>"

API Reference

Parameters

You must specify the following parameters:

  • walletId [string] - The id of the wallet. Can be found in the response body of the Create Wallet or List Wallets endpoints.
  • verificationId [string] - The id of the verification that has been sent to the wallet. Can be found with the List Verifications endpoint.

Get a List of Available Credentials

GET /api/{walletId}/verifications/{verificationId}/availableCredentials

If the selection process needs to be more specific, use this endpoint to discover the available credentials that fulfill the requirements of the verification request.

curl -X GET "https://api.streetcred.id/custodian/api/{walletId}/verifications/{verificationId}/availableCredentials" \
-H "accept: text/plain" \
-H "Authorization: bearer <access token>" \
-H "X-Streetcred-Subscription-Key: <Subscription Key>"

API Reference

Response

{
"attributes": [
{
"policyName": "string",
"attributeNames": [
"string"
],
"availableCredentials": [
{
"credentialId": "string",
"state": "Offered",
"connectionId": "string",
"definitionId": "string",
"schemaId": "string",
"values": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}
],
"restrictions": [
{
"schemaId": "string",
"schemaIssuerDid": "string",
"schemaName": "string",
"schemaVersion": "string",
"issuerDid": "string",
"credentialDefinitionId": "string"
}
]
}
],
"predicates": [
{
"policyName": "string",
"attributeNames": [
"string"
],
"availableCredentials": [
{
"credentialId": "string",
"state": "Offered",
"connectionId": "string",
"definitionId": "string",
"schemaId": "string",
"values": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}
],
"restrictions": [
{
"schemaId": "string",
"schemaIssuerDid": "string",
"schemaName": "string",
"schemaVersion": "string",
"issuerDid": "string",
"credentialDefinitionId": "string"
}
]
}
]
}

Respond to Verification Request with Specific Credentials

PUT /api/{walletId}/verifications/{verificationId}

Once the available credentials have been listed, use the response to select which credentials should be sent along with the verification response.

API Reference

Paramaters

You must specify the following parameters:

  • walletId
  • verificationId
  • body:
[
{
"policyName": "string", // Name of the policy used in the verification
"credentialId": "string", // The credential identifier to be used with this policy
"hidden": true // Specifies if this value will be hidden. If hidden, the value is not disclosed, only a cryptographic proof of ownership.
}
]