{
  "openapi": "3.1.0",
  "info": {
    "title": "Artemis Insights external API",
    "version": "1.74.0",
    "description": "Access to a company's data for integrations. Create an API key under Settings > API Keys and choose its scopes. Most endpoints are read-only. The exceptions are idempotent `PUT`s by your own id: vendors, customers and inventory item definitions; chemical regulatory data (`chemicals:regulatory:write`, always stored as unconfirmed until a person reviews it); and quality measurements (`quality:write`, write-once). Nothing can be deleted, and stock levels cannot be written. Changes can also be received as signed webhooks (Settings > Webhooks).\n\nSend the key as `X-API-Key: <key>` or `Authorization: Bearer <key>`. The original lists are newest first and capped at a fixed size (stated per endpoint); the vendor and inventory lists are paged with `limit` and `offset`."
  },
  "servers": [
    {
      "url": "/api/external",
      "description": "This install"
    }
  ],
  "tags": [
    {
      "name": "Data",
      "description": "Company data."
    }
  ],
  "paths": {
    "/receipts": {
      "get": {
        "summary": "List receipts",
        "description": "Up to the 500 most recent expense receipts.\n\nRequires the `receipts:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listReceipts",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "receipts:read",
        "responses": {
          "200": {
            "description": "The records, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Receipt"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/insights": {
      "get": {
        "summary": "List insights",
        "description": "Up to the 100 most recent insights the app has generated.\n\nRequires the `insights:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listInsights",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "insights:read",
        "responses": {
          "200": {
            "description": "The records, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Insight"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets": {
      "get": {
        "summary": "List tickets",
        "description": "Up to the 200 most recent support tickets.\n\nRequires the `tickets:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listTickets",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "tickets:read",
        "responses": {
          "200": {
            "description": "The records, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Ticket"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/reports": {
      "get": {
        "summary": "List daily reports",
        "description": "Up to the 90 most recent daily reports.\n\nRequires the `reports:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listDailyReports",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "reports:read",
        "responses": {
          "200": {
            "description": "The records, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DailyReport"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/vendors": {
      "get": {
        "summary": "List vendors",
        "description": "Vendors, ordered by name, 100 at a time. `externalId` is the id you wrote the record with, or null if it was not created through this API.\n\nRequires the `vendors:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listVendors",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "vendors:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Vendor"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/vendors/{externalId}": {
      "get": {
        "summary": "Get a vendor",
        "description": "The vendor you wrote under this `externalId`.\n\nRequires the `vendors:read` scope.",
        "operationId": "getAVendor",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "vendors:read",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Vendor"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Nothing has been written under that externalId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Create or update a vendor",
        "description": "Creates the vendor the first time this `externalId` is used and updates it afterwards, so a request can be repeated safely. Only the fields you send are changed. `name` is required; a vendor that already exists under that name is adopted, not duplicated.\n\nRequires the `vendors:write` scope. Limited per key to 120 requests a minute (EXTERNAL_WRITE_LIMIT_PER_MINUTE). Each change is recorded in the audit log against the API key and fires the matching webhook event with `source: \"api\"`.",
        "operationId": "createOrUpdateAVendor",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "vendors:write",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VendorInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The record existed and was updated, or was already as sent (`action` says which).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultVendor"
                }
              }
            }
          },
          "201": {
            "description": "The record was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultVendor"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid (see `issues`), or tries to set something that cannot be set through the API (such as `currentStock`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A value that must be unique (such as a barcode) is already used by another record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes for this key; retry shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/customers": {
      "get": {
        "summary": "List customers",
        "description": "Customers (the CRM's accounts), ordered by name, 100 at a time. `externalId` is the id you wrote the record with, or null if it was not created through this API.\n\nRequires the `customers:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listCustomers",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Customer"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/customers/{externalId}": {
      "get": {
        "summary": "Get a customer",
        "description": "The customer you wrote under this `externalId`.\n\nRequires the `customers:read` scope.",
        "operationId": "getACustomer",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Nothing has been written under that externalId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Create or update a customer",
        "description": "Creates the customer the first time this `externalId` is used and updates it afterwards, so a request can be repeated safely. Only the fields you send are changed. `name` is required; a customer that already exists under that name is adopted, not duplicated.\n\nRequires the `customers:write` scope. Limited per key to 120 requests a minute (EXTERNAL_WRITE_LIMIT_PER_MINUTE). Each change is recorded in the audit log against the API key and fires the matching webhook event with `source: \"api\"`.",
        "operationId": "createOrUpdateACustomer",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "customers:write",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The record existed and was updated, or was already as sent (`action` says which).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultCustomer"
                }
              }
            }
          },
          "201": {
            "description": "The record was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultCustomer"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid (see `issues`), or tries to set something that cannot be set through the API (such as `currentStock`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A value that must be unique (such as a barcode) is already used by another record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes for this key; retry shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/inventory-items": {
      "get": {
        "summary": "List inventory items",
        "description": "Inventory item definitions with their current stock (read-only), ordered by SKU, 100 at a time.\n\nRequires the `inventory:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listInventoryItems",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "inventory:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InventoryItem"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/inventory-items/{externalId}": {
      "get": {
        "summary": "Get an inventory item",
        "description": "The item you wrote under this `externalId`, including its current stock.\n\nRequires the `inventory:read` scope.",
        "operationId": "getAnInventoryItem",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "inventory:read",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryItem"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Nothing has been written under that externalId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Create or update an inventory item",
        "description": "Creates or updates an item DEFINITION (name, SKU, cost, reorder point...). Only the fields you send are changed; `sku` and `name` are required, and an item that already has that SKU is adopted. **Stock levels cannot be written**: they change only through inventory movements, which keep the history intact, and sending `currentStock` is refused.\n\nRequires the `inventory:write` scope. Limited per key to 120 requests a minute (EXTERNAL_WRITE_LIMIT_PER_MINUTE). Each change is recorded in the audit log against the API key and fires the matching webhook event with `source: \"api\"`.",
        "operationId": "createOrUpdateAnInventoryItem",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "inventory:write",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryItemInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The record existed and was updated, or was already as sent (`action` says which).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultInventoryItem"
                }
              }
            }
          },
          "201": {
            "description": "The record was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultInventoryItem"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid (see `issues`), or tries to set something that cannot be set through the API (such as `currentStock`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A value that must be unique (such as a barcode) is already used by another record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes for this key; retry shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chemicals": {
      "get": {
        "summary": "List chemicals",
        "description": "Chemical products with their GHS, transport and regulatory fields, and Japan compliance values when recorded, ordered by name. `regulatoryDataSource` is set when an integration supplied the values and no person has confirmed them yet. Requires the company's Chemical Inventory module; a company without it gets 403.\n\nRequires the `chemicals:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listChemicals",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "chemicals:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "cas",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only the chemical with this CAS number."
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only records updated at or after this time - for incremental syncs."
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Chemical"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chemicals/{externalId}": {
      "get": {
        "summary": "Get a chemical",
        "description": "The chemical you wrote under this `externalId`.\n\nRequires the `chemicals:read` scope.",
        "operationId": "getAChemical",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "chemicals:read",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Chemical"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Nothing has been written under that externalId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Create or update a chemical's regulatory data",
        "description": "For SDS and regulatory-data providers. Creates the chemical the first time this `externalId` is used, adopting an existing one with the same CAS number or name instead of duplicating it, and updates it afterwards. Only the fields you send are changed. Optional `japan` sets Japanese compliance values (ISHA, PRTR, PDSCL, CSCL, Fire Service Act).\n\n**Values written here are never treated as confirmed.** They are stored with the source `integration: <key name>`, Japan compliance confirmation is cleared, and the app shows them as supplied by an integration until a person reviews and saves them. This app never decides whether a substance is regulated, and neither does an integration on its behalf. Fires `chemical.regulatory_updated`.\n\nRequires the `chemicals:regulatory:write` scope. Limited per key to 120 requests a minute (EXTERNAL_WRITE_LIMIT_PER_MINUTE). Each change is recorded in the audit log against the API key and fires the matching webhook event with `source: \"api\"`.",
        "operationId": "createOrUpdateAChemicalSRegulatoryData",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "chemicals:regulatory:write",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChemicalInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The record existed and was updated, or was already as sent (`action` says which).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultChemical"
                }
              }
            }
          },
          "201": {
            "description": "The record was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultChemical"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid (see `issues`), or tries to set something that cannot be set through the API (such as `currentStock`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Another chemical already uses that name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes for this key; retry shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chemical-lots": {
      "get": {
        "summary": "List chemical lots",
        "description": "Received chemical lots with quantity on hand, dates and storage location, newest first. Requires the company's Chemical Inventory module; a company without it gets 403.\n\nRequires the `chemicals:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listChemicalLots",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "chemicals:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only records with this status."
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only records updated at or after this time - for incremental syncs."
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChemicalLot"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/production-batches": {
      "get": {
        "summary": "List production batches",
        "description": "Batches produced from formulas, newest first. Requires the company's Chemical Inventory module; a company without it gets 403.\n\nRequires the `chemicals:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listProductionBatches",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "chemicals:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only records produced at or after this time - for incremental syncs."
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProductionBatch"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/work-orders": {
      "get": {
        "summary": "List work orders",
        "description": "Work orders with their bill of materials and equipment, newest first. Requires the company's Manufacturing module; a company without it gets 403.\n\nRequires the `manufacturing:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listWorkOrders",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "manufacturing:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only records with this status."
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only records created, started or completed at or after this time - for incremental syncs."
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkOrder"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/work-orders/{workOrderId}/oee": {
      "get": {
        "summary": "Get a work order's OEE",
        "description": "Availability, performance, quality and OEE for a completed work order, computed exactly as the app computes them (recorded downtime, quantity produced, non-conformance quantities). `oee` is null with a `reason` when it can't be computed.\n\nRequires the `manufacturing:read` scope. Requires the company's Manufacturing module; a company without it gets 403.",
        "operationId": "getAWorkOrdersOee",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "manufacturing:read",
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The work order's id (from List work orders)."
          }
        ],
        "responses": {
          "200": {
            "description": "The figures (fractions from 0 to 1).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Oee"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No work order with that id in this company.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/equipment": {
      "get": {
        "summary": "List equipment",
        "description": "Machines and lines, ordered by name. Requires the company's Manufacturing module; a company without it gets 403.\n\nRequires the `manufacturing:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listEquipment",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "manufacturing:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Equipment"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quality-characteristics": {
      "get": {
        "summary": "List quality characteristics",
        "description": "What gets measured (dimension, pH, viscosity...) with its spec limits - use an `id` from here as `characteristicId` when recording measurements. Requires the company's Manufacturing module; a company without it gets 403.\n\nRequires the `quality:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listQualityCharacteristics",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "quality:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QualityCharacteristic"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quality-measurements": {
      "get": {
        "summary": "List quality measurements",
        "description": "Recorded measurements, newest first. Requires the company's Manufacturing module; a company without it gets 403.\n\nRequires the `quality:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listQualityMeasurements",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "quality:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "characteristicId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only records measured at or after this time - for incremental syncs."
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QualityMeasurement"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quality-measurements/{externalId}": {
      "put": {
        "summary": "Record a quality measurement",
        "description": "For plant-floor systems (SCADA/MES, test benches, an Ignition gateway). Records one reading under your own id, so a retry after a timeout is safe. **Measurements are write-once:** sending the same `externalId` with the same values returns `unchanged`; sending it with different values is refused with 409 rather than rewriting history behind the SPC charts. Recorded under the admin who created the API key. Fires `quality_measurement.recorded`, and `quality_measurement.out_of_spec` when the value is outside the characteristic's spec limits.\n\nRequires the `quality:write` scope. Limited per key to 120 requests a minute (EXTERNAL_WRITE_LIMIT_PER_MINUTE). Each change is recorded in the audit log against the API key and fires the matching webhook event with `source: \"api\"`.",
        "operationId": "recordAQualityMeasurement",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "quality:write",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "Your own id for the record (letters, digits and . _ : @ - only, up to 200 characters).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:@-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QualityMeasurementInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The record existed and was updated, or was already as sent (`action` says which).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultQualityMeasurement"
                }
              }
            }
          },
          "201": {
            "description": "The record was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpsertResultQualityMeasurement"
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid (see `issues`), or tries to set something that cannot be set through the API (such as `currentStock`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A different measurement was already recorded under this externalId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes for this key; retry shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/non-conformance-reports": {
      "get": {
        "summary": "List non-conformance reports",
        "description": "NCRs with severity, status and disposition, newest first. Requires the company's Quality module; a company without it gets 403.\n\nRequires the `quality:read` scope. Results are limited to the company the key belongs to.",
        "operationId": "listNonConformanceReports",
        "security": [
          {
            "ApiKeyHeader": []
          },
          {
            "BearerKey": []
          }
        ],
        "x-required-scope": "quality:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only records with this status."
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only records created at or after this time - for incremental syncs."
          }
        ],
        "responses": {
          "200": {
            "description": "One page of records. `X-Total-Count` is how many exist in all.",
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-Offset": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NonConformanceReport"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, wrong, or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key is valid but does not have this endpoint's scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "BearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "The API key itself, sent as a bearer token."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Receipt": {
        "type": "object",
        "required": [
          "id",
          "currency",
          "approvalStatus",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "vendorName": {
            "type": [
              "string",
              "null"
            ]
          },
          "purchaseDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "description": "In the receipt's currency units, not cents."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 code."
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "approvalStatus": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "rejected"
            ]
          },
          "employeeEmail": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who submitted it."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Insight": {
        "type": "object",
        "required": [
          "id",
          "tenantId",
          "domain",
          "severity",
          "title",
          "description",
          "suggestedAction",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "tenantId": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "severity": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "suggestedAction": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Ticket": {
        "type": "object",
        "required": [
          "id",
          "subject",
          "status",
          "priority",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "priority": {
            "type": "string"
          },
          "reporterEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Vendor": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "contactName": {
            "type": [
              "string",
              "null"
            ]
          },
          "contactEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "contactPhone": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "VendorInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "category": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100
          },
          "contactName": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "contactEmail": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "maxLength": 200
          },
          "contactPhone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 60
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000
          }
        }
      },
      "Customer": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "industry": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CustomerInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "industry": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "website": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 5000
          }
        }
      },
      "UpsertResultCustomer": {
        "type": "object",
        "required": [
          "externalId",
          "action",
          "record"
        ],
        "properties": {
          "externalId": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "unchanged"
            ]
          },
          "record": {
            "$ref": "#/components/schemas/Customer"
          }
        }
      },
      "InventoryItem": {
        "type": "object",
        "required": [
          "id",
          "sku",
          "name",
          "currentStock"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "sku": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "unitCostCents": {
            "type": "integer"
          },
          "sellPriceCents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "barcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "leadTimeDays": {
            "type": [
              "integer",
              "null"
            ]
          },
          "reorderPoint": {
            "type": "integer"
          },
          "reorderQuantity": {
            "type": [
              "integer",
              "null"
            ]
          },
          "location": {
            "type": [
              "string",
              "null"
            ]
          },
          "currentStock": {
            "type": "integer",
            "description": "Read-only: changes only through inventory movements."
          }
        }
      },
      "InventoryItemInput": {
        "type": "object",
        "required": [
          "sku",
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "sku": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000
          },
          "category": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100
          },
          "unitCostCents": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "sellPriceCents": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "barcode": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100
          },
          "leadTimeDays": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "reorderPoint": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "reorderQuantity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          }
        }
      },
      "UpsertResultVendor": {
        "type": "object",
        "required": [
          "externalId",
          "action",
          "record"
        ],
        "properties": {
          "externalId": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "unchanged"
            ]
          },
          "record": {
            "$ref": "#/components/schemas/Vendor"
          }
        }
      },
      "UpsertResultInventoryItem": {
        "type": "object",
        "required": [
          "externalId",
          "action",
          "record"
        ],
        "properties": {
          "externalId": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "unchanged"
            ]
          },
          "record": {
            "$ref": "#/components/schemas/InventoryItem"
          }
        }
      },
      "Chemical": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "casNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "manufacturer": {
            "type": [
              "string",
              "null"
            ]
          },
          "ghsHazardClasses": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ghsSignalWord": {
            "type": [
              "string",
              "null"
            ]
          },
          "ghsPictograms": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "hazardStatements": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "precautionaryStatements": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "dotHazardClass": {
            "type": [
              "string",
              "null"
            ]
          },
          "unNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "properShippingName": {
            "type": [
              "string",
              "null"
            ]
          },
          "packingGroup": {
            "type": [
              "string",
              "null"
            ]
          },
          "sdsUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "sdsVerifiedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "storageClass": {
            "type": [
              "string",
              "null"
            ]
          },
          "requiredPpe": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "epaReportingThreshold": {
            "type": [
              "number",
              "null"
            ]
          },
          "isExtremelyHazardousSubstance": {
            "type": "boolean"
          },
          "isTriListed": {
            "type": "boolean"
          },
          "reportingUnit": {
            "type": "string"
          },
          "tscaInventoryStatus": {
            "type": [
              "string",
              "null"
            ]
          },
          "reachRegistrationNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "regulatoryDataSource": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set when an integration supplied the hazard/regulatory values and no person has confirmed them yet."
          },
          "regulatoryDataUpdatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "japanCompliance": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/JapanCompliance"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "JapanCompliance": {
        "type": "object",
        "properties": {
          "ishaLabelSdsRequired": {
            "type": "boolean"
          },
          "ishaRiskAssessmentRequired": {
            "type": "boolean"
          },
          "prtrClass": {
            "type": [
              "string",
              "null"
            ]
          },
          "prtrReportingThreshold": {
            "type": [
              "number",
              "null"
            ]
          },
          "prtrReportingUnit": {
            "type": "string"
          },
          "pdsclClassification": {
            "type": [
              "string",
              "null"
            ]
          },
          "fireServiceActCategory": {
            "type": [
              "string",
              "null"
            ]
          },
          "fireServiceActDesignatedQuantityKg": {
            "type": [
              "number",
              "null"
            ]
          },
          "fireServiceActDesignatedQuantityUnit": {
            "type": "string"
          },
          "csclStatus": {
            "type": [
              "string",
              "null"
            ]
          },
          "verifiedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When a person last confirmed these values in the app; null if not (including after an integration wrote them)."
          },
          "dataSource": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ChemicalInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "casNumber": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{2,7}-\\d{2}-\\d$"
          },
          "manufacturer": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "ghsHazardClasses": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 200
            },
            "maxItems": 20
          },
          "ghsSignalWord": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "Danger",
              "Warning",
              null
            ]
          },
          "ghsPictograms": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 50
            },
            "maxItems": 20
          },
          "hazardStatements": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500
            },
            "maxItems": 30
          },
          "precautionaryStatements": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500
            },
            "maxItems": 30
          },
          "tscaInventoryStatus": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "listed",
              "not_listed",
              "exempt",
              "unknown",
              null
            ]
          },
          "reachRegistrationNumber": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100
          },
          "dotHazardClass": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 20
          },
          "unNumber": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 20
          },
          "properShippingName": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "packingGroup": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "I",
              "II",
              "III",
              null
            ]
          },
          "sdsUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 1000,
            "description": "http or https only."
          },
          "storageClass": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "flammable",
              "oxidizer",
              "corrosive_acid",
              "corrosive_base",
              "toxic",
              "reactive",
              "inert",
              "other",
              null
            ]
          },
          "requiredPpe": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 200
            },
            "maxItems": 20
          },
          "isExtremelyHazardousSubstance": {
            "type": "boolean"
          },
          "isTriListed": {
            "type": "boolean"
          },
          "japan": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "ishaLabelSdsRequired": {
                "type": "boolean"
              },
              "ishaRiskAssessmentRequired": {
                "type": "boolean"
              },
              "prtrClass": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "specified_class_1",
                  "class_1",
                  "class_2",
                  null
                ]
              },
              "prtrReportingThreshold": {
                "type": [
                  "number",
                  "null"
                ],
                "exclusiveMinimum": 0
              },
              "prtrReportingUnit": {
                "type": "string",
                "maxLength": 20
              },
              "pdsclClassification": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "poisonous",
                  "deleterious",
                  null
                ]
              },
              "csclStatus": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "encs_existing",
                  "new_chemical_substance",
                  "monitoring",
                  "priority_assessment",
                  "class_1_specified",
                  "class_2_specified",
                  null
                ]
              },
              "fireServiceActCategory": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "1",
                  "2",
                  "3",
                  "4",
                  "5",
                  "6",
                  null
                ]
              },
              "fireServiceActDesignatedQuantityKg": {
                "type": [
                  "number",
                  "null"
                ],
                "exclusiveMinimum": 0,
                "description": "The designated quantity, in fireServiceActDesignatedQuantityUnit."
              },
              "fireServiceActDesignatedQuantityUnit": {
                "type": "string",
                "enum": [
                  "kg",
                  "L"
                ],
                "description": "L for Class 4 flammable liquids, kg otherwise."
              }
            }
          }
        }
      },
      "UpsertResultChemical": {
        "type": "object",
        "required": [
          "externalId",
          "action",
          "record"
        ],
        "properties": {
          "externalId": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "unchanged"
            ]
          },
          "record": {
            "$ref": "#/components/schemas/Chemical"
          }
        }
      },
      "ChemicalLot": {
        "type": "object",
        "required": [
          "id",
          "productId",
          "lotNumber",
          "quantity",
          "unitOfMeasure",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "productId": {
            "type": "string"
          },
          "lotNumber": {
            "type": "string"
          },
          "barcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "quantity": {
            "type": "number"
          },
          "unitOfMeasure": {
            "type": "string"
          },
          "receivedDate": {
            "type": "string",
            "format": "date-time"
          },
          "expirationDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "retestDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "supplierName": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "storageLocation": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        }
      },
      "ProductionBatch": {
        "type": "object",
        "required": [
          "id",
          "batchNumber",
          "finishedProductName",
          "producedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "batchNumber": {
            "type": "string"
          },
          "finishedProductName": {
            "type": "string"
          },
          "finishedProductId": {
            "type": [
              "string",
              "null"
            ]
          },
          "formulaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "quantityProduced": {
            "type": [
              "number",
              "null"
            ]
          },
          "unitOfMeasure": {
            "type": [
              "string",
              "null"
            ]
          },
          "producedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WorkOrder": {
        "type": "object",
        "required": [
          "id",
          "status",
          "quantityPlanned",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "quantityPlanned": {
            "type": "integer"
          },
          "quantityProduced": {
            "type": [
              "integer",
              "null"
            ]
          },
          "scheduledStart": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "startedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "bom": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "equipment": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        }
      },
      "Oee": {
        "type": "object",
        "properties": {
          "oee": {
            "type": [
              "number",
              "null"
            ]
          },
          "availability": {
            "type": [
              "number",
              "null"
            ]
          },
          "performance": {
            "type": [
              "number",
              "null"
            ]
          },
          "quality": {
            "type": [
              "number",
              "null"
            ]
          },
          "runTimeMinutes": {
            "type": "number"
          },
          "downtimeMinutes": {
            "type": "number"
          },
          "reason": {
            "type": "string",
            "description": "Why OEE is null, when it is."
          }
        }
      },
      "Equipment": {
        "type": "object",
        "required": [
          "id",
          "name",
          "equipmentType",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "equipmentType": {
            "type": "string"
          },
          "serialNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "location": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "availableHoursPerDay": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      },
      "QualityCharacteristic": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "upperSpecLimit": {
            "type": [
              "number",
              "null"
            ]
          },
          "lowerSpecLimit": {
            "type": [
              "number",
              "null"
            ]
          },
          "bomId": {
            "type": [
              "string",
              "null"
            ]
          },
          "equipmentId": {
            "type": [
              "string",
              "null"
            ]
          },
          "formulaId": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "QualityMeasurement": {
        "type": "object",
        "required": [
          "id",
          "characteristicId",
          "value",
          "measuredAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "characteristicId": {
            "type": "string"
          },
          "value": {
            "type": "number"
          },
          "measuredAt": {
            "type": "string",
            "format": "date-time"
          },
          "workOrderId": {
            "type": [
              "string",
              "null"
            ]
          },
          "productionBatchId": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "QualityMeasurementInput": {
        "type": "object",
        "required": [
          "characteristicId",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "characteristicId": {
            "type": "string",
            "description": "An id from List quality characteristics."
          },
          "value": {
            "type": "number"
          },
          "measuredAt": {
            "type": "string",
            "format": "date-time",
            "description": "Defaults to now."
          },
          "workOrderId": {
            "type": "string"
          },
          "productionBatchId": {
            "type": "string"
          }
        }
      },
      "UpsertResultQualityMeasurement": {
        "type": "object",
        "required": [
          "externalId",
          "action",
          "record"
        ],
        "properties": {
          "externalId": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "created",
              "unchanged"
            ]
          },
          "record": {
            "$ref": "#/components/schemas/QualityMeasurement"
          }
        }
      },
      "NonConformanceReport": {
        "type": "object",
        "required": [
          "id",
          "title",
          "severity",
          "status",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "severity": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "disposition": {
            "type": [
              "string",
              "null"
            ]
          },
          "quantityAffected": {
            "type": [
              "number",
              "null"
            ]
          },
          "workOrderId": {
            "type": [
              "string",
              "null"
            ]
          },
          "itemId": {
            "type": [
              "string",
              "null"
            ]
          },
          "vendorId": {
            "type": [
              "string",
              "null"
            ]
          },
          "rootCause": {
            "type": [
              "string",
              "null"
            ]
          },
          "correctiveAction": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "resolvedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "DailyReport": {
        "type": "object",
        "required": [
          "id",
          "date",
          "content"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "content": {
            "type": "string",
            "description": "The report text."
          }
        }
      }
    }
  }
}
