{
 "openapi": "3.1.0",
 "info": {
  "title": "11.broker",
  "version": "1",
  "description": "Open and follow jobs at 11.broker. A job's key is sent as a bearer token."
 },
 "servers": [
  {
   "url": "https://11.broker"
  }
 ],
 "components": {
  "securitySchemes": {
   "jobKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "The key given when the job was opened, or the one in your private link."
   }
  }
 },
 "paths": {
  "/api/lines": {
   "get": {
    "summary": "The lines: what each takes and leaves, its steps and rules, and whether it is open.",
    "responses": {
     "200": {
      "description": "JSON"
     }
    }
   }
  },
  "/api/credentials": {
   "get": {
    "summary": "The credentials register: every license, its issuer and where it stands.",
    "responses": {
     "200": {
      "description": "JSON"
     }
    }
   }
  },
  "/api/jobs": {
   "post": {
    "summary": "Open a job. Answers with the job number and a key. The key is shown this once.",
    "responses": {
     "201": {
      "description": "The job number, the key and the address of the job's page."
     },
     "422": {
      "description": "What is wrong, field by field."
     },
     "429": {
      "description": "Too many requests from this address."
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "what",
         "name",
         "email"
        ],
        "properties": {
         "what": {
          "type": "string",
          "description": "What needs brokering, in a sentence or more (11 to 2,000 characters)."
         },
         "name": {
          "type": "string",
          "description": "Who the desk should answer."
         },
         "email": {
          "type": "string",
          "description": "Where the desk should answer."
         },
         "lines": {
          "type": "array",
          "items": {
           "type": "string"
          },
          "description": "Any of real-estate, insurance, animals, shipping, business, mortgages, vehicles, boats, produce, other. Left out, the description is read for them."
         },
         "role": {
          "type": "string",
          "description": "One of buyer, seller, both, unsure."
         },
         "where": {
          "type": "string",
          "description": "Where it is, or from where to where."
         },
         "when": {
          "type": "string",
          "description": "When it needs to happen."
         },
         "amount": {
          "type": "string",
          "description": "A price or a budget."
         },
         "otherSide": {
          "type": "string",
          "description": "Who is on the other side, if known."
         },
         "phone": {
          "type": "string",
          "description": "A phone number for the desk."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/jobs/{id}": {
   "get": {
    "summary": "The job as you may see it: stage, checklist, terms, signatures and the notes you may read.",
    "responses": {
     "200": {
      "description": "JSON"
     }
    },
    "security": [
     {
      "jobKey": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^11-[A-Z2-9]{6}$"
      },
      "description": "The job number."
     }
    ]
   }
  },
  "/api/jobs/{id}/notes": {
   "post": {
    "summary": "Write to the desk. Send {\"note\": \"...\"}. The other side does not see it.",
    "responses": {
     "200": {
      "description": "JSON"
     }
    },
    "security": [
     {
      "jobKey": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^11-[A-Z2-9]{6}$"
      },
      "description": "The job number."
     }
    ]
   }
  },
  "/api/jobs/{id}/sign": {
   "post": {
    "summary": "Sign the current terms. Send {\"version\", \"fingerprint\", \"name\", \"agree\": true}, and \"bothSides\": true when the broker acts for both sides.",
    "responses": {
     "200": {
      "description": "JSON"
     }
    },
    "security": [
     {
      "jobKey": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^11-[A-Z2-9]{6}$"
      },
      "description": "The job number."
     }
    ]
   }
  },
  "/api/jobs/{id}/withdraw": {
   "post": {
    "summary": "Withdraw a job you opened, before its terms are signed.",
    "responses": {
     "200": {
      "description": "JSON"
     }
    },
    "security": [
     {
      "jobKey": []
     }
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^11-[A-Z2-9]{6}$"
      },
      "description": "The job number."
     }
    ]
   }
  },
  "/api/health": {
   "get": {
    "summary": "Whether the site and its database answer.",
    "responses": {
     "200": {
      "description": "JSON"
     }
    }
   }
  }
 }
}