Updating Passes

Updating a Barcode Message

You are able to specify an optional message on the pass barcode, which can be used to embed information into the pass.

This feature can be useful for encoding IDs and other important values from your internal system.

To protect the contents of your message, we AES-256 bit encrypt
the value, and the decrypted value will only be returned when a pass is successfully scanned by the GET /v0/scan endpoint.

Learn more about using pass barcodes here.

const passId = "f664196b-035a-454d-90c4-ab0adc107981";
const messageToEncrypt = "ITEM-1207";

const payload = {
  barcode: {
    message: messageToEncrypt,
  },
};

const response = await fetch(
  `https://api.ethpass.xyz/api/v0/passes/${passId}`,
  {
    method: "PATCH",
    body: JSON.stringify(payload),
    headers: new Headers({
      "content-type": "application/json",
      "X-API-KEY": "YOUR_SECRET_API_KEY",
    }),
  }
);

Updating Pass Details

You are also able to update properties of the pass, per the spec of the Google
or Apple Pass.

Updating Apple Pass Properties

To update properties on an Apple Pass, you can use PATCH /v0/passes/{passId} like below:

const payload = {
  barcode: {
    message: "Message update",
  },
  pass: {
    logoText: "PATCH",
    description: "Patch description1",
    labelColor: "rgb(255,0,0)",
    backgroundColor: "rgb(0,0,0)",
    foregroundColor: "rgb(255,255,255)",
    headerFields: [
      {
        key: "header1",
        label: "CLAIM CODE",
        value: "ABJD81",
        textAlignment: "PKTextAlignmentNatural",
        changeMessage: "NEW CLAIM CODE %@",
      },
    ],
    backFields: [
      {
        key: "opensea",
        label: "View on OpenSea",
        value:
          "https://opensea.io/assets/0x25ed58c027921e14d86380ea2646e3a1b5c55a8b/5943",
        textAlignment: "PKTextAlignmentNatural",
        changeMessage: "Check back of pass %@.",
      },
      {
        key: "notification",
        label: "Latest Notification",
        value: "New message",
        textAlignment: "PKTextAlignmentNatural",
        changeMessage: "%@",
      },
    ],
    primaryFields: [
      {
        key: "primary1",
        label: "Token #",
        value: 5945,
        textAlignment: "PKTextAlignmentNatural",
      },
      {
        key: "primary2",
        label: "New Fields",
        value: "Hello",
        textAlignment: "PKTextAlignmentNatural",
      },
    ],
    secondaryFields: [
      {
        key: "secondary1",
        label: "Contract Address",
        value: "0x25ed...5a8e",
        textAlignment: "PKTextAlignmentLeft",
      },
      {
        key: "secondary2",
        label: "Contract Address",
        value: "0x25ed...5a81",
        textAlignment: "PKTextAlignmentLeft",
      },
      {
        key: "secondary3",
        label: "Contract Address1",
        value: "0x25ed...5a81",
        textAlignment: "PKTextAlignmentLeft",
      },
    ],
  },
};

const response = await fetch(`https://api.ethpass.xyz/api/v0/passes/${data}`, {
  method: "PATCH",
  body: JSON.stringify(payload),
  headers: new Headers({
    "content-type": "application/json",
    "X-API-KEY": "YOUR_SECRET_API_KEY",
  }),
});

Updating Google Pass Properties

To update properties on a Google Pass, you can use PATCH /v0/passes/{passId} like below:

const payload = {
  barcode: {
    message: "Message update",
  },
  pass: {
    messages: [
      {
        header: "View on Etherscan1",
        body: "https://etherscan.io/token/0x25ed58c027921e14d86380ea2646e3a1b5c55a8b?a=5946",
      },
      {
        header: "View on OpenSea1",
        body: "https://opensea.io/assets/0x25ed58c027921e14d86380ea2646e3a1b5c55a8b/59461",
      },
    ],
  },
};

const response = await fetch(`https://api.ethpass.xyz/api/v0/passes/${data}`, {
  method: "PATCH",
  body: JSON.stringify(payload),
  headers: new Headers({
    "content-type": "application/json",
    "X-API-KEY": "YOUR_SECRET_API_KEY",
  }),
});