{
  "openapi": "3.1.0",
  "info": {
    "title": "Audit Clue API",
    "version": "0.1.0",
    "description": "PBC means \"prepared by client\": the records an auditor asks a company to hand over. The ledger and a zip of the company's general records are free downloads. The documents behind a ledger entry come from POST /api/{dataset}/pbc, by transaction ID (the ledger's Entry number, not the Line ID). The service returns only records that already exist. It never writes documents and never says who is responsible. Requests are metered: one unit per transaction ID in every served request, charged again if you ask for the same ID again. Rejected, failed and rate-limited calls are free. Examples below are illustrative: IDs, filenames and hashes are placeholders, not records of the practice or final case."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/teams/register": {
      "post": {
        "summary": "Register a team while signup is open",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "team_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "team_name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token shown once; expires 48 hours after signup",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Registration"
                }
              }
            }
          },
          "400": {
            "description": "Bad team name or body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Registration is closed (REGISTRATION_CLOSED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Team name taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "413": {
            "description": "Body or output too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Operational limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "503": {
            "description": "Storage unavailable; safe to retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        }
      }
    },
    "/api/{dataset}/pbc": {
      "parameters": [
        {
          "name": "dataset",
          "in": "path",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/Dataset"
          }
        }
      ],
      "post": {
        "summary": "PBC request: the documents behind ledger entries",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "description": "Optional. Omit for a new logged request. Supply a key only for exact retry protection, and reuse it only with the same payload. Evidence selection caching and unique-ID counting do not require a key. Explicit empty or malformed keys are rejected.",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[ -~]{1,128}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Request"
              },
              "examples": {
                "byTransactionId": {
                  "summary": "By transaction ID",
                  "value": {
                    "transaction_ids": [
                      "GJ-2025-0000123"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ready. `usage` is the team's running total after this request, not the cost of this request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ready"
                },
                "examples": {
                  "byTransactionId": {
                    "summary": "Illustrative: documents tied to one ledger entry",
                    "value": {
                      "request_id": "11111111-2222-4333-8444-555555555555",
                      "dataset": "practice",
                      "dataset_version": "example-v1",
                      "status": "ready",
                      "resolved_scope": {
                        "sources": [],
                        "transaction_ids": [
                          "GJ-2025-0000123"
                        ]
                      },
                      "documents": [
                        {
                          "document_id": "d-0a1b2c3d4e5f60718293",
                          "filename": "purchase-order-PO-1042.pdf",
                          "content_type": "application/pdf",
                          "bytes": 48211,
                          "sha256": "<sha256 of the file>",
                          "download_path": "/api/practice/documents/d-0a1b2c3d4e5f60718293"
                        },
                        {
                          "document_id": "d-1b2c3d4e5f6071829304",
                          "filename": "invoice-INV-7731.pdf",
                          "content_type": "application/pdf",
                          "bytes": 51907,
                          "sha256": "<sha256 of the file>",
                          "download_path": "/api/practice/documents/d-1b2c3d4e5f6071829304"
                        },
                        {
                          "document_id": "d-2c3d4e5f607182930415",
                          "filename": "payment-confirmation-PAY-1042.pdf",
                          "content_type": "application/pdf",
                          "bytes": 39544,
                          "sha256": "<sha256 of the file>",
                          "download_path": "/api/practice/documents/d-2c3d4e5f607182930415"
                        }
                      ],
                      "unavailable": [],
                      "usage": {
                        "requests": 1,
                        "unique_transaction_ids": 1,
                        "source_requests": 0,
                        "bytes_downloaded": 0,
                        "transaction_units": 1,
                        "question_documents": 0,
                        "metered_units": 1
                      },
                      "metered": {
                        "transaction_units": 1,
                        "question_documents": 0
                      }
                    }
                  },
                  "withMissingOriginal": {
                    "summary": "Illustrative: one original no longer exists",
                    "value": {
                      "request_id": "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee",
                      "dataset": "practice",
                      "dataset_version": "example-v1",
                      "status": "ready",
                      "resolved_scope": {
                        "sources": [],
                        "transaction_ids": [
                          "GJ-2025-0000456"
                        ]
                      },
                      "documents": [
                        {
                          "document_id": "d-4e5f6071829304152637",
                          "filename": "invoice-INV-8020.pdf",
                          "content_type": "application/pdf",
                          "bytes": 50122,
                          "sha256": "<sha256 of the file>",
                          "download_path": "/api/practice/documents/d-4e5f6071829304152637"
                        }
                      ],
                      "unavailable": [
                        {
                          "reference": "INV-8020 delivery note",
                          "status": "unavailable",
                          "reason": "The original was not retained. Asking again does not change this."
                        }
                      ],
                      "usage": {
                        "requests": 3,
                        "unique_transaction_ids": 2,
                        "source_requests": 0,
                        "bytes_downloaded": 0,
                        "transaction_units": 3,
                        "question_documents": 0,
                        "metered_units": 3
                      },
                      "metered": {
                        "transaction_units": 1,
                        "question_documents": 0
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad body, a question (not supported), or the dataset is not released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Team disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate name, payload conflict or active lease",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "413": {
            "description": "Body or output too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Unknown transaction ID, or the IDs together exceed 50 documents",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tooBroad": {
                    "summary": "The IDs together have more than 50 documents (free)",
                    "value": {
                      "code": "CLARIFICATION_REQUIRED",
                      "reason": "too_broad",
                      "message": "These transaction IDs would return more than 50 documents: send fewer IDs.",
                      "retryable": false,
                      "request_id": "23232323-4545-4676-8898-010101010101"
                    }
                  },
                  "unknownId": {
                    "summary": "A transaction ID is not in the ledger (free)",
                    "value": {
                      "code": "UNKNOWN_TRANSACTION",
                      "message": "One or more transaction IDs are not in the ledger. Use the ledger's Entry number (for example GJ-2025-0000123), not the Line ID (JEL-...).",
                      "retryable": false
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Operational limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "503": {
            "description": "Storage unavailable; safe to retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        },
        "description": "Send the ledger Entry numbers you want the documents for. Each entry usually has several documents. Metered at one unit per ID, every time you ask for it.\n\nAt most 100 IDs per request and 50 documents per response; if the IDs together have more, the request is rejected with 422 and costs nothing: send fewer IDs.\n\nReusing an Idempotency-Key with the same body replays the stored answer for free."
      }
    },
    "/api/{dataset}/documents/{document_id}": {
      "parameters": [
        {
          "name": "dataset",
          "in": "path",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/Dataset"
          }
        },
        {
          "name": "document_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "summary": "Download a granted document",
        "responses": {
          "200": {
            "description": "The document",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Bad body, or the dataset is not released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Team disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Operational limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "503": {
            "description": "Storage unavailable; safe to retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        }
      }
    },
    "/api/{dataset}/downloads/{file_id}": {
      "parameters": [
        {
          "name": "dataset",
          "in": "path",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/Dataset"
          }
        },
        {
          "name": "file_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "summary": "Download the ledger or the records zip",
        "parameters": [
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Optional, for resuming a large download: one byte range, e.g. bytes=0-1048575"
          }
        ],
        "responses": {
          "200": {
            "description": "The whole file",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "Part of the file",
            "headers": {
              "Content-Range": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Bad body, or the dataset is not released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Team disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "416": {
            "description": "Unsatisfiable range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Operational limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "503": {
            "description": "Storage unavailable; safe to retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        }
      }
    },
    "/api/{dataset}/usage": {
      "parameters": [
        {
          "name": "dataset",
          "in": "path",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/Dataset"
          }
        }
      ],
      "get": {
        "summary": "Your team's usage",
        "responses": {
          "200": {
            "description": "Current usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "400": {
            "description": "Bad body, or the dataset is not released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Team disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Operational limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "503": {
            "description": "Storage unavailable; safe to retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Delay in seconds when retryable",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        }
      }
    },
    "/api/{dataset}/accuse": {
      "parameters": [
        {
          "name": "dataset",
          "in": "path",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/Dataset"
          }
        }
      ],
      "post": {
        "summary": "Name the person responsible",
        "description": "Fields:\n\n- `name` (required): full name as in the records.\n- `employee_id`: the employee number. Send it: either the name or the number can identify the person.\n- `transaction_ids` (required): 1 to 100 ledger Entry numbers involved.\n- `document_ids` (required): 1 to 20 documents your team received that prove it.\n- `reasoning` (required): plain text, 50 to 4000 characters.\n\nAn accusation missing any of these, citing documents you were not given or entries not in the ledger is rejected with 422 and costs nothing.\n\n**Practice** answers immediately. `correct` is true only when the person is responsible and at least one entry you cite is part of what they did; then `entries_matched` of `entries_cited` says how many were on target. Otherwise it is false, and the reply does not say whether the name or the entries were off. `found` and `culprits` count your progress and `wrong` counts wrong accusations, test names included. There is no cap.\n\n**Final**: every accusation is a separate claim that stands until you withdraw it (up to 200), `correct` is always null, and results are announced after the event. Accusing someone the records do not support counts against you.\n\nAccusations are not metered.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "transaction_ids",
                  "document_ids",
                  "reasoning"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 120,
                    "description": "The person's full name as it appears in the company's records."
                  },
                  "employee_id": {
                    "type": "string",
                    "description": "The person's employee number, or the person ID the ledger prints (Preparer ID, Approver ID). Send it with the name: either one can identify the person."
                  },
                  "transaction_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "type": "string"
                    },
                    "description": "1 to 100 ledger Entry numbers involved (the same IDs you send to PBC)."
                  },
                  "document_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string"
                    },
                    "description": "1 to 20 document_id values from your PBC responses. Each must be a document your team received in this dataset."
                  },
                  "reasoning": {
                    "type": "string",
                    "minLength": 50,
                    "maxLength": 4000,
                    "description": "Plain text: how the cited documents tie this person to it. Read by the judges."
                  }
                }
              },
              "examples": {
                "person": {
                  "summary": "An accusation",
                  "value": {
                    "name": "Jordan Example",
                    "employee_id": "100123",
                    "transaction_ids": [
                      "GJ-2025-0000123",
                      "GJ-2025-0000456"
                    ],
                    "document_ids": [
                      "DOCUMENT_ID_1",
                      "DOCUMENT_ID_2"
                    ],
                    "reasoning": "Why the cited documents show that this person did it, in your own words."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "recorded",
                    "correct",
                    "message"
                  ],
                  "properties": {
                    "recorded": {
                      "type": "boolean"
                    },
                    "correct": {
                      "type": [
                        "boolean",
                        "null"
                      ],
                      "description": "Practice: true or false. Final: always null."
                    },
                    "remaining": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "Final only: accusations you can still add."
                    },
                    "message": {
                      "type": "string"
                    },
                    "accusation_id": {
                      "type": "string"
                    },
                    "found": {
                      "type": "integer",
                      "description": "Practice only: culprits you have found."
                    },
                    "culprits": {
                      "type": "integer",
                      "description": "Practice only: culprits in the case."
                    },
                    "wrong": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "Practice only: wrong accusations your team has made."
                    },
                    "entries_matched": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "Practice, correct only: cited entries that are part of what this person did."
                    },
                    "entries_cited": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "Practice, correct only: entries you cited."
                    }
                  }
                },
                "examples": {
                  "practiceWrong": {
                    "summary": "Practice: not established",
                    "value": {
                      "recorded": true,
                      "correct": false,
                      "found": 0,
                      "culprits": 6,
                      "wrong": 1,
                      "message": "Not established. Either this person is not responsible, or none of the entries you cited is part of what they did.",
                      "accusation_id": "33333333-4444-4555-8666-777777777777"
                    }
                  },
                  "practiceRight": {
                    "summary": "Practice: right person, with entries from their case",
                    "value": {
                      "recorded": true,
                      "correct": true,
                      "found": 1,
                      "culprits": 6,
                      "wrong": 0,
                      "entries_matched": 3,
                      "entries_cited": 4,
                      "message": "Correct. 3 of 4 cited entries are part of what this person did.",
                      "accusation_id": "33333333-4444-4555-8666-777777777777"
                    }
                  },
                  "final": {
                    "summary": "Final: recorded, no verdict",
                    "value": {
                      "recorded": true,
                      "correct": null,
                      "remaining": 199,
                      "message": "Recorded. Every accusation stands until you withdraw it; results are announced after the event.",
                      "accusation_id": "33333333-4444-4555-8666-777777777777"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad body, or the dataset is not released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Final: no accusations left. Practice: every culprit is already found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Missing or unknown transaction IDs (TRANSACTIONS_REQUIRED, UNKNOWN_TRANSACTION), documents not held (DOCUMENTS_NOT_HELD) or reasoning missing (REASONING_REQUIRED); costs no try",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Operational limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Team disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List your standing accusations",
        "responses": {
          "200": {
            "description": "Your accusations for the active dataset version",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "limit": {
                      "type": "integer"
                    },
                    "accusations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "accusation_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "employee_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "role": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "transaction_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "correct": {
                            "type": [
                              "boolean",
                              "null"
                            ]
                          },
                          "inserted_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/{dataset}/accuse/{accusation_id}": {
      "parameters": [
        {
          "name": "dataset",
          "in": "path",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/Dataset"
          }
        },
        {
          "name": "accusation_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "delete": {
        "summary": "Withdraw a Final accusation",
        "description": "Final only. Practice accusations cannot be withdrawn.",
        "responses": {
          "200": {
            "description": "Withdrawn",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "withdrawn": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such standing accusation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "Dataset": {
        "type": "string",
        "enum": [
          "practice",
          "final"
        ]
      },
      "Registration": {
        "type": "object",
        "properties": {
          "team_id": {
            "type": "string"
          },
          "team_name": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "team_id",
          "team_name",
          "token",
          "expires_at"
        ]
      },
      "Request": {
        "type": "object",
        "properties": {
          "transaction_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "maxItems": 100
          }
        },
        "required": [
          "transaction_ids"
        ],
        "description": "1 to 100 transaction IDs: the ledger's Entry number, not the Line ID."
      },
      "Ready": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "dataset": {
            "$ref": "#/components/schemas/Dataset"
          },
          "dataset_version": {
            "type": "string"
          },
          "status": {
            "const": "ready"
          },
          "resolved_scope": {
            "$ref": "#/components/schemas/Scope",
            "description": "The transaction IDs this request covered."
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Document"
            }
          },
          "unavailable": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Unavailable"
            },
            "description": "Records that are partial, missing or unreadable. Asking again does not change them."
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "metered": {
            "type": "object",
            "description": "What this request cost. One unit per transaction ID.",
            "properties": {
              "transaction_units": {
                "type": "integer",
                "description": "One per transaction ID in this request."
              },
              "question_documents": {
                "type": "integer",
                "description": "Always 0."
              }
            }
          }
        },
        "required": [
          "request_id",
          "dataset",
          "dataset_version",
          "status",
          "resolved_scope",
          "documents",
          "unavailable",
          "usage"
        ]
      },
      "Scope": {
        "type": "object",
        "properties": {
          "transaction_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Always empty."
          }
        },
        "required": [
          "transaction_ids",
          "sources"
        ]
      },
      "Document": {
        "type": "object",
        "properties": {
          "document_id": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "content_type": {
            "type": "string",
            "description": "application/pdf, image/jpeg, text/html or text/csv. Files are always served as attachments."
          },
          "bytes": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Size in bytes. Null in a generated dataset until the document has been downloaded once; every download carries its checksum in the X-Content-SHA256 header."
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "description": "SHA-256 of the file, or null as for bytes."
          },
          "download_path": {
            "type": "string"
          }
        },
        "required": [
          "document_id",
          "filename",
          "content_type",
          "bytes",
          "sha256",
          "download_path"
        ]
      },
      "Unavailable": {
        "type": "object",
        "properties": {
          "reference": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "partial",
              "unavailable",
              "poor_quality"
            ]
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "reference",
          "status",
          "reason"
        ]
      },
      "Usage": {
        "type": "object",
        "description": "Your team's running totals for this dataset. Only requests that returned documents count.",
        "properties": {
          "requests": {
            "type": "integer",
            "minimum": 0,
            "description": "Requests that returned documents."
          },
          "unique_transaction_ids": {
            "type": "integer",
            "minimum": 0,
            "description": "Distinct transaction IDs you have received documents for."
          },
          "source_requests": {
            "type": "integer",
            "minimum": 0,
            "description": "Always 0."
          },
          "bytes_downloaded": {
            "type": "integer",
            "minimum": 0,
            "description": "Bytes of documents and downloads sent to you."
          },
          "transaction_units": {
            "type": "integer",
            "minimum": 0,
            "description": "Metered: one per transaction ID in every request that returned records; asking for the same ID again is charged again."
          },
          "question_documents": {
            "type": "integer",
            "minimum": 0,
            "description": "Always 0: requests take transaction IDs only."
          },
          "metered_units": {
            "type": "integer",
            "minimum": 0,
            "description": "Equal to transaction_units. Shown on the public leaderboard; fewer ranks higher."
          }
        },
        "required": [
          "requests",
          "unique_transaction_ids",
          "source_requests",
          "bytes_downloaded",
          "transaction_units",
          "question_documents",
          "metered_units"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "request_id": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "too_broad",
              "no_evidence"
            ],
            "description": "Present only with CLARIFICATION_REQUIRED. too_broad: the IDs together have more than 50 documents; send fewer IDs. no_evidence: no documents are held for those entries. A same-key replay returns the same reason."
          }
        },
        "required": [
          "code",
          "message",
          "retryable"
        ]
      }
    }
  }
}
