{
  "openapi": "3.1.0",
  "info": {
    "title": "UIE correspondence",
    "version": "1.1.0",
    "description": "New enquiries go directly to UIE departmental inboxes by email. This API reads and follows up on existing private threads using the private capability."
  },
  "servers": [
    {
      "url": "https://fdkvjebkrvgdxvrilotw.supabase.co/functions/v1"
    }
  ],
  "security": [
    {
      "projectKey": [],
      "publicBearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "projectKey": {
        "type": "apiKey",
        "in": "header",
        "name": "apikey",
        "description": "Use x-publishable-project-key."
      },
      "publicBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Use the same publishable project key. A private thread also requires its own replyToken."
      }
    }
  },
  "x-publishable-project-key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZka3ZqZWJrcnZnZHh2cmlsb3R3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzgyNjE1MjIsImV4cCI6MjA5MzgzNzUyMn0.zCweB3TCmogBoFuUoW2m9h2SZhbw9SQp-0Gv9a0ve8g",
  "paths": {
    "/ursa-intake": {
      "post": {
        "operationId": "correspondWithUIE",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "const": "read"
                      },
                      "reference": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "replyToken": {
                        "type": "string",
                        "pattern": "^[0-9a-f]{64}$",
                        "description": "Use the private token from the existing thread access code."
                      }
                    },
                    "required": [
                      "action",
                      "reference",
                      "replyToken"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "const": "follow_up"
                      },
                      "reference": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "replyToken": {
                        "type": "string",
                        "pattern": "^[0-9a-f]{64}$",
                        "description": "Use the private token from the existing thread access code."
                      },
                      "message": {
                        "type": "string",
                        "minLength": 8,
                        "maxLength": 5000
                      },
                      "requestId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "consent": {
                        "const": true
                      }
                    },
                    "required": [
                      "action",
                      "reference",
                      "replyToken",
                      "message",
                      "requestId",
                      "consent"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted retry or thread response"
          },
          "201": {
            "description": "Message received; response includes reference"
          },
          "404": {
            "description": "Private thread unavailable"
          },
          "409": {
            "description": "Request ID was already used for different content"
          },
          "422": {
            "description": "Invalid request"
          },
          "429": {
            "description": "Retry later"
          },
          "503": {
            "description": "Receipt unavailable"
          }
        }
      }
    }
  }
}
