Linking Assets

Linking assets

Any asset can be linked to each other to create a link between two assets. This allows for flexible connections between any asset. A few usage examples:

  • Link amendments of a documentation to the original asset.
  • Link multiple documents together as a collection.
  • Link “signatures” to a document for verification.

Important note: Only the owner of the asset defined in the URL can use it to link with other assets. You can’t arbitrarily choose any other asset and link it with your own or other assets.

POST /assets/{assetId}/links

{
  "targetAssetIds": ["string"]
}
  • linkedAssetIds: The assets that should be linked to the parent asset defined in the URL.

Code example

export async function linkAssets(
  apiKey: string,
  token: string,
  assetId: string,
  payload: AssetLink
): Promise<IResponse<AssetStatusResponse>> {
  const result = await axios.post<IResponse<AssetStatusResponse>>(`${process.env.NOTARDEC_URL}/assets/${assetId}/links`, payload, {
    headers: {
      'X-API-KEY': apiKey,
      Authorization: `Bearer ${token}`,
    },
  });
  return result.data;
}

Here, the first parameter we pass is the Notardec Key, the second is the token (optional parameter, the record can be created using the TEOS key), the third is the asset id, the fourth is request body. The request body and the response body will have the following form:

Request
{
  "targetAssetIds": ["string"]
}
Response
{
  value: {
    id: string;
    state: AssetState;
  } | null;
  meta?: MetaResponse;
  error?: ErrorResponse;
}

AssetState is enum list:

export enum AssetState {
  RECEIVED = 'Received',
  SUBMITTED = 'Submitted',
  COMMITTED = 'Committed',
  CONFIRMED = 'Confirmed',
  TX_SIGNATURE_SUBMITTED = 'TxSignatureSubmitted',
  REVOKED_BY_TX_SERVER = 'RevokedByTxServer',
  REVOKED_BY_USER = 'RevokedByUser',
  REVOKED_BY_BLOCKCHAIN = 'RevokedByBlockchain',
}

To see all the links for the asset, a request to GET /assets/{assetID}/links can be sent. The following ouput can be received:

{
  "value": {
    "from": ["string"],
    "to": ["string"]
  }
}
  • from: These are the assets that are the parent of the assets. This would mean string -> assetID
  • to: These are assets that are the child of the asset. This would mean assetID -> string

Code example

export async function getAssetLinks(apiKey: string, token: string, assetId: string): Promise<IResponse<AssetLinks>> {
  const result = await axios.get<IResponse<AssetLinks>>(`${process.env.NOTARDEC_URL}/assets/${assetId}/links`, {
    headers: {
      'X-API-KEY': apiKey,
      Authorization: `Bearer ${token}`,
    },
  });
  return result.data;
}

Here, the first parameter we pass is the Notardec Key, the second is the token (optional parameter, the record can be created using the TEOS key), the third is the asset id. The response body will have the following form:

{
    value: {
        from: string[];
        to: string[];
    } | null;
    meta?: MetaResponse;
    error?: ErrorResponse;
}

Links are not permanent, they can at any time be revoked if so desired. This can be useful if for example a signature should be revoked for any reason or a document amendment was faulty.

PATCH /assets/{assetId}/links

{
  "targetAssetIds": ["string"]
}