{
 "openapi": "3.1.0",
 "info": {
  "title": "Tender Desk free list requests",
  "version": "1.0.0",
  "summary": "Ask for the free Tender Desk list on someone's behalf.",
  "description": "For assistants and apps. Send the person's email, postcode and trade, plus your assistant's or app's name. We email the person a confirmation link and do nothing else until they confirm. Unconfirmed requests are deleted after 7 days. The response never contains the list or any personal details. Only send a request when the person has asked you to. Human docs: https://yourevenings.com/tender/for-assistants",
  "contact": {
   "name": "Your Evenings Ltd",
   "email": "hello@yourevenings.com",
   "url": "https://yourevenings.com/tender/for-assistants"
  },
  "termsOfService": "https://yourevenings.com/tender/terms"
 },
 "externalDocs": {
  "description": "Human docs",
  "url": "https://yourevenings.com/tender/for-assistants"
 },
 "servers": [
  {
   "url": "https://yourevenings.com"
  }
 ],
 "security": [],
 "paths": {
  "/tender/api/v1/free-list-requests": {
   "post": {
    "operationId": "requestFreeTenderList",
    "summary": "Request the free list for a person (they confirm by email)",
    "description": "The person gets an email from hello@yourevenings.com with the subject \"Please confirm your free tender list\". If they confirm, we email them up to three live UK public tenders within about an hour's drive of their postcode that fit their trade. If there are none, we tell them. Free. No key needed. Limits: 10 requests an hour per IP address; at most 3 confirmation emails per address in 7 days, at least 15 minutes apart; no new request for an address that asked in the last 7 days. Requests over those per-address limits get the same 202 reply and no email.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/FreeListRequest"
       },
       "examples": {
        "basic": {
         "value": {
          "email": "sam@example.co.uk",
          "postcode": "LS6 2AB",
          "trade": "Roofing",
          "assistant": "Example Assistant",
          "person_asked": true
         }
        },
        "other": {
         "value": {
          "email": "sam@example.co.uk",
          "postcode": "G12",
          "trade": "Something else",
          "trade_other": "Home care",
          "assistant": "Example App",
          "person_asked": true
         }
        }
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "Accepted. This is the only success reply, whether or not an email was sent this time.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Accepted"
        },
        "example": {
         "status": "confirmation_sent",
         "message": "We have sent, or recently sent, a confirmation email to this address, unless it already asked for the list in the last 7 days. Nothing else happens until the person confirms. Unconfirmed requests are deleted after 7 days.",
         "docs": "https://yourevenings.com/tender/for-assistants"
        }
       }
      }
     },
     "400": {
      "description": "A field is missing or not valid (invalid_field, with the field name) or the body is not a JSON object (invalid_json).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        },
        "example": {
         "error": "invalid_field",
         "field": "postcode",
         "message": "postcode must be a UK postcode, full (SW1A 1AA) or the first part (SW1A)."
        }
       }
      }
     },
     "405": {
      "description": "Use POST.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body over 4 KB.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "415": {
      "description": "Body must be application/json.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "email_not_accepted: a throwaway address, or a domain that cannot receive email.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        },
        "example": {
         "error": "email_not_accepted",
         "field": "email",
         "message": "Please use a permanent email address."
        }
       }
      }
     },
     "429": {
      "description": "rate_limited or busy. Wait for the Retry-After seconds.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "email_unavailable: we could not send the email just now. Nothing was saved. Try again after Retry-After seconds.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "FreeListRequest": {
    "type": "object",
    "additionalProperties": true,
    "required": [
     "email",
     "postcode",
     "trade",
     "assistant",
     "person_asked"
    ],
    "properties": {
     "email": {
      "type": "string",
      "format": "email",
      "maxLength": 120,
      "description": "The person's email address. We send the confirmation link here."
     },
     "postcode": {
      "type": "string",
      "maxLength": 12,
      "description": "The UK postcode the person works from, full (SW1A 1AA) or the first part (SW1A).",
      "examples": [
       "LS6 2AB",
       "G12"
      ]
     },
     "trade": {
      "type": "string",
      "enum": [
       "Building and maintenance",
       "Painting and decorating",
       "Roofing",
       "Heating and plumbing",
       "Electrical",
       "Groundworks and civils",
       "Grounds and landscaping",
       "Cleaning",
       "Facilities management",
       "Something else"
      ],
      "description": "The person's trade. Use Something else and fill in trade_other if none fits."
     },
     "trade_other": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9 ,_'&+()-]*$",
      "description": "Needed only when trade is Something else. What the person does, for example Home care."
     },
     "assistant": {
      "type": "string",
      "minLength": 1,
      "maxLength": 40,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9 _'&+()-]*$",
      "description": "The name of your assistant or app. We show it in the email so the person knows who asked. No links or dots."
     },
     "person_asked": {
      "type": "boolean",
      "const": true,
      "description": "Must be true. Only send a request when the person has asked you to."
     }
    }
   },
   "Accepted": {
    "type": "object",
    "required": [
     "status",
     "message"
    ],
    "properties": {
     "status": {
      "type": "string",
      "const": "confirmation_sent"
     },
     "message": {
      "type": "string"
     },
     "docs": {
      "type": "string",
      "format": "uri"
     }
    }
   },
   "Error": {
    "type": "object",
    "required": [
     "error",
     "message"
    ],
    "properties": {
     "error": {
      "type": "string",
      "enum": [
       "invalid_json",
       "invalid_field",
       "method_not_allowed",
       "too_large",
       "unsupported_media_type",
       "email_not_accepted",
       "rate_limited",
       "busy",
       "email_unavailable",
       "server_error"
      ]
     },
     "field": {
      "type": "string"
     },
     "message": {
      "type": "string"
     }
    }
   }
  }
 }
}