{
  "openapi": "3.1.0",
  "info": {
    "title": "Calvin Kennedy and Wayrest software enquiries",
    "version": "1.0.0",
    "description": "Submit a software enquiry on the user's behalf after obtaining their permission. Use one site and send once. A receipt confirms the message was recorded. Replies are by email. Keep credentials and private customer data out."
  },
  "servers": [
    {
      "url": "https://calvinkennedy.com"
    }
  ],
  "paths": {
    "/api/enquiries": {
      "post": {
        "operationId": "submitSoftwareEnquiry",
        "summary": "Send a software enquiry",
        "description": "Server-to-server JSON. Browser users can use the contact forms. Generate a new UUID v4 for each enquiry and reuse it for retries of the same message.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "site",
                  "submission_key",
                  "name",
                  "email",
                  "message"
                ],
                "properties": {
                  "site": {
                    "type": "string",
                    "enum": [
                      "calvin-kennedy",
                      "wayrest"
                    ]
                  },
                  "submission_key": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89aAbB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 100
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200,
                    "description": "Reply address supplied with the user's permission."
                  },
                  "message": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 4000,
                    "description": "Explain the project, what help is needed and any deadline. A public link can help."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded, or already recorded under the same submission key for this site.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "recorded",
                    "requestId"
                  ],
                  "properties": {
                    "recorded": {
                      "const": true
                    },
                    "requestId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "duplicate": {
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid enquiry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "field": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Use the website contact form from a browser.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "field": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Send JSON with Content-Type application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "field": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Wait for Retry-After or use the contact form.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "field": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "503": {
            "description": "Intake unavailable. Retry later with the same submission key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "field": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
