Usage Examples
This page provides common usage examples for the LearnCloud Storage API, so you can quickly see how to store, retrieve, and manage verifiable data objects like credentials, presentations, and metadata.
Each example is standalone and self-explanatory. Scroll, copy, and paste what you need.
โ All examples assume:
You have a valid LearnCloud JWT (via auth or delegation)
Youโre storing data on behalf of a user identified by a DID
Youโre using the endpoint:
https://cloud.learncard.com/api
๐ Authentication
All requests require:
Authorization: Bearer <your-JWT>
The JWT must resolve to a DID matching the stored object owner, unless delegated.
Storage
๐ค Store a Credential or Presentation
Endpoint: POST https://cloud.learncard.com/storage/store
Description: Stores a VC, VP, or JWE, and returns a lc:cloud:cloud.learncard.com/trpc:credential:id
URI for later access.
Request
Response
๐ฅ Resolve a Stored Item by URI
Endpoint: GET https://cloud.learncard.com/storage/resolve/{uri}
Description: Fetches an encrypted, stored credential or presentation from its URI.
Request
Response
Returns the encrypted JWE for the stored credential or presentation.
๐ฆ Batch Resolve Stored Items
Endpoint: POST https://cloud.learncard.com/storage/resolve/batch
Description: Resolves multiple credential URIs in a single call.
Request
Response
โ ๏ธ If a URI is invalid or not found,
null
is returned for that entry.
โ
Quick Tips
Store VC/VP/JWE
/storage/store
POST
URI of stored item
Resolve 1 item
/storage/resolve/{uri}
GET
Encrypted JWE
Resolve many
/storage/resolve/batch
POST
Array of JWE/null results
Always encrypt before sending to the API
Use returned URIs as persistent identifiers
Batch resolve to reduce network overhead
Indexing
๐งพ How the Index Stores Credential Metadata
The LearnCard index is used to securely store metadata about credentials youโve issued or received. It doesn't store the full credential itselfโinstead, it stores a reference (uri
) to the credential (which is stored separately in LearnCloud Storage) along with optional metadata fields.
Each entry is encrypted as a JWE object and stored as a CredentialRecord
.
Unencrypted Format (Before Encryption)
Encrypted Format (Submitted to /index/add
, etc.)
/index/add
, etc.)This encrypted object becomes the payload for the index API (e.g.,
/index/add
,/index/get
). LearnCard decrypts it on read and uses it to support search, sync, and filtered queriesโwithout exposing sensitive data.
๐ Get Credential Records Index
Endpoint: POST https://cloud.learncard.com/index/get
Description: Query your CredentialRecords index with pagination, sorting, and optional filtering.
Request
Response
Returns a paginated list of credential records or a JWE if encryption is enabled.
๐ข Count Credential Records
Endpoint: POST https://cloud.learncard.com/index/count
Description: Count the number of credential records matching a query.
Request
Response
or
Returns either a plain number or encrypted JWE containing the count.
โ Add a Credential Record
Endpoint: POST https://cloud.learncard.com/index/add
Description: Add a new credential record to the user's index.
Request
Response
Returns true
if the record was successfully added.
โโ Add Many Credential Records
Endpoint: POST https://cloud.learncard.com/index/addMany
Description: Add multiple credential records in one request.
Request
Response
Returns true
if all records were successfully added.
โ๏ธ Update a Credential Record
Endpoint: PATCH https://cloud.learncard.com/index/{id}
Description: Update a credential record by its internal ID.
Request
Response
Returns true
if the record was successfully updated.
โ Delete a Credential Record
Endpoint: DELETE https://cloud.learncard.com/index/{id}
Description: Delete a specific credential record by ID.
Request
Response
Returns true
if the record was deleted.
๐งน Delete All Credential Records
Endpoint: DELETE https://cloud.learncard.com/index
Description: Delete all credential records for the authenticated user.
Request
Response
Returns true
if all records were removed.
xAPI Statements
๐ค Send an xAPI Statement
Endpoint: POST https://cloud.learncard.com/xapi/statements
Description: Send a structured learning event to LearnCloud, using the "Actor - Verb - Object" format.
Request
Returns 200 OK
on success. No response body is returned unless there is an error.
โ
Best Practices
Use the same DID in
actor.name
andactor.account.name
Always set
X-VP
header with your JWTUse standard verbs like
attempted
,completed
,mastered
,demonstrated
Use real or resolvable URIs for
object.id
(or consistent mock URLs)Test with dummy statements before production
๐ Read xAPI Statements
Endpoint: GET https://cloud.learncard.com/xapi/statements
Description: Retrieve xAPI statements associated with the authenticated user's DID.
๐ Basic Query
Returns a list of xAPI statements for the user.
๐ Filtered Query Example
Filters results by verb and date range.
๐ Paginated Fetching
๐งช Security Notes
โ You can only query your own statements unless using delegated access.
โ A
401
means:Invalid or expired JWT
DID mismatch between JWT and
actor
Missing
X-VP
header
๐ค Delegated Access
To allow another party to query your statements:
Issue a delegate credential
Wrap it in a presentation
Sign it into a JWT
Use it in the
X-VP
header
๐งผ Voiding a Statement
You can void a previously sent statement by its ID.
โ ๏ธ You can only void statements you originally submitted.
๐ง Best Practices for Querying
Use
limit
,since
, andverb
to keep results efficientUse
activity
,ascending
, orformat=ids
for advanced querying
Last updated
Was this helpful?