{
  "swagger": "2.0",
  "info": {
    "title": "Oomplo",
    "description": "Create PDF and Word documents from Oomplo templates filled with your data: one document per call or a series with one document per row, ready for SharePoint, OneDrive or e-mail.",
    "version": "1.0",
    "contact": {
      "name": "Oomplo",
      "url": "https://oomplo.com",
      "email": "hello@oomplo.com"
    }
  },
  "host": "oomplo.company.example",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "api_key": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization"
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "paths": {
    "/api/templates/{template}/render": {
      "post": {
        "operationId": "RenderDocument",
        "summary": "Create a document from a template",
        "description": "Fills a published template with the data and returns the PDF (or the filled Word document) as file content.",
        "parameters": [
          {
            "name": "template",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Template",
            "description": "The ID or the API name of a published template."
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "type": "object",
                  "x-ms-summary": "Data",
                  "description": "Your fields as JSON, e.g. the output of a previous step."
                },
                "format": {
                  "type": "string",
                  "enum": [
                    "pdf",
                    "docx"
                  ],
                  "default": "pdf",
                  "x-ms-summary": "Format",
                  "description": "PDF, or docx for the filled Word document."
                },
                "missing": {
                  "type": "string",
                  "enum": [
                    "error",
                    "empty"
                  ],
                  "default": "error",
                  "x-ms-summary": "Missing Values",
                  "x-ms-visibility": "advanced",
                  "description": "Error names every missing value; empty leaves them empty."
                },
                "version": {
                  "type": "integer",
                  "x-ms-summary": "Version",
                  "x-ms-visibility": "advanced",
                  "description": "A kept version instead of the published one."
                },
                "response": {
                  "type": "string",
                  "default": "json",
                  "x-ms-visibility": "internal",
                  "x-ms-summary": "Response",
                  "description": "The document as JSON with the file in base64."
                }
              },
              "required": [
                "data",
                "response"
              ]
            },
            "x-ms-summary": "Body",
            "description": "The request."
          }
        ],
        "responses": {
          "200": {
            "description": "The document",
            "schema": {
              "type": "object",
              "properties": {
                "file": {
                  "type": "string",
                  "format": "byte",
                  "x-ms-summary": "File Content",
                  "description": "The document, for a file or an attachment."
                },
                "fileName": {
                  "type": "string",
                  "x-ms-summary": "File Name",
                  "description": "A file name for the document."
                },
                "contentType": {
                  "type": "string",
                  "x-ms-summary": "Content Type",
                  "description": "The media type of the document."
                },
                "pages": {
                  "type": "integer",
                  "x-ms-summary": "Pages",
                  "description": "The number of pages of the PDF."
                },
                "warnings": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "x-ms-summary": "Warnings",
                  "description": "What the document shows simplified."
                }
              }
            }
          },
          "400": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          },
          "404": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          },
          "409": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          },
          "422": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          }
        }
      }
    },
    "/api/templates/{template}/validate": {
      "post": {
        "operationId": "ValidateData",
        "summary": "Check data for a template",
        "description": "Every missing value and every value of the wrong kind, without making a document.",
        "parameters": [
          {
            "name": "template",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Template",
            "description": "The ID or the API name of a published template."
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "type": "object",
                  "x-ms-summary": "Data",
                  "description": "Your fields as JSON, e.g. the output of a previous step."
                }
              },
              "required": [
                "data"
              ]
            },
            "x-ms-summary": "Body",
            "description": "The request."
          }
        ],
        "responses": {
          "200": {
            "description": "The report",
            "schema": {
              "type": "object",
              "properties": {
                "valid": {
                  "type": "boolean",
                  "x-ms-summary": "Valid",
                  "description": "Whether a document can be made from the data."
                },
                "missing": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "path": {
                        "type": "string",
                        "x-ms-summary": "Path",
                        "description": "The path of the value, e.g. client.name."
                      },
                      "row": {
                        "type": "integer",
                        "x-ms-summary": "Row",
                        "description": "The first element of an array without the value."
                      },
                      "count": {
                        "type": "integer",
                        "x-ms-summary": "Count",
                        "description": "How many elements do not have the value."
                      }
                    }
                  },
                  "x-ms-summary": "Missing Values",
                  "description": "Values the template needs and the data does not have."
                },
                "problems": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "path": {
                        "type": "string",
                        "x-ms-summary": "Path",
                        "description": "The path of the value."
                      },
                      "message": {
                        "type": "string",
                        "x-ms-summary": "Message",
                        "description": "What is wrong with the value."
                      }
                    }
                  },
                  "x-ms-summary": "Problems",
                  "description": "Values of the wrong kind."
                },
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "Why the template cannot be filled, if it cannot."
                }
              }
            }
          },
          "404": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          },
          "409": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          }
        }
      }
    },
    "/api/templates/{template}/schema": {
      "get": {
        "operationId": "GetTemplateSchema",
        "summary": "Get the data a template needs",
        "parameters": [
          {
            "name": "template",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Template",
            "description": "The ID or the API name of a published template."
          }
        ],
        "responses": {
          "200": {
            "description": "Fields, arrays, an example and a JSON Schema",
            "schema": {
              "type": "object",
              "properties": {
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  },
                  "x-ms-summary": "Fields",
                  "description": "The fields of the template."
                },
                "example": {
                  "type": "object",
                  "x-ms-summary": "Example",
                  "description": "Example data with every field."
                },
                "jsonSchema": {
                  "type": "object",
                  "x-ms-summary": "JSON Schema",
                  "description": "A JSON Schema of the data."
                }
              }
            }
          },
          "404": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          },
          "409": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          }
        },
        "description": "The fields and arrays a template needs, an example and a JSON Schema."
      }
    },
    "/api/templates/{template}/jobs": {
      "post": {
        "operationId": "StartSeries",
        "summary": "Start a series of documents",
        "description": "One document per row; the result is a ZIP or one PDF.",
        "parameters": [
          {
            "name": "template",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Template",
            "description": "The ID or the API name of a published template."
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "series": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "default": "dane1",
                      "x-ms-summary": "Data Source",
                      "description": "The data source of the template each row replaces."
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      },
                      "x-ms-summary": "Rows",
                      "description": "The rows as JSON objects, one document each."
                    }
                  },
                  "required": [
                    "name",
                    "rows"
                  ],
                  "x-ms-summary": "Series",
                  "description": "The rows and the data they replace."
                },
                "zip": {
                  "type": "boolean",
                  "default": true,
                  "x-ms-summary": "ZIP",
                  "description": "Whether to make a ZIP with a file per row instead of one PDF."
                },
                "label": {
                  "type": "string",
                  "x-ms-summary": "File Names",
                  "x-ms-visibility": "advanced",
                  "description": "A pattern of the file names with {{path}} of a row."
                },
                "format": {
                  "type": "string",
                  "enum": [
                    "pdf",
                    "docx"
                  ],
                  "default": "pdf",
                  "x-ms-summary": "Format",
                  "description": "PDF, or docx for a ZIP of filled Word documents."
                }
              },
              "required": [
                "series"
              ]
            },
            "x-ms-summary": "Body",
            "description": "The request."
          }
        ],
        "responses": {
          "202": {
            "description": "The job",
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "x-ms-summary": "Series ID",
                  "description": "The ID to follow the series with."
                },
                "state": {
                  "type": "string",
                  "x-ms-summary": "State",
                  "description": "Running at the start."
                },
                "total": {
                  "type": "integer",
                  "x-ms-summary": "Total",
                  "description": "The number of documents."
                }
              }
            }
          },
          "400": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          },
          "422": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          }
        }
      }
    },
    "/api/jobs/{id}": {
      "get": {
        "operationId": "GetSeries",
        "summary": "Get the state of a series",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Series ID",
            "description": "The ID Start a series of documents returned."
          }
        ],
        "responses": {
          "200": {
            "description": "The state",
            "schema": {
              "type": "object",
              "properties": {
                "state": {
                  "type": "string",
                  "x-ms-summary": "State",
                  "description": "Running, done or failed."
                },
                "done": {
                  "type": "integer",
                  "x-ms-summary": "Done",
                  "description": "The documents made so far."
                },
                "total": {
                  "type": "integer",
                  "x-ms-summary": "Total",
                  "description": "The number of documents."
                },
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "Why the series failed, with the row."
                }
              }
            }
          },
          "404": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          }
        },
        "description": "Whether the series is running, done or failed, and how far it is."
      }
    },
    "/api/jobs/{id}/result": {
      "get": {
        "operationId": "GetSeriesResult",
        "summary": "Get the result of a series",
        "produces": [
          "application/zip",
          "application/pdf"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Series ID",
            "description": "The ID Start a series of documents returned."
          }
        ],
        "responses": {
          "200": {
            "description": "The ZIP or PDF",
            "schema": {
              "type": "string",
              "format": "binary"
            }
          },
          "404": {
            "description": "An error with a message",
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "x-ms-summary": "Error",
                  "description": "The message of the error."
                }
              }
            }
          }
        },
        "description": "The ZIP or the PDF of a finished series."
      }
    }
  },
  "x-ms-connector-metadata": [
    {
      "propertyName": "Website",
      "propertyValue": "https://oomplo.com"
    },
    {
      "propertyName": "Privacy policy",
      "propertyValue": "https://oomplo.com/privacy/"
    },
    {
      "propertyName": "Categories",
      "propertyValue": "Content and Files;Productivity"
    }
  ]
}
