{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usps/json-schema/usps-indicia-imb-response-schema.json",
  "title": "Indicia IMB Response",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/usps-domestic-labels-openapi.yml#/components/schemas/IndiciaImbResponse",
  "type": "object",
  "properties": {
    "indiciaMetadata": {
      "type": "object",
      "description": "Metadata for indicia",
      "properties": {
        "imb": {
          "type": "string",
          "description": "Human-readable form of the intelligent mail barcode (IMB) value."
        },
        "constructCode": {
          "type": "string",
          "description": "The barcode construct code associated with the tracking number.\n\nNotes:\n  - This field will be absent from the response if the request does not include extra services.\n"
        },
        "trackingNumber": {
          "type": "string",
          "description": "Human-readable form of the intelligent mail package barcode (IMPB) value.\n\nNotes:\n  - This field will be absent from the response if the request does not include extra services.\n"
        },
        "SKU": {
          "type": "string",
          "description": "Pricing SKU"
        },
        "totalPrice": {
          "type": "number",
          "description": "Total price of the indicia, including postage and any fees.",
          "format": "float"
        },
        "postage": {
          "type": "number",
          "description": "Amount of postage required, does not include insurance or other extra service fees."
        },
        "fees": {
          "type": "array",
          "description": "Fees associated to the mailpiece.",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "Name of the fee."
              },
              "SKU": {
                "type": "string",
                "description": "Pricing SKU for the fee."
              },
              "price": {
                "type": "number",
                "description": "The price for the fee.",
                "format": "float"
              }
            },
            "additionalProperties": false
          }
        },
        "weight": {
          "type": "number",
          "description": "The mailpiece weight, in ounces."
        },
        "extraServices": {
          "$ref": "#/$defs/ExtraServiceResponse"
        },
        "serviceTypeCode": {
          "type": "string",
          "description": "The Service Type Code associated with the mailpiece. A list of Service Type Codes can be found at: [https://postalpro.usps.com/IMPB_Service_Type_Codes](https://postalpro.usps.com/IMPB_Service_Type_Codes)\n"
        },
        "bannerText": {
          "type": "string",
          "description": "Banner text printed on the label."
        },
        "mailClass": {
          "enum": [
            "FIRST-CLASS"
          ],
          "description": "The mail class of the indicia."
        },
        "toAddress": {
          "description": "The `toAddress` from the request that will be printed on the letter, flat, or card.",
          "allOf": [
            {
              "$ref": "#/$defs/IndiciaImbAddress"
            }
          ]
        },
        "returnAddress": {
          "description": "The `returnAddress` from the request that will be printed on the letter, flat, or card.",
          "allOf": [
            {
              "$ref": "#/$defs/IndiciaImbAddress"
            }
          ]
        },
        "indiciaIMI": {
          "$ref": "#/$defs/IndiciaIMI"
        },
        "warnings": {
          "$ref": "#/$defs/Warnings"
        }
      }
    },
    "indiciaImage": {
      "type": "string",
      "description": "Contains the Base64-encoded file contents of the indicia image. Provided only when `imageInfo.labelType` is not `IMI_DATA_ONLY`.\n",
      "format": "byte"
    },
    "receiptImage": {
      "type": "string",
      "description": "Contains the Base64-encoded file contents of the indicia receipt image. Provided only when `imageInfo.receiptOption` is `SEPARATE_PAGE`.\n",
      "format": "byte"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "Address": {
      "title": "Address",
      "type": "object",
      "properties": {
        "streetAddress": {
          "maxLength": 50,
          "minLength": 1,
          "type": "string",
          "description": "The number of a building along with the name of the road or street on which it is located."
        },
        "streetAddressAbbreviation": {
          "maxLength": 50,
          "minLength": 0,
          "type": "string",
          "description": "This is the abbreviation of street address line for the address.",
          "readOnly": true
        },
        "secondaryAddress": {
          "maxLength": 50,
          "type": "string",
          "description": "The secondary unit designator, such as apartment(APT) or suite(STE) number, defining the exact location of the address within a building.  For more information please see [Postal Explorer](https://pe.usps.com/text/pub28/28c2_003.htm)."
        },
        "cityAbbreviation": {
          "type": "string",
          "description": "This is the abbreviation of city name for the address.",
          "readOnly": true
        }
      },
      "additionalProperties": true,
      "description": "Address fields standard to all locations."
    },
    "Addressee": {
      "title": "Addressee",
      "type": "object",
      "properties": {
        "firstName": {
          "maxLength": 50,
          "minLength": 1,
          "type": "string",
          "description": "First Name corresponding to the address."
        },
        "lastName": {
          "maxLength": 50,
          "minLength": 1,
          "type": "string",
          "description": "Last Name corresponding to the address."
        },
        "firm": {
          "maxLength": 50,
          "minLength": 0,
          "type": "string",
          "description": "Firm/business name corresponding to the address."
        }
      },
      "additionalProperties": true,
      "description": "Fields used to identity the entity receiving a mail piece or package"
    },
    "DomesticAddress": {
      "title": "Domestic Address",
      "additionalProperties": true,
      "description": "Address fields for US locations",
      "allOf": [
        {
          "$ref": "#/$defs/Address"
        },
        {
          "type": "object",
          "properties": {
            "city": {
              "maxLength": 28,
              "minLength": 1,
              "type": "string",
              "description": "This is the city name of the address."
            },
            "state": {
              "$ref": "#/$defs/State"
            },
            "ZIPCode": {
              "pattern": "^\\d{5}$",
              "type": "string",
              "description": "This is the 5-digit ZIP code."
            },
            "ZIPPlus4": {
              "pattern": "^\\d{4}$",
              "type": [
                "string",
                "null"
              ],
              "description": "This is the 4-digit component of the ZIP+4 code. Using the correct Zip+4 reduces the number of times your mail is handled and can decrease the chance of a misdelivery or error."
            },
            "urbanization": {
              "maxLength": 96,
              "type": "string",
              "description": "An area, sector, or residential development within a geographic area (typically used for addresses in Puerto Rico)."
            }
          },
          "additionalProperties": true
        }
      ]
    },
    "ExtraServiceResponse": {
      "title": "Extra Service Response",
      "type": "array",
      "minItems": 0,
      "description": "Extra services requested on the mailpiece.",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the extra service."
          },
          "SKU": {
            "type": "string",
            "description": "SKU of the extra service."
          },
          "price": {
            "type": "number",
            "description": "The price for the extra service.",
            "format": "float"
          },
          "warnings": {
            "type": "array",
            "description": "Warnings and additional details around the Extra Services.",
            "minItems": 0,
            "items": {
              "type": "object",
              "properties": {
                "warningCode": {
                  "type": "string",
                  "description": "Code corresponding to the warning"
                },
                "warningDescription": {
                  "type": "string",
                  "description": "Warning or additional information regarding the Extra Service."
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    },
    "IndiciaIMI": {
      "title": "Indicia IMI",
      "description": "Base64 encoded string of the binary data used to create the Intelligent Mail Indicia (IMI) Data Matrix.",
      "type": "string",
      "format": "byte"
    },
    "IndiciaImbAddress": {
      "title": "Indicia IMB Domestic Label Address",
      "required": [
        "ZIPCode",
        "city",
        "state",
        "streetAddress"
      ],
      "type": "object",
      "additionalProperties": true,
      "description": "The address where the letter, flat, or card is being mailed to. Address elements streetAddress, city, state, ZIPCode are required.  First and Last Name or Firm are also required.",
      "allOf": [
        {
          "$ref": "#/$defs/DomesticAddress"
        },
        {
          "$ref": "#/$defs/Addressee"
        },
        {
          "type": "object",
          "properties": {
            "ignoreBadAddress": {
              "writeOnly": true,
              "type": "boolean",
              "description": "Allows Non-Validated Street Address. Enter `true` to bypass street address validation failures/errors or `false` if only validated addresses should be allowed.\n\nNote: Integrators are recommended to always use `false` to ensure no delivery issues. \n\nIn the event USPS cannot validate the street address, this tag will \"bypass\" address validation error when `true` is indicated to allow IMB indicia creation which could impact delivery.\n"
            }
          },
          "additionalProperties": true
        }
      ]
    },
    "State": {
      "maxLength": 2,
      "minLength": 2,
      "pattern": "^(AA|AE|AL|AK|AP|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MP|MT|NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY)$",
      "type": "string",
      "description": "This is the two-character state code of the address."
    },
    "Warnings": {
      "title": "Warnings",
      "type": "array",
      "description": "Warnings and additional details around the Label.",
      "minItems": 0,
      "items": {
        "type": "object",
        "properties": {
          "warningCode": {
            "type": "string",
            "description": "Code corresponding to the warning"
          },
          "warningDescription": {
            "type": "string",
            "description": "Warning or additional information regarding the Label."
          }
        },
        "additionalProperties": false
      }
    }
  }
}