{
  "openapi": "3.1.0",
  "info": {
    "title": "BlueAuth API for ChatGPT",
    "version": "1.0.0",
    "description": "Compatibility API for BlueAuth document authentication, electronic signatures, certificates, timestamps, and forensic evidence preservation. Blockchain or timestamp evidence is returned only by operations that perform that action. Authenticate with a BlueAuth API key (ba_live_xxx or ba_test_xxx) via Bearer token. For new agent integrations, prefer the remote MCP server at https://blueauth.co/api/mcp-server/mcp.\n\nGet your API key at https://blueauth.co/g/developer/api-keys",
    "termsOfService": "https://blueauth.co/terms",
    "contact": {
      "name": "BlueAuth Support",
      "email": "support@blueauth.co",
      "url": "https://blueauth.co/mcp"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://blueauth.co/terms"
    }
  },
  "externalDocs": {
    "description": "Privacy Policy",
    "url": "https://blueauth.co/privacy-policy"
  },
  "servers": [
    {
      "url": "https://blueauth.co",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/mcpPublic": {
      "post": {
        "operationId": "blueauthOperation",
        "summary": "Execute a BlueAuth operation",
        "description": "Single endpoint that routes to all BlueAuth operations. Specify the operation in the request body.",
        "security": [
          { "ApiKeyAuth": [] }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["operation"],
                "properties": {
                  "operation": {
                    "type": "string",
                    "enum": [
                      "getBalance",
                      "getUploadUrl",
                      "verifyDocument",
                      "registerDocument",
                      "stampDocument",
                      "createSignatureRequest",
                      "issueCertificateBatch",
                      "createEcustodyGroup",
                      "appendEcustody"
                    ],
                    "description": "The BlueAuth operation to execute. Use getBalance to check available documents, getUploadUrl before uploading files, verifyDocument to check a hash, registerDocument to authenticate a PDF on blockchain, stampDocument to apply a timestamp, createSignatureRequest to send for signature, issueCertificateBatch for batch certificates, createEcustodyGroup for forensic evidence preservation, appendEcustody to add files to existing custody group."
                  },
                  "params": {
                    "type": "object",
                    "description": "Operation-specific parameters. See each operation's required fields below.",
                    "properties": {
                      "fileName": {
                        "type": "string",
                        "description": "[getUploadUrl] Name of file to upload (e.g. 'contract.pdf')"
                      },
                      "contentType": {
                        "type": "string",
                        "description": "[getUploadUrl] MIME type (e.g. 'application/pdf')"
                      },
                      "fileSizeBytes": {
                        "type": "number",
                        "description": "[getUploadUrl, registerDocument, stampDocument] File size in bytes"
                      },
                      "storagePath": {
                        "type": "string",
                        "description": "[registerDocument, stampDocument, createSignatureRequest] Storage path returned by getUploadUrl after file upload"
                      },
                      "documentName": {
                        "type": "string",
                        "description": "[registerDocument, stampDocument, createSignatureRequest] Human-readable document name"
                      },
                      "visibility": {
                        "type": "string",
                        "enum": ["public", "private", "password"],
                        "description": "[registerDocument, stampDocument, createEcustodyGroup] Visibility level"
                      },
                      "unlockPassword": {
                        "type": "string",
                        "description": "[registerDocument, stampDocument] Password if visibility=private"
                      },
                      "placement": {
                        "type": "string",
                        "enum": ["bottom-right", "bottom-left", "top-right", "top-left", "center"],
                        "description": "[registerDocument] Watermark placement"
                      },
                      "signers": {
                        "type": "array",
                        "description": "[createSignatureRequest] List of signers",
                        "items": {
                          "type": "object",
                          "required": ["email", "fullName"],
                          "properties": {
                            "email": { "type": "string", "format": "email" },
                            "fullName": { "type": "string" },
                            "phone": { "type": "string" },
                            "useWhatsapp": { "type": "boolean" },
                            "lang": { "type": "string", "enum": ["pt", "en"] }
                          }
                        }
                      },
                      "message": {
                        "type": "string",
                        "description": "[createSignatureRequest] Optional message for signers"
                      },
                      "templateStoragePath": {
                        "type": "string",
                        "description": "[issueCertificateBatch] Storage path of certificate template"
                      },
                      "certificateName": {
                        "type": "string",
                        "description": "[issueCertificateBatch] Certificate name/title"
                      },
                      "recipients": {
                        "type": "array",
                        "description": "[issueCertificateBatch] List of certificate recipients",
                        "items": {
                          "type": "object",
                          "required": ["name", "email"],
                          "properties": {
                            "name": { "type": "string" },
                            "email": { "type": "string", "format": "email" },
                            "customFields": {
                              "type": "object",
                              "additionalProperties": { "type": "string" }
                            }
                          }
                        }
                      },
                      "groupName": {
                        "type": "string",
                        "description": "[createEcustodyGroup] Name of evidence group"
                      },
                      "password": {
                        "type": "string",
                        "description": "[createEcustodyGroup] Password if visibility=password"
                      },
                      "caseId": {
                        "type": "string",
                        "description": "[createEcustodyGroup] Legal case identifier"
                      },
                      "notes": {
                        "type": "string",
                        "description": "[createEcustodyGroup, appendEcustody] Notes about the evidence"
                      },
                      "includeBlockchain": {
                        "type": "boolean",
                        "description": "[createEcustodyGroup] Anchor on blockchain (default true)"
                      },
                      "files": {
                        "type": "array",
                        "description": "[createEcustodyGroup, appendEcustody] Files to preserve",
                        "items": {
                          "type": "object",
                          "required": ["storagePath", "fileName", "fileSize"],
                          "properties": {
                            "storagePath": { "type": "string" },
                            "fileName": { "type": "string" },
                            "fileSize": { "type": "number" }
                          }
                        }
                      },
                      "groupId": {
                        "type": "string",
                        "description": "[appendEcustody] Existing custody group ID"
                      },
                      "hash": {
                        "type": "string",
                        "description": "[verifyDocument] Document hash to verify on blockchain"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "description": "Operation-specific result payload",
                      "additionalProperties": true,
                      "properties": {
                        "available": { "type": "number", "description": "Documents available (getBalance)" },
                        "plan": { "type": "string", "description": "Subscription plan name" },
                        "subscriptionStatus": { "type": "string", "description": "Subscription status" },
                        "environment": { "type": "string", "description": "live or test" },
                        "uploadUrl": { "type": "string", "description": "Signed upload URL (getUploadUrl)" },
                        "storagePath": { "type": "string", "description": "Storage path for file" },
                        "expiresAt": { "type": "string", "description": "URL expiration timestamp" },
                        "documentHash": { "type": "string", "description": "SHA-256 hash of document" },
                        "blockchainHash": { "type": "string", "description": "Hash registered on blockchain" },
                        "blockNumber": { "type": "number", "description": "Blockchain block number" },
                        "verificationUrl": { "type": "string", "description": "Public verification page URL" },
                        "verified": { "type": "boolean", "description": "Whether hash was found on blockchain" },
                        "documentName": { "type": "string", "description": "Name of the document" },
                        "tokensUsed": { "type": "number", "description": "Documents counted by the operation" },
                        "requestId": { "type": "string", "description": "Signature request ID" },
                        "trackingUrl": { "type": "string", "description": "URL to track signature progress" },
                        "batchId": { "type": "string", "description": "Certificate batch ID" },
                        "groupId": { "type": "string", "description": "E-custody group ID" },
                        "groupHash": { "type": "string", "description": "E-custody group hash" },
                        "publicUrl": { "type": "string", "description": "Public URL for evidence group" },
                        "status": { "type": "string", "description": "Operation status" }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": { "type": "string" },
                    "message": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid operation or missing parameters",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": { "type": "string" },
                    "message": { "type": "string" }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": { "type": "string" },
                    "message": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {},
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your BlueAuth API key (ba_live_xxx for production, ba_test_xxx for sandbox). Sent as 'Authorization: Bearer ba_live_...'. Get one at https://blueauth.co/g/developer/api-keys"
      }
    }
  }
}
