{
  "openapi": "3.1.1",
  "info": {
    "title": "Barcode Generator (EAN-13, UPC-A, Code 128) API",
    "version": "1.0.0",
    "summary": "EAN-13, UPC-A and Code 128 barcodes with check digits, true-size PDF, SVG and PNG.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://printshopbarcode.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "EAN-13, UPC-A and Code 128 barcodes with check digits, true-size PDF, SVG and PNG.",
        "description": "Make an EAN-13, UPC-A or Code 128 barcode. EAN/UPC check digits are calculated (or verified), Code 128 switches between code sets A, B and C for the shortest symbol, and the result prints at GS1 sizes with quiet zones and a test square.\n\nMethodology:\n- EAN-13: the first digit selects the L/G parity pattern of the left half (GS1 table), the right half uses R codes; the check digit is the mod-10 sum with weights 3 and 1 from the right. UPC-A is encoded as EAN-13 with a leading 0.\n- Code 128: a dynamic programme over (position, active code set) picks start code, CODE A/B/C switches and SHIFT for the fewest symbol characters; check value = (start + Σ value × position) mod 103.\n- Sizes: EAN/UPC module 0.330 mm × magnification (80–200 %), bar height 22.85 mm × magnification, guard bars 5 modules longer; quiet zones 11/7 modules (EAN-13), 9/9 (UPC-A), 10/10 (Code 128).\n\nRetail EAN/UPC numbers must be licensed from GS1; making a barcode does not register a product number. Check print quality with a scanner before mass printing.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "printshop_barcode",
        "x-owner-app": "printshop",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrintshopBarcodeInput"
              },
              "examples": {
                "example1": {
                  "summary": "EAN-13 with the check digit added",
                  "value": {
                    "symbology": "ean13",
                    "data": "400638133393"
                  }
                },
                "example2": {
                  "summary": "UPC-A",
                  "value": {
                    "symbology": "upca",
                    "data": "03600029145"
                  }
                },
                "example3": {
                  "summary": "Code 128 for a parcel reference",
                  "value": {
                    "symbology": "code128",
                    "data": "PO-2027-000123",
                    "height": 15,
                    "layout": "sheet"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrintshopBarcodeResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "PrintshopBarcodeInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "symbology": {
            "title": "Barcode type",
            "type": "string",
            "enum": [
              "ean13",
              "upca",
              "code128"
            ],
            "default": "ean13"
          },
          "data": {
            "title": "Data",
            "description": "EAN-13: 12 digits (the check digit is added) or 13 digits (it is checked). UPC-A: 11 or 12 digits. Code 128: up to 80 ASCII characters.",
            "type": "string",
            "maxLength": 80,
            "default": "400638133393"
          },
          "magnification": {
            "title": "Size (magnification)",
            "description": "EAN/UPC: 1 = 0.33 mm modules (GS1 nominal); Code 128: 1 = 0.30 mm modules.",
            "type": "number",
            "minimum": 0.8,
            "maximum": 2,
            "default": 1
          },
          "height": {
            "title": "Bar height (mm)",
            "type": "number",
            "minimum": 5,
            "maximum": 100,
            "default": 22.85
          },
          "text": {
            "title": "Print the digits under the bars",
            "type": "boolean",
            "default": true
          },
          "layout": {
            "title": "Print layout",
            "type": "string",
            "enum": [
              "one",
              "sheet"
            ],
            "default": "one"
          },
          "caption": {
            "title": "Caption above the barcode",
            "type": "string",
            "maxLength": 200,
            "default": ""
          },
          "paper": {
            "title": "Paper size",
            "type": "string",
            "enum": [
              "a3",
              "a4",
              "a5",
              "a6",
              "b5",
              "letter",
              "legal",
              "tabloid",
              "halfletter"
            ],
            "default": "a4"
          }
        },
        "required": []
      },
      "PrintshopBarcodeResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "symbology",
              "text",
              "checkDigit",
              "modules",
              "xMm",
              "widthMm",
              "codeSets",
              "symbolValues",
              "pages",
              "pageWidthMm",
              "pageHeightMm",
              "warnings",
              "files",
              "openInApp"
            ],
            "properties": {
              "symbology": {
                "type": "string"
              },
              "text": {
                "type": "string"
              },
              "checkDigit": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "modules": {
                "type": "integer"
              },
              "xMm": {
                "type": "number"
              },
              "widthMm": {
                "type": "number"
              },
              "codeSets": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "symbolValues": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "integer"
                }
              },
              "pages": {
                "type": "integer"
              },
              "pageWidthMm": {
                "type": "number"
              },
              "pageHeightMm": {
                "type": "number"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "files": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "pdf",
                  "svg",
                  "png"
                ],
                "properties": {
                  "pdf": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  "svg": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  "png": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  }
                }
              },
              "openInApp": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}