{
  "openapi": "3.1.1",
  "info": {
    "title": "Sharecrate Safe File Names API",
    "version": "1.0.0",
    "summary": "Make file names safe for Windows, macOS, Linux and ZIP files, and fix duplicates.",
    "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://sharecratesafefilenames.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Make file names safe for Windows, macOS, Linux and ZIP files, and fix duplicates.",
        "description": "Paste file names, one per line, and get names that work everywhere: no characters Windows refuses, no reserved device names like CON or NUL, no hidden text-direction characters that disguise an extension, Unicode in the composed form (NFC), no trailing dots or spaces and at most 200 bytes with the extension kept. Names that become equal are numbered the way Sharecrate does it, and program extensions are flagged.\n\nMethodology:\n- Each name is converted to Unicode NFC, then control characters, bidirectional controls (U+202A–U+202E, U+2066–U+2069, U+200E/U+200F, U+061C) and zero-width characters are removed.\n- The characters / \\ : * ? \" \u003c \u003e | become _, repeated spaces collapse to one, and dots or spaces at the start and end are removed (Windows drops trailing ones; leading dots hide files on macOS and Linux).\n- Windows device names (CON, PRN, AUX, NUL, COM0–9, LPT0–9 and their superscript forms) get an underscore, also when they have an extension. Names longer than the byte limit are shortened before the extension.\n- Duplicate detection compares names case-insensitively, like Windows, macOS and the Sharecrate drive; later names get “ (2)”, “ (3)” … before the extension.\n- Program and macro extensions (.exe, .js, .docm …) and double extensions like .pdf.exe are flagged, not changed.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "sharecrate_safe_filenames",
        "x-owner-app": "sharecrate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SharecrateSafeFilenamesInput"
              },
              "examples": {
                "example1": {
                  "summary": "Messy names from several systems",
                  "value": {
                    "names": "Quarterly report: final?.pdf\nCON.txt\nnotes .\n../../etc/passwd\nInvoice‮fdp.exe\nRésumé.docx\nRésumé.docx\nphoto\u003c1\u003e.jpg\n   spaced    out   name.png\n.hidden-config",
                    "dedupe": true
                  }
                },
                "example2": {
                  "summary": "Camera exports that clash after cleaning",
                  "value": {
                    "names": "IMG:0001.JPG\nIMG?0001.JPG\nimg_0001.jpg\nholiday / beach.png",
                    "dedupe": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SharecrateSafeFilenamesResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "SharecrateSafeFilenamesInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "names": {
            "title": "File names (one per line)",
            "description": "Paths are cut to their last part. At most 2000 names.",
            "type": "string",
            "maxLength": 200000,
            "default": "Quarterly report: final?.pdf\nCON.txt\nnotes .\n../../etc/passwd\nInvoice‮fdp.exe\nRésumé.docx\nRésumé.docx\nphoto\u003c1\u003e.jpg\n   spaced    out   name.png\n.hidden-config"
          },
          "dedupe": {
            "title": "Number names that become equal (photo (2).jpg)",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "SharecrateSafeFilenamesResult": {
        "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": [
              "rows",
              "total",
              "changed",
              "duplicatesResolved",
              "risky",
              "list"
            ],
            "properties": {
              "rows": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "line",
                    "original",
                    "safe",
                    "changed",
                    "renamedForDuplicate",
                    "reasons",
                    "warnings"
                  ],
                  "properties": {
                    "line": {
                      "type": "integer"
                    },
                    "original": {
                      "type": "string"
                    },
                    "safe": {
                      "type": "string"
                    },
                    "changed": {
                      "type": "boolean"
                    },
                    "renamedForDuplicate": {
                      "type": "boolean"
                    },
                    "reasons": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "total": {
                "type": "integer"
              },
              "changed": {
                "type": "integer"
              },
              "duplicatesResolved": {
                "type": "integer"
              },
              "risky": {
                "type": "integer"
              },
              "list": {
                "type": "string"
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}