{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peoplescourt-ai/json-schema/peoplescourt-ai-canonical-filing-schema.json",
  "title": "CanonicalFiling",
  "description": "Prepare a standard-procedure filing using caseTrack and the separate appealWaived election. The default retains a human appeal. External principal IDs identify represented parties; they are not account credentials. Use claimantAcceptanceIdentity for claimant account binding.",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peoplescourt-ai-openapi.json#/components/schemas/CanonicalFiling",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "externalCaseId",
    "transactionId",
    "policyVersion",
    "authorityGrantId",
    "consentArtifactIds",
    "claimAmount",
    "parties",
    "intakeMode",
    "confirmationPolicy",
    "claimantAcceptanceIdentity"
  ],
  "properties": {
    "caseMode": {
      "type": "string",
      "enum": [
        "proceeding",
        "evaluation"
      ],
      "default": "proceeding"
    },
    "externalCaseId": {
      "type": "string"
    },
    "transactionId": {
      "type": "string"
    },
    "policyVersion": {
      "type": "string"
    },
    "authorityGrantId": {
      "type": "string"
    },
    "consentArtifactIds": {
      "$ref": "#/$defs/CaseDraftConsentArtifactIds"
    },
    "claimAmount": {
      "$ref": "#/$defs/FiatMoney"
    },
    "parties": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "claimant",
        "respondent"
      ],
      "properties": {
        "claimant": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "externalId",
            "name",
            "principalKind"
          ],
          "properties": {
            "externalId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "principalKind": {
              "$ref": "#/$defs/CanonicalPrincipalKind"
            },
            "accountId": {
              "type": "string",
              "description": "Do not supply this field for new filings. Use claimantAcceptanceIdentity for claimant account binding."
            }
          }
        },
        "respondent": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "externalId",
            "name",
            "principalKind"
          ],
          "properties": {
            "externalId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "principalKind": {
              "$ref": "#/$defs/CanonicalPrincipalKind"
            },
            "accountId": {
              "type": "string",
              "description": "Do not supply this field for new filings. Use claimantAcceptanceIdentity for claimant account binding."
            }
          }
        }
      }
    },
    "summary": {
      "type": "string"
    },
    "backgroundFacts": {
      "type": "string"
    },
    "claim": {
      "$ref": "#/$defs/CanonicalComplaintClaim"
    },
    "feeReferralAuthorizationId": {
      "type": "string",
      "description": "Neutral agreement-derived fee referral. Mutually exclusive with sponsorshipReferralId."
    },
    "sponsorshipReferralId": {
      "type": "string",
      "deprecated": true,
      "description": "Fixed-$5 sponsorship referral. Mutually exclusive with feeReferralAuthorizationId."
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "intakeMode": {
      "type": "string",
      "enum": [
        "claimant_initiated",
        "claimant_proposed",
        "bilateral_api",
        "bundled_bilateral"
      ]
    },
    "confirmationPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode"
      ],
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "initiator_only",
            "all_participants",
            "bundled_authorizations"
          ]
        }
      }
    },
    "procedure": {
      "type": "string",
      "const": "standard",
      "deprecated": true,
      "description": "The filing procedure is standard. Select the adjudicator track using caseTrack and make any appeal waiver as a separate appealWaived election."
    },
    "evaluation": {
      "$ref": "#/$defs/NarrowEvaluationDefinitionInput"
    },
    "participants": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "role"
        ],
        "properties": {
          "side": {
            "type": "string",
            "enum": [
              "claimant",
              "respondent"
            ]
          },
          "partnerId": {
            "type": "string",
            "description": "Required for API-authorized participants. Omit it for the hosted respondent in claimant_initiated mode."
          },
          "agentId": {
            "type": "string"
          },
          "role": {
            "$ref": "#/$defs/CanonicalRepresentativeRole"
          }
        }
      }
    },
    "claimantAcceptanceIdentity": {
      "description": "Optional packet identity. When omitted, existing partner consent and hosted respondent behavior apply; no hosted claimant acceptance link is issued. Canonical filings require this identity.",
      "$ref": "#/$defs/ClaimantAcceptanceIdentity"
    },
    "schedule": {
      "$ref": "#/$defs/CaseProcedure"
    },
    "caseTrack": {
      "$ref": "#/$defs/CaseTrack",
      "description": "Select AI-only (ai_standard or ai_fast, also the default) or ai_assisted_human. Before consent, the server assigns eligible AI-only monetary cases below USD 100 to ai_fast and other cases to ai_standard. Both parties accept the exact resolved procedure and fee terms.",
      "default": "ai_standard"
    },
    "appealWaived": {
      "type": "boolean",
      "default": false,
      "description": "Separate proposed internal human appeal waiver; effective only after both parties expressly accept the exact procedure tuple."
    }
  },
  "allOf": [
    {
      "not": {
        "required": [
          "feeReferralAuthorizationId",
          "sponsorshipReferralId"
        ]
      }
    },
    {
      "oneOf": [
        {
          "title": "Claimant initiates and respondent may consent later",
          "properties": {
            "intakeMode": {
              "type": "string",
              "const": "claimant_initiated"
            }
          },
          "oneOf": [
            {
              "title": "Hosted respondent consents after opening",
              "properties": {
                "consentArtifactIds": {
                  "$ref": "#/$defs/ClaimantOnlyConsentArtifactIds"
                },
                "participants": {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "role"
                    ],
                    "properties": {
                      "side": {
                        "type": "string",
                        "enum": [
                          "claimant",
                          "respondent"
                        ]
                      },
                      "partnerId": {
                        "type": "string",
                        "description": "Required for API-authorized participants. Omit it for the hosted respondent in claimant_initiated mode."
                      },
                      "agentId": {
                        "type": "string"
                      },
                      "role": {
                        "$ref": "#/$defs/CanonicalRepresentativeRole"
                      }
                    }
                  }
                }
              }
            },
            {
              "title": "Respondent consent was registered in advance",
              "properties": {
                "consentArtifactIds": {
                  "$ref": "#/$defs/ConsentArtifactIds"
                }
              }
            }
          ]
        },
        {
          "title": "Bilaterally authorized or claimant-proposed case",
          "properties": {
            "intakeMode": {
              "type": "string",
              "enum": [
                "claimant_proposed",
                "bilateral_api",
                "bundled_bilateral"
              ]
            },
            "consentArtifactIds": {
              "$ref": "#/$defs/ConsentArtifactIds"
            }
          }
        }
      ]
    }
  ],
  "oneOf": [
    {
      "title": "Proceeding case",
      "required": [
        "summary",
        "claim"
      ],
      "properties": {
        "caseMode": {
          "type": "string",
          "const": "proceeding"
        }
      }
    },
    {
      "title": "Narrow evaluation case",
      "required": [
        "caseMode",
        "evaluation"
      ],
      "properties": {
        "caseMode": {
          "type": "string",
          "const": "evaluation"
        }
      }
    }
  ],
  "$defs": {
    "CanonicalComplaintClaim": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "statement",
        "requestedOutcome"
      ],
      "properties": {
        "statement": {
          "type": "string"
        },
        "requestedOutcome": {
          "type": "string",
          "enum": [
            "refund",
            "release",
            "split",
            "other"
          ]
        },
        "requestedItems": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "description": "Optional typed operative requests, digest-bound with stable IDs. At most one monetary item uses claimAmount. Declaratory and fixed-order text is supplied directly by the party.",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "kind",
              "text"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[MDO][1-9][0-9]{0,5}$"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "monetary",
                  "declaratory",
                  "order"
                ]
              },
              "text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 4000
              }
            }
          }
        }
      }
    },
    "CanonicalPrincipalKind": {
      "type": "string",
      "enum": [
        "individual",
        "organization",
        "autonomous_agent"
      ]
    },
    "CanonicalRepresentativeRole": {
      "type": "string",
      "enum": [
        "claimant_representative",
        "respondent_representative"
      ]
    },
    "CaseDraftConsentArtifactIds": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "claimant": {
          "type": "string"
        },
        "respondent": {
          "type": "string",
          "description": "May be omitted only for claimant_initiated; the respondent then accepts the immutable case terms in the hosted flow."
        }
      }
    },
    "CaseProcedure": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "profile"
      ],
      "properties": {
        "profile": {
          "type": "string",
          "enum": [
            "standard",
            "fast",
            "single_round",
            "joint_record",
            "evaluation",
            "custom_bounded"
          ]
        },
        "answerRequired": {
          "type": "boolean"
        },
        "evidenceRounds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 3
        },
        "rebuttalRounds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 3
        },
        "filingsPerSidePerStage": {
          "type": "integer",
          "minimum": 1,
          "maximum": 3
        },
        "recordConfirmationRequired": {
          "type": "boolean",
          "const": true
        }
      }
    },
    "CaseTrack": {
      "type": "string",
      "enum": [
        "ai_fast",
        "ai_standard",
        "ai_assisted_human"
      ]
    },
    "ClaimantAcceptanceIdentity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "email"
      ],
      "properties": {
        "accountId": {
          "type": "string",
          "description": "Optional People’s Court account ID allowed to accept. Otherwise the signed-in account must have the normalized, verified claimant email."
        },
        "email": {
          "type": "string",
          "format": "email",
          "description": "Requires a signed-in account with this verified email."
        },
        "walletAddress": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$"
        }
      }
    },
    "ClaimantOnlyConsentArtifactIds": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "claimant": {
          "type": "string"
        }
      }
    },
    "ConsentArtifactIds": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "respondent"
      ],
      "properties": {
        "claimant": {
          "type": "string"
        },
        "respondent": {
          "type": "string"
        }
      }
    },
    "FiatMoney": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "currency",
        "minorUnits"
      ],
      "properties": {
        "currency": {
          "type": "string",
          "const": "USD"
        },
        "minorUnits": {
          "type": "string",
          "pattern": "^(0|[1-9][0-9]{0,77})$"
        }
      }
    },
    "NarrowEvaluationCriterion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "text"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]{0,63}$"
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        }
      }
    },
    "NarrowEvaluationDefinitionInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "externalEvaluationId",
        "question",
        "allowedOutcomes"
      ],
      "properties": {
        "externalEvaluationId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "question": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "text",
            "criteria"
          ],
          "properties": {
            "text": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2000
            },
            "criteria": {
              "type": "array",
              "minItems": 1,
              "maxItems": 20,
              "items": {
                "$ref": "#/$defs/NarrowEvaluationCriterion"
              }
            }
          }
        },
        "allowedOutcomes": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "description": "Exactly three outcomes are required; indeterminate must be the single outcome mapped to none. The other outcomes may use full release or exact Award allocation.",
          "items": {
            "$ref": "#/$defs/NarrowEvaluationOutcome"
          }
        },
        "evidencePolicy": {
          "$ref": "#/$defs/NarrowEvaluationEvidencePolicyInput"
        },
        "reviewPolicy": {
          "$ref": "#/$defs/NarrowEvaluationReviewPolicyInput"
        }
      }
    },
    "NarrowEvaluationEvidencePolicyInput": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "sources": {
          "type": "array",
          "minItems": 1,
          "maxItems": 2,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "enum": [
              "party_submissions",
              "evidence_export_candidates"
            ]
          }
        },
        "additionalPartyEvidence": {
          "type": "boolean",
          "const": true,
          "default": true
        }
      }
    },
    "NarrowEvaluationOutcome": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "code",
        "settlementAction"
      ],
      "properties": {
        "code": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]{0,63}$"
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "settlementAction": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "release_to_claimant",
                "release_to_respondent",
                "allocate_by_award",
                "none"
              ]
            }
          }
        }
      }
    },
    "NarrowEvaluationReviewPolicyInput": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "initialPath": {
          "type": "string",
          "const": "adjudicative",
          "default": "adjudicative"
        },
        "humanReviewRequired": {
          "type": "boolean",
          "const": false,
          "default": false
        }
      }
    }
  }
}