Skip to main content
Associate a CID with a payment instruction for x402 monetization

Usage

import { PinataSDK } from "pinata";

const pinata = new PinataSDK({
  pinataJwt: process.env.PINATA_JWT!,
  pinataGateway: "example-gateway.mypinata.cloud",
});

const association = await pinata.x402.addCid(
  "01234567-89ab-cdef-0123-456789abcdef",
  "bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4"
);

Returns

type CidAssociationResponse = {
  data: CidAssociation;
};

type CidAssociation = {
  payment_instruction_id: string;
  cid: string;
  created_at: string;
};

Parameters

paymentInstructionId (required)

  • Type: string
The unique identifier of the payment instruction to associate the CID with
const association = await pinata.x402.addCid(
  "01234567-89ab-cdef-0123-456789abcdef",
  "bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4"
);

cid (required)

  • Type: string
The IPFS CID to associate with the payment instruction. Once associated, accessing this content will require payment according to the payment instruction.
const association = await pinata.x402.addCid(
  "01234567-89ab-cdef-0123-456789abcdef",
  "bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4"
);