{
 "openapi": "3.1.0",
 "info": {
  "title": "Still Relevant Fax API",
  "version": "1.0.0",
  "description": "Prepare a fax to a US or Canadian number and get a payment link for a person. $2.49 per fax (up to 25 pages), charged only if delivered. No API key."
 },
 "servers": [
  {
   "url": "https://stillrelevant.uk"
  }
 ],
 "paths": {
  "/api/v1/faxes": {
   "post": {
    "operationId": "prepareFax",
    "summary": "Prepare a fax and get a pay_url",
    "description": "Converts the document to fax pages and returns a pay_url. Nothing is sent until a person pays at pay_url.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "to"
        ],
        "properties": {
         "to": {
          "type": "string",
          "description": "US or Canadian fax number, any format"
         },
         "file_url": {
          "type": "string",
          "format": "uri",
          "description": "Public https URL of the document"
         },
         "file_base64": {
          "type": "string",
          "description": "Document as base64"
         },
         "filename": {
          "type": "string",
          "description": "File name with extension, needed with file_base64"
         },
         "cover": {
          "$ref": "#/components/schemas/Cover"
         }
        }
       }
      },
      "multipart/form-data": {
       "schema": {
        "type": "object",
        "required": [
         "to",
         "file"
        ],
        "properties": {
         "to": {
          "type": "string"
         },
         "file": {
          "type": "string",
          "format": "binary"
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Prepared",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fax"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/api/fax/{id}": {
   "get": {
    "operationId": "getFax",
    "summary": "Check a fax",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Status",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fax"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Cover": {
    "type": "object",
    "properties": {
     "to": {
      "type": "string"
     },
     "from": {
      "type": "string"
     },
     "note": {
      "type": "string"
     }
    }
   },
   "Fax": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "ready",
       "paying",
       "queued",
       "sending",
       "retry",
       "delivered",
       "failed",
       "expired"
      ]
     },
     "pages": {
      "type": "integer"
     },
     "to": {
      "type": "string"
     },
     "price": {
      "type": "string"
     },
     "charged": {
      "type": "boolean"
     },
     "pay_url": {
      "type": "string"
     },
     "preview_url": {
      "type": "string"
     },
     "status_url": {
      "type": "string"
     },
     "confirmation_url": {
      "type": "string"
     },
     "reason": {
      "type": "string"
     },
     "note": {
      "type": "string"
     },
     "delivered_at": {
      "type": "string"
     }
    }
   }
  },
  "responses": {
   "Error": {
    "description": "Error",
    "content": {
     "application/json": {
      "schema": {
       "type": "object",
       "properties": {
        "error": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  }
 }
}