{
  "openapi": "3.1.1",
  "info": {
    "title": "Transmute.Server | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://transmute.online/"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Transmute.Server"
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/cli/manifest": {
      "get": {
        "tags": [
          "Cli"
        ],
        "operationId": "GetCliManifest",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/cli/download/{rid}": {
      "get": {
        "tags": [
          "Cli"
        ],
        "operationId": "DownloadCliBinary",
        "parameters": [
          {
            "name": "rid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings/operations": {
      "get": {
        "tags": [
          "Mappings"
        ],
        "operationId": "GetOperationCatalog",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings/{id}": {
      "get": {
        "tags": [
          "Mappings"
        ],
        "operationId": "GetMapping",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "Mappings"
        ],
        "operationId": "UpdateMapping",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings": {
      "post": {
        "tags": [
          "Mappings"
        ],
        "operationId": "CreateMapping",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings/{id}/validate": {
      "post": {
        "tags": [
          "Mappings"
        ],
        "operationId": "ValidateMapping",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings/{id}/preview": {
      "post": {
        "tags": [
          "Mappings"
        ],
        "operationId": "PreviewMapping",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings/{id}/run": {
      "post": {
        "tags": [
          "Mappings"
        ],
        "operationId": "RunMapping",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "$ref": "#/components/schemas/IFormFile"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings/{id}/ai/generate": {
      "post": {
        "tags": [
          "Mappings"
        ],
        "operationId": "AiGenerateMapping",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiGenerateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/mappings/{id}/ai/destination-schema": {
      "post": {
        "tags": [
          "Mappings"
        ],
        "operationId": "AiGenerateDestinationSchema",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiDestinationSchemaRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/ai/providers": {
      "get": {
        "tags": [
          "AI"
        ],
        "operationId": "GetAiProviders",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/ai/secrets/ephemeral": {
      "post": {
        "tags": [
          "AI"
        ],
        "operationId": "CreateAiEphemeralSecret",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiEphemeralSecretRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiEphemeralSecretResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDto"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sessions": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "operationId": "ListSessions",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/sessions/{id}": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "operationId": "GetSession",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/sessions/{id}/paused-rows": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "operationId": "ListPausedRows",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/sessions/{id}/paused-rows/{rowIndex}/resume": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "operationId": "ResumePausedRow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rowIndex",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResumeRowRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/sessions/{id}/links": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "operationId": "CreateSessionLink",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionLinkRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AiCredentialMode": {
        "enum": [
          "None",
          "Ephemeral",
          "StoredUser",
          "Managed"
        ],
        "default": "None"
      },
      "AiDestinationSchemaRequest": {
        "required": [
          "sourceSchema"
        ],
        "type": "object",
        "properties": {
          "sourceSchema": {
            "$ref": "#/components/schemas/JsonElement"
          },
          "sourceSamples": {
            "type": [
              "null",
              "array"
            ]
          },
          "instructions": {
            "type": [
              "null",
              "string"
            ]
          },
          "targetFormat": {
            "type": "string",
            "default": "json"
          },
          "privacyPolicy": {
            "$ref": "#/components/schemas/PrivacyPolicy"
          },
          "providerOverride": {
            "type": [
              "null",
              "string"
            ]
          },
          "modelOverride": {
            "type": [
              "null",
              "string"
            ]
          },
          "baseUrlOverride": {
            "type": [
              "null",
              "string"
            ]
          },
          "credentialMode": {
            "$ref": "#/components/schemas/AiCredentialMode"
          },
          "ephemeralSecretHandle": {
            "type": [
              "null",
              "string"
            ]
          }
        },
        "description": "Request to propose a destination schema and representative sample from a source shape and\r\nplain-language goal. Source row values are filtered by the server-side privacy policy."
      },
      "AiEphemeralSecretRequest": {
        "required": [
          "provider",
          "apiKey"
        ],
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "apiKey": {
            "type": "string"
          },
          "ttlSeconds": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32",
            "default": 900
          }
        }
      },
      "AiEphemeralSecretResponse": {
        "required": [
          "handle",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "handle": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AiGenerateRequest": {
        "required": [
          "destinationSchema"
        ],
        "type": "object",
        "properties": {
          "destinationSchema": {
            "$ref": "#/components/schemas/JsonElement"
          },
          "sourceSchema": { },
          "sourceSamples": {
            "type": [
              "null",
              "array"
            ]
          },
          "targetSamples": {
            "type": [
              "null",
              "array"
            ]
          },
          "prose": {
            "type": [
              "null",
              "string"
            ]
          },
          "currentMapping": {
            "type": [
              "null",
              "string"
            ]
          },
          "privacyPolicy": {
            "$ref": "#/components/schemas/PrivacyPolicy"
          },
          "providerOverride": {
            "type": [
              "null",
              "string"
            ]
          },
          "modelOverride": {
            "type": [
              "null",
              "string"
            ]
          },
          "baseUrlOverride": {
            "type": [
              "null",
              "string"
            ]
          },
          "credentialMode": {
            "$ref": "#/components/schemas/AiCredentialMode"
          },
          "ephemeralSecretHandle": {
            "type": [
              "null",
              "string"
            ]
          }
        },
        "description": "Request to `POST /mappings/{id}/ai/generate`. Response is streamed as SSE; each event\r\ncarries either partial markdown, a validation pass result, or a completion sentinel.\r\nSamples are included only if tenant `PrivacyPolicy` permits — server enforces this."
      },
      "ColumnRuleRequest": {
        "required": [
          "field",
          "expression",
          "scope"
        ],
        "type": "object",
        "properties": {
          "field": {
            "type": "string"
          },
          "expression": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          }
        },
        "description": "A per-column correction applied alongside a row resolution (Handover Part C.5). When\r\nstring ColumnRuleRequest.Scope is `subsequent`, the string ColumnRuleRequest.Expression (a TXX expression with\r\n`value` bound) is applied to the named field for the current and all later rows in the\r\nstreaming run. When `row`, it only affects the resolved row."
      },
      "CreateMappingRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "markdownSource": {
            "type": [
              "null",
              "string"
            ]
          },
          "astJson": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "IFormFile": {
        "type": "string",
        "format": "binary"
      },
      "JsonElement": { },
      "PreviewRequest": {
        "required": [
          "sampleRows"
        ],
        "type": "object",
        "properties": {
          "sampleRows": {
            "type": "array"
          },
          "maxRows": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32",
            "default": 50
          }
        },
        "description": "Request/response for `POST /mappings/{id}/preview` — runs the mapping against N sample\r\nrows and returns resolved outputs alongside any errors. Used by TXM's inline preview pane."
      },
      "PrivacyPolicy": {
        "enum": [
          "Full",
          "SchemaOnly",
          "SchemaAndSyntheticSamples"
        ],
        "default": "SchemaOnly"
      },
      "ProblemDto": {
        "required": [
          "type",
          "title",
          "status"
        ],
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          },
          "code": {
            "type": [
              "null",
              "string"
            ]
          }
        },
        "description": "RFC 7807 problem+json shape used uniformly across the public surface."
      },
      "ResumeRowRequest": {
        "type": "object",
        "properties": {
          "correctedOutput": { },
          "columnRule": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ColumnRuleRequest"
              }
            ]
          },
          "skip": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "SessionLinkRequest": {
        "type": "object",
        "properties": {
          "rowIndex": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "ttlSeconds": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32",
            "default": 900
          }
        }
      },
      "UpdateMappingRequest": {
        "type": "object",
        "properties": {
          "markdownSource": {
            "type": [
              "null",
              "string"
            ]
          },
          "astJson": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Transmute.Server"
    },
    {
      "name": "Cli"
    },
    {
      "name": "Mappings"
    },
    {
      "name": "AI"
    },
    {
      "name": "Sessions"
    }
  ]
}