{
  "openapi": "3.0.3",
  "info": {
    "title": "Elektritööd Tallinnas enquiries",
    "version": "1.0.0",
    "description": "User-authorized electrical work enquiries. Obtain a cookie and token using GET, wait at least 2 seconds, then POST using the same cookie. Tokens expire after 7200 seconds. This is not a mail relay or booking API. Text-only JSON; use the HTML form for attachments. A successful response is mail-transport acceptance, not delivery. An uncertain result must be retried with the same normalized enquiry and token."
  },
  "servers": [
    {
      "url": "https://www.xn--elektritd-tallinnas-x6ba.ee"
    }
  ],
  "paths": {
    "/agent-enquiry.php": {
      "get": {
        "operationId": "getEnquiryToken",
        "summary": "Get form token and current requirements; sends no email",
        "responses": {
          "200": {
            "description": "Store session cookie and returned form_id/csrf_token. Cookie is HttpOnly, Secure, SameSite=Lax.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "form_id",
                    "csrf_token",
                    "min_wait_seconds",
                    "expires_in_seconds"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "form_id": {
                      "type": "string"
                    },
                    "csrf_token": {
                      "type": "string"
                    },
                    "min_wait_seconds": {
                      "type": "integer"
                    },
                    "expires_in_seconds": {
                      "type": "integer"
                    },
                    "fields": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After. Site-wide access protection can instead return text/plain before the JSON handler; honor the HTTP status and Retry-After in either case.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After. Site-wide access protection can instead return text/plain before the JSON handler; honor the HTTP status and Retry-After in either case.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Site-wide access block; no enquiry sent.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "sendElectricalWorkEnquiry",
        "summary": "Send an enquiry explicitly authorized by the user",
        "description": "Preserve the cookie from GET. Maximum body 65536 UTF-8 bytes, application/json. Unknown keys, recipient/header overrides and attachments are rejected. Same normalized enquiry + session/token does not resend. A used token with changed enquiry returns 409. No CORS browser access from other origins.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "form_id",
                  "csrf_token",
                  "name",
                  "phone",
                  "message",
                  "agent_name",
                  "on_behalf_of_user"
                ],
                "properties": {
                  "form_id": {
                    "type": "string",
                    "maxLength": 32,
                    "description": "Maximum 32 UTF-8 bytes; not characters.",
                    "pattern": "^[a-f0-9]{32}$"
                  },
                  "csrf_token": {
                    "type": "string",
                    "maxLength": 64,
                    "description": "Maximum 64 UTF-8 bytes; not characters.",
                    "pattern": "^[a-f0-9]{64}$"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 400,
                    "description": "Maximum 400 UTF-8 bytes; not characters."
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 160,
                    "description": "Maximum 160 UTF-8 bytes; not characters."
                  },
                  "email": {
                    "type": "string",
                    "maxLength": 320,
                    "description": "Maximum 320 UTF-8 bytes; not characters."
                  },
                  "area": {
                    "type": "string",
                    "maxLength": 800,
                    "description": "Maximum 800 UTF-8 bytes; not characters."
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 12000,
                    "description": "Maximum 12000 UTF-8 bytes; not characters."
                  },
                  "agent_name": {
                    "type": "string",
                    "maxLength": 160,
                    "description": "Maximum 160 UTF-8 bytes; not characters."
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "et",
                      "en",
                      "ru"
                    ],
                    "default": "et"
                  },
                  "website": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "default": ""
                  },
                  "on_behalf_of_user": {
                    "type": "boolean",
                    "enum": [
                      true
                    ],
                    "description": "User explicitly authorized sending this enquiry."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Mail transport accepted; does not confirm delivery. replayed=true means no additional send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "status",
                    "replayed",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ]
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After. Site-wide access protection can instead return text/plain before the JSON handler; honor the HTTP status and Retry-After in either case.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After. Site-wide access protection can instead return text/plain before the JSON handler; honor the HTTP status and Retry-After in either case.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Request rejected; no mail accepted for this request. Inspect code and Retry-After. Site-wide access protection can instead return text/plain before the JSON handler; honor the HTTP status and Retry-After in either case.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying; present on HTTP 429."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "code",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "sessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "PHPSESSID",
        "description": "Session cookie returned by GET. Also supply form_id and csrf_token in JSON. Follow the actual Set-Cookie name if server session settings differ."
      }
    }
  }
}
