{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0.20241113",
    "title": "VinceLive API"
  },
  "host": "api.vince.live",
  "basePath": "/",
  "tags": [
    {
      "name": "Workflows",
      "description": "APIs to send and receive data from Vince Live"
    }
  ],
  "paths": {
    "/v1/custom-tables/data/{tableName}": {
      "get": {
        "tags": [
          "Custom Tables"
        ],
        "summary": "List or get data from custom table",
        "parameters": [
          {
            "$ref": "#/parameters/tableName"
          },
          {
            "$ref": "#/parameters/queryParamRecordId"
          },
          {
            "$ref": "#/parameters/queryParamBeginsWith"
          },
          {
            "$ref": "#/parameters/queryParamRecords"
          },
          {
            "$ref": "#/parameters/headerParamResponseTransformation"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "$ref": "#/definitions/ListCustomTableItems"
            }
          }
        }
      }
    },
    "/live/workflows/{workflowId}": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Send data to a workflow in VinceLive",
        "description": "Lets you send a file or string to a VinceLive workflow. You are here able to send various formats directly into the API, and it can be unstructured.",
        "operationId": "SendItemAPI",
        "consumes": [
          "application/json",
          "application/xml",
          "text/plain"
        ],
        "produces": [
          "application/json",
          "application/xml"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "description": "This is the workflowId from Vince Live",
            "required": true,
            "type": "string"
          },
          {
            "in": "body",
            "name": "body",
            "description": "Input document/data.",
            "required": false,
            "schema": {
              "$ref": "#/definitions/SampleWorkflow"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "string"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "type": "string"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "type": "string"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "type": "string"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "type": "string"
            }
          }
        }
      }
    },
    "/v1/custom-tables/search/{tableName}": {
      "get": {
        "tags": [
          "Custom Tables"
        ],
        "summary": "Search custom table index using simple query syntax",
        "description": "If you want to do a quick search using a simple query. Syntax described [here](https://opensearch.org/docs/latest/query-dsl/full-text/simple-query-string/)",
        "parameters": [
          {
            "$ref": "#/parameters/tableName"
          },
          {
            "$ref": "#/parameters/queryParamQuery"
          },
          {
            "$ref": "#/parameters/queryParamSize"
          },
          {
            "$ref": "#/parameters/queryParamFields"
          },
          {
            "$ref": "#/parameters/queryParamScrollMinutes"
          },
          {
            "$ref": "#/parameters/queryParamScrollId"
          },
          {
            "$ref": "#/parameters/headerParamResponseTransformation"
          },
          {
            "$ref": "#/parameters/queryParamComparisons"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "type": "string"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "type": "string"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "type": "string"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "post": {
        "tags": [
          "Custom Tables"
        ],
        "summary": "Search using OpenSearch query syntax",
        "description": "Allows for more complex OpenSearch queries against the index for the custom table. Please refer to the [OpenSearch documentation](https://opensearch.org/docs/latest/query-dsl/)\n\n## Stored scripts\nIt is possible to use the following stored scripts:\n\n-   `compare-fields`  Compare two fields with each other in the search, similar to SQL  `WHERE fieldA > fieldB`  syntax.\n\t``````JSON\n\t{\n\t  \"script\": {\n\t    \"script\": {\n\t      \"id\": \"compare-fields\",\n\t      \"params\": {\n\t        \"leftField\": \"deliveryDate\",\n\t        \"operator\": \">\",\n\t        \"rightField\": \"requestedDeliveryDate\"\n\t      }\n\t    }\n\t  }\n\t}\n```",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "tableName",
            "in": "path",
            "description": "This is the table name you want to search",
            "required": true,
            "type": "string"
          },
          {
            "in": "body",
            "name": "body",
            "description": "Input search payload",
            "required": true,
            "schema": {
              "$ref": "#/definitions/SampleSearch"
            }
          },
          {
            "name": "vl-response-transformation",
            "in": "header",
            "description": "Customize the response. Syntax described [here](https://vincesoftware.notion.site/Common-features-ef4b049863d9493fa03af2956df51a0c#35f32fe245d441818bde09b3e58828be).",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "type": "string"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "type": "string"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "type": "string"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "parameters": {
    "tableName": {
      "in": "path",
      "name": "tableName",
      "required": true,
      "type": "string",
      "description": "Custom table name"
    },
    "headerParamResponseTransformation": {
      "in": "header",
      "name": "vl-response-transformation",
      "required": false,
      "type": "string",
      "description": "JSONata expression to use for transforming results. **Note!** Transformation is performed *after* data hase been fetch from source."
    },
    "queryParamComparisons": {
      "in": "query",
      "name": "comparisons",
      "required": false,
      "type": "string",
      "description": "Used for comparing fields in a custom table. **Note!** Must be stringified array of _Comparison objects_.\n\n## Comparison object\n\nEach comparison is an object containing `leftField`, `operator` and `rightField` properties.\n```JSON\n{ \n\t\"leftField\": \"deliveryDate\", \n\t\"operator\": \">\", \n\t\"rightField\": \"requestedDeliveryDate\"\n}\n```\n## Available operators\n\nAvailable operators are: \n* `==` equals\n* `!=` not equals\n* `>` greater than\n* `<`: less than\n* `>=` greater than or equals\n* `<=` less than or equals\n\n## Examples\nSingle Comparison object wrapped in array: \n```JSON\n[\n\t{ \n\t\t\"leftField\": \"deliveryDate\", \n\t\t\"operator\": \">\", \n\t\t\"rightField\": \"requestedDeliveryDate\"\n\t}\n]\n```\n\nMultiple Comparison objects wrapped in array: \n```JSON\n[\n\t{ \n\t\t\"leftField\": \"deliveryDate\", \n\t\t\"operator\": \">\", \n\t\t\"rightField\": \"requestedDeliveryDate\"\n\t},\n\t{ \n\t\t\"leftField\": \"deliveredQuantity\", \n\t\t\"operator\": \"<\", \n\t\t\"rightField\": \"orderedQuantity\"\n\t}\n]\n```"
    },
    "queryParamQuery": {
      "in": "query",
      "name": "q",
      "required": false,
      "type": "string",
      "description": "Search query using simple query syntax. Syntax described [here](https://opensearch.org/docs/latest/query-dsl/full-text/simple-query-string/)."
    },
    "queryParamSize": {
      "in": "query",
      "name": "size",
      "required": false,
      "type": "integer",
      "minimum": 1,
      "maximum": 2000,
      "default": 1000,
      "description": "Number of records per page, used with parameter `q`. Min 1, max 2000, default 1000."
    },
    "queryParamFields": {
      "in": "query",
      "name": "fields",
      "required": false,
      "type": "integer",
      "description": "Comma separated list of field names to limit the search to."
    },
    "queryParamScrollMinutes": {
      "in": "query",
      "name": "scrollMinutes",
      "required": false,
      "type": "integer",
      "minimum": 1,
      "maximum": 60,
      "description": "Call without `scrollId` to initiate scrolling, data will be scrollable for *n* minutes. Min 1, max 60."
    },
    "queryParamScrollId": {
      "in": "query",
      "name": "scrollId",
      "required": false,
      "type": "string",
      "description": "Scroll ID, required after calling search endpoint with `scrollMinutes`."
    },
    "queryParamRecordId": {
      "in": "query",
      "name": "__id",
      "required": false,
      "type": "string",
      "description": "ID of record to get, when getting single record.\n\n**Note!** This overrides all other query parameters."
    },
    "queryParamBeginsWith": {
      "in": "query",
      "name": "beginsWith",
      "required": false,
      "type": "string",
      "description": "When present, filters on records where `primaryKeys` are prefixed with `beginsWith` value. Separate multiple primaryKeys with `#`. \n\n### Examples\nFor a table with `primaryKeys: ordNum, warehouse`\n\n *  `123` will return orders beginning with `123`. \n\n * `123456#ma` will return orders with number `123456` for warehouses starting with `ma`"
    },
    "queryParamRecords": {
      "in": "query",
      "name": "records",
      "required": false,
      "type": "string",
      "description": "When present, extracts only certain records.\n\nTakes a JSON-encoded string representing an array of records, where each record is an object with `primaryKey`s and value pairs.\n\n### Examples\n#### Single Record\n\n`[{ \"ItemNumber\": \"308\", \"Warehouse\": \"001\" }]`\n\n#### Multiple Records\n\n`[{ \"ItemNumber\": \"308\", \"Warehouse\": \"001\" },{ \"ItemNumber\": \"KK327\", \"Warehouse\": \"002\" }]`"
      
    }
  },
  "definitions": {
    "CustomTableItem": {
      "type": "object",
      "properties": {
        "__id": {
          "type": "string",
          "description": "Internal ID of the record",
          "readOnly": true
        },
        "__created": {
          "type": "string",
          "description": "Date and time of record creation",
          "readOnly": true
        },
        "__modified": {
          "type": "string",
          "description": "Date and time of record change",
          "readOnly": true
        },
        "__modifiedBy": {
          "type": "string",
          "description": "User ID of last change",
          "readOnly": true
        }
      },
      "additionalProperties": true,
      "example": {
        "__id": "skldjfakdsjhaskdjf",
        "__created": "2023-04-01T23:05:40Z",
        "__modified": "2023-04-03T23:08:40Z",
        "__modifiedBy": "USER-12312312003123123123123123123123",
        "ordNum": 12356600,
        "warehouse": "main",
        "value": 900
      }
    },
    "ListCustomTableItems": {
      "type": "object",
      "properties": {
        "count": {
          "type": "integer",
          "example": 1
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CustomTableItem"
          }
        },
        "scrollId": {
          "type": "string",
          "example": "rweqpuioewquiroieroioire"
        }
      },
      "required": [
        "count",
        "items"
      ]
    },
    "SampleWorkflow": {
      "type": "object",
      "properties": {
        "orderNo": {
          "type": "string",
          "example": "200015234"
        },
        "orderLines": {
          "type": "number",
          "example": 3
        }
      }
    },
    "SampleSearch": {
      "type": "object",
      "properties": {
        "size": {
          "type": "number",
          "example": 100
        },
        "from": {
          "type": "number",
          "example": 0
        },
        "query": {
          "type": "object",
          "example": {
            "bool": {
              "must": [
                {
                  "match": {
                    "myField": "RENTED"
                  }
                }
              ]
            }
          }
        }
      }
    }
  }
}