Cards
The CardsResource class manages Cards—the modular content blocks within a Digital Product Passport (DPP). These cards house specific characteristics, metadata, or provenance information that define the product's journey and specifications.
Methods
list
Retrieves all cards associated with a specific Digital Product Passport.
Signature
async list(dppId: string, options?: RequestOptions): Promise<Cards[]>
Parameters
| Parameter | Type | Description |
|---|---|---|
| dppId | string | The unique identifier of the target DPP. |
| options | RequestOptions | (Optional) Custom request configuration. |
get
Fetches the full details of a single card within a DPP.
Signature
async get(dppId: string, cardId: string, options?: RequestOptions): Promise<Cards>
Parameters
| Parameter | Type | Description |
|---|---|---|
| dppId | string | The unique identifier of the parent DPP. |
| cardId | string | The unique identifier of the card to retrieve. |
create
Creates a new card and attaches it to a Digital Product Passport. The SDK automatically handles injecting the required userId from the SDK configuration.
Signature
async create(dppId: string, data: CreateCard, options?: RequestOptions): Promise<Cards>
Example
const newCard = await sdk.cards.create("dpp_123", {
name: "Sustainability Data",
description: "Eco-impact metrics",
characteristics: [
{ name: "Carbon Footprint", description: "2kg CO2e" }
]
});
Parameters
| Parameter | Type | Description |
|---|---|---|
| dppId | string | The unique identifier of the DPP where the card will be added. |
| data | CreateCard | The card payload, including name, description, and characteristics. |
update
Updates an existing card's metadata or modifies its characteristics.
Signature
async update(dppId: string, cardId: string, data: UpdateCard, options?: RequestOptions): Promise<Cards>
Parameters
| Parameter | Type | Description |
|---|---|---|
| dppId | string | The parent DPP identifier. |
| cardId | string | The unique identifier of the card to update. |
| data | UpdateCard | The updated fields (e.g., name, description, characteristics). |
delete
Removes a card entirely from a Digital Product Passport.
Signature
async delete(dppId: string, cardId: string, options?: RequestOptions): Promise<void>
[!WARNING] This action is destructive. Deleting a card will also remove all characteristics nested within it.
deleteCharacteristic
Removes a specific characteristic from a card without deleting the card itself.
Signature
async deleteCharacteristic(characteristicId: string, options?: RequestOptions): Promise<void>
Parameters
| Parameter | Type | Description |
|---|---|---|
| characteristicId | string | The unique identifier of the characteristic to remove. |
Errors & Troubleshooting
All methods in this resource may throw an SDKError (HTTP 500) if:
- The
dppIdorcardIdprovided does not exist. - The authenticated user does not have permission to modify the DPP.
- Required fields in the
createorupdatepayload are missing.
try {
await sdk.cards.delete("dpp_123", "card_456");
} catch (error) {
if (error instanceof SDKError) {
console.error(`Operation failed: ${error.message}`);
}
}