{
  "openapi": "3.0.1",
  "info": {
    "title": "NeutronEdi.Api | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://api.neutronedi.com/"
    }
  ],
  "paths": {
    "/api/v1/read/x12": {
      "post": {
        "tags": [
          "EDI Operations"
        ],
        "summary": "Parse raw X12 EDI content into structured JSON or XML",
        "description": "Accepts raw X12 EDI text and returns parsed transaction sets. Use Accept: application/xml or ?format=xml for XML output. Errors are always returned as JSON.",
        "operationId": "ReadX12",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReadX12Request"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadX12Result"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ReadX12Result"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadX12Result"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Too Many Requests"
          }
        }
      }
    },
    "/api/v1/read/edifact": {
      "post": {
        "tags": [
          "EDI Operations"
        ],
        "summary": "Parse raw EDIFACT EDI content into structured JSON or XML",
        "description": "Accepts raw EDIFACT EDI text and returns parsed messages. Use Accept: application/xml or ?format=xml for XML output. Errors are always returned as JSON.",
        "operationId": "ReadEdifact",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReadEdifactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadEdifactResult"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ReadEdifactResult"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadEdifactResult"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Too Many Requests"
          }
        }
      }
    },
    "/api/v1/write/x12": {
      "post": {
        "tags": [
          "EDI Operations"
        ],
        "summary": "Generate raw X12 EDI output from JSON",
        "description": "Accepts an X12 interchange as JSON with ISA, Groups (containing GS and Transactions), and IEA. Version and transaction set ID are extracted automatically.",
        "operationId": "WriteX12",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WriteX12Request"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteX12Result"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteX12Result"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Too Many Requests"
          }
        }
      }
    },
    "/api/v1/write/edifact": {
      "post": {
        "tags": [
          "EDI Operations"
        ],
        "summary": "Generate raw EDIFACT EDI output from JSON",
        "description": "Accepts an EDIFACT interchange as JSON with UNB, Messages (containing UNH), and optional UNG. Version and message type are extracted automatically.",
        "operationId": "WriteEdifact",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WriteEdifactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteEdifactResult"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteEdifactResult"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Too Many Requests"
          }
        }
      }
    },
    "/api/v1/validate/x12": {
      "post": {
        "tags": [
          "EDI Operations"
        ],
        "summary": "Validate raw X12 EDI content against EDI specifications",
        "description": "Accepts raw X12 EDI text and returns a detailed validation report including errors and warnings.",
        "operationId": "ValidateX12",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateX12Request"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateX12Result"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Too Many Requests"
          }
        }
      }
    },
    "/api/v1/validate/edifact": {
      "post": {
        "tags": [
          "EDI Operations"
        ],
        "summary": "Validate raw EDIFACT EDI content against EDI specifications",
        "description": "Accepts raw EDIFACT EDI text and returns a detailed validation report including errors and warnings.",
        "operationId": "ValidateEdifact",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateEdifactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateEdifactResult"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "429": {
            "description": "Too Many Requests"
          }
        }
      }
    },
    "/api/v1/interchange/receive/x12": {
      "post": {
        "tags": [
          "EDI Operations"
        ],
        "summary": "Receive an inbound X12 interchange with partner tracking",
        "description": "Parses raw X12 EDI, records the interchange, resolves the trading partner, applies partner validation rules, and performs duplicate detection and 997 acknowledgment matching.",
        "operationId": "ReceiveX12",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReceiveX12Request"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiveX12Result"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiveX12Result"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiveX12Result"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Too Many Requests"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JsonElement": { },
      "NullableOfJsonElement": {
        "nullable": true
      },
      "ReadEdifactRequest": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          },
          "includeCONTRL": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "ReadEdifactResult": {
        "required": [
          "success",
          "version",
          "messages",
          "ackCONTRL",
          "errors"
        ],
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          },
          "messages": {
            "type": "array"
          },
          "ackCONTRL": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "default": null,
            "nullable": true
          }
        }
      },
      "ReadX12Group": {
        "required": [
          "gs",
          "ge",
          "transactionSets"
        ],
        "type": "object",
        "properties": {
          "gs": {
            "$ref": "#/components/schemas/JsonElement"
          },
          "ge": {
            "$ref": "#/components/schemas/NullableOfJsonElement"
          },
          "transactionSets": {
            "type": "array"
          }
        }
      },
      "ReadX12Request": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          },
          "include997": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "ReadX12Result": {
        "required": [
          "success",
          "version",
          "isa",
          "iea",
          "groups",
          "ack997",
          "ackTA1",
          "errors"
        ],
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          },
          "isa": {
            "$ref": "#/components/schemas/NullableOfJsonElement"
          },
          "iea": {
            "$ref": "#/components/schemas/NullableOfJsonElement"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReadX12Group"
            }
          },
          "ack997": {
            "type": "string",
            "nullable": true
          },
          "ackTA1": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "default": null,
            "nullable": true
          }
        }
      },
      "ReceiveX12Group": {
        "required": [
          "gs",
          "ge",
          "transactionSets"
        ],
        "type": "object",
        "properties": {
          "gs": {
            "$ref": "#/components/schemas/JsonElement"
          },
          "ge": {
            "$ref": "#/components/schemas/NullableOfJsonElement"
          },
          "transactionSets": {
            "type": "array"
          }
        }
      },
      "ReceiveX12Request": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          },
          "partnerId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "include997": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "ReceiveX12Result": {
        "required": [
          "success",
          "version",
          "isa",
          "iea",
          "groups",
          "ack997",
          "ackTA1",
          "errors"
        ],
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          },
          "isa": {
            "$ref": "#/components/schemas/NullableOfJsonElement"
          },
          "iea": {
            "$ref": "#/components/schemas/NullableOfJsonElement"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReceiveX12Group"
            }
          },
          "ack997": {
            "type": "string",
            "nullable": true
          },
          "ackTA1": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "interchangeRecordId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "resolvedPartnerId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "partnerValidationErrors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "default": null,
            "nullable": true
          },
          "requestId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "default": null,
            "nullable": true
          }
        }
      },
      "ValidateEdifactRequest": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          }
        }
      },
      "ValidateEdifactResult": {
        "required": [
          "isValid",
          "errors",
          "warnings"
        ],
        "type": "object",
        "properties": {
          "isValid": {
            "type": "boolean"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "default": null,
            "nullable": true
          }
        }
      },
      "ValidateX12Request": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          }
        }
      },
      "ValidateX12Result": {
        "required": [
          "isValid",
          "errors",
          "warnings"
        ],
        "type": "object",
        "properties": {
          "isValid": {
            "type": "boolean"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "default": null,
            "nullable": true
          }
        }
      },
      "ValidationError": {
        "required": [
          "segment",
          "position",
          "message",
          "errorCode"
        ],
        "type": "object",
        "properties": {
          "segment": {
            "type": "string"
          },
          "position": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "type": "string"
          },
          "errorCode": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "WriteEdifactRequest": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "$ref": "#/components/schemas/JsonElement"
          }
        }
      },
      "WriteEdifactResult": {
        "required": [
          "success",
          "ediContent",
          "errors"
        ],
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "ediContent": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "default": null,
            "nullable": true
          }
        }
      },
      "WriteX12Request": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "$ref": "#/components/schemas/JsonElement"
          }
        }
      },
      "WriteX12Result": {
        "required": [
          "success",
          "ediContent",
          "errors"
        ],
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "ediContent": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string",
            "default": null,
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "default": null,
            "nullable": true
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "EDI Operations"
    }
  ]
}