{
  "openapi": "3.0.2",
  "servers": [{ "url": "https://apis.<domain>" }],
  "info": {
    "version": "1.4.0",
    "title": "connhex-manufacturing",
    "description": "The following is the default **ConnhexJSON Schema** provided out ouf the box for Connhex Manufacturing:\n\n\n### Device\n```json\n{\n  \"$id\": \"https://connhex.com/device.schema.json\",\n  \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"deviceType\": {\n      \"type\": \"string\",\n      \"title\": \"Device Type\"\n    },\n    \"connhexId\": {\n      \"type\": \"string\",\n      \"title\": \"Connhex ID\"\n    },\n    \"pcbPartNumber\": {\n      \"type\": \"string\",\n      \"title\": \"Pcb Part Number\"\n    },\n    \"fwVersion\": {\n      \"type\": \"string\",\n      \"title\": \"FW Version\"\n    },\n    \"partNumber\": {\n      \"type\": \"string\",\n      \"title\": \"Part Number\"\n    },\n    \"serialNumber\": {\n      \"type\": \"string\",\n      \"title\": \"Serial Number\"\n    },\n    \"workOrder\": {\n      \"type\": \"string\",\n      \"title\": \"Work Order\"\n    },\n    \"productionOrder\": {\n      \"type\": \"string\",\n      \"title\": \"production_order\"\n    },\n    \"palletId\": {\n      \"type\": \"string\",\n      \"title\": \"Pallet ID\"\n    },\n    \"packageId\": {\n      \"type\": \"string\",\n      \"title\": \"Package ID\"\n    },\n  }\n}\n```\n\n#### Tenants\n\nEvery device schema must include a `tenants` field (`string[]`). This field is **required by the platform** to support multi-tenancy:\n\n- **On read / list**: results are automatically scoped to devices belonging to the caller's authorized tenants.\n- **On create**: if `tenants` is not provided in the request body, the device is automatically assigned to the caller's authorized tenants. If provided, the value is intersected with the caller's authorized tenants.\n- **On update**: the `tenants` field can be updated to reassign a device to different tenants (within the caller's authorized set).\n"
  },
  "paths": {
    "/manufacturing/devices/": {
      "get": {
        "tags": ["Devices"],
        "description": "List manufactured devices.\n\nRequired Permission:\n\n - Resource: ```manufacturnig:devices```\n\n - Action: ```manufacturing:devices:list```",
        "operationId": "List devices",
        "parameters": [
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/fields"
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/filter"
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/include"
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/page[limit]"
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/page[offset]"
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/sort"
          }
        ],
        "responses": {
          "200": {
            "description": "list",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Device"
                      }
                    },
                    "included": {
                      "type": "array",
                      "uniqueItems": true,
                      "items": {
                        "$ref": "#/components/schemas/resource"
                      }
                    },
                    "links": {
                      "description": "Link members related to primary data",
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/links"
                        },
                        {
                          "$ref": "#/components/schemas/pagination"
                        }
                      ]
                    },
                    "jsonapi": {
                      "$ref": "#/components/schemas/jsonapi"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not authorized",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Devices"],
        "description": "Create devices.\n\nRequired Permission:\n\n - Resource: ```manufacturing:devices```\n\n - Action: ```manufacturing:devices:create```",
        "operationId": "Create devices",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/vnd.api+json": {
              "schema": {
                "required": ["data"],
                "properties": {
                  "data": {
                    "type": "object",
                    "required": ["type"],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "$ref": "#/components/schemas/type"
                      },
                      "id": {
                        "$ref": "#/components/schemas/id"
                      },
                      "links": {
                        "type": "object",
                        "properties": {
                          "self": {
                            "$ref": "#/components/schemas/link"
                          }
                        }
                      },
                      "attributes": {
                        "type": "object",
                        "properties": {
                          "pcbPartNumber": {
                            "type": "string"
                          },
                          "deviceType": {
                            "type": "string"
                          },
                          "fwVersion": {
                            "type": "string"
                          },
                          "partNumber": {
                            "type": "string"
                          },
                          "serialNumber": {
                            "type": "string"
                          },
                          "packageId": {
                            "type": "string"
                          },
                          "palletId": {
                            "type": "string"
                          },
                          "productionOrder": {
                            "type": "string"
                          },
                          "workOrder": {
                            "type": "string"
                          },
                          "connhexId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date"
                          },
                          "deletedAt": {
                            "type": "string",
                            "format": "date"
                          },
                          "tenants": {
                            "type": "array",
                            "items": { "type": "string" },
                            "description": "Tenant IDs to assign to this device. Filtered to the caller's authorized tenants. Defaults to caller's tenants if omitted."
                          }
                        },
                        "required": ["serialNumber", "connhexId"]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "[Created](https://jsonapi.org/format/#crud-creating-responses-201). Assigned `id` and/or any other changes are in this response.",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Device"
                    },
                    "included": {
                      "type": "array",
                      "uniqueItems": true,
                      "items": {
                        "$ref": "#/components/schemas/resource"
                      }
                    },
                    "links": {
                      "description": "Link members related to primary data",
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/links"
                        },
                        {
                          "$ref": "#/components/schemas/pagination"
                        }
                      ]
                    },
                    "jsonapi": {
                      "$ref": "#/components/schemas/jsonapi"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted for [asynchronous processing](https://jsonapi.org/recommendations/#asynchronous-processing)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/datum"
                }
              }
            }
          },
          "204": {
            "description": "[Created](https://jsonapi.org/format/#crud-creating-responses-204) with the supplied `id`. No other changes from what was POSTed."
          },
          "401": {
            "description": "not authorized",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "403": {
            "description": "[Forbidden](https://jsonapi.org/format/#crud-creating-responses-403)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "404": {
            "description": "[Related resource does not exist](https://jsonapi.org/format/#crud-creating-responses-404)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "409": {
            "description": "[Conflict](https://jsonapi.org/format/#crud-creating-responses-409)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          }
        }
      }
    },
    "/manufacturing/devices/{ids}/": {
      "get": {
        "tags": ["Devices"],
        "description": "Get device.\n\nRequired Permission:\n\n - Resource: ```manufacturing:devices:{id}```\n\n - Action: ```manufacturing:devices:get```",
        "operationId": "Read device",
        "parameters": [
          {
            "name": "ids",
            "in": "path",
            "required": true,
            "description": "Comma-separated globally unique ids (UUID4)",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/fields"
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/include"
          },
          {
            "$ref": "../../common.json#/components/jsonApi/parameters/sort"
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Device"
                    },
                    "included": {
                      "type": "array",
                      "uniqueItems": true,
                      "items": {
                        "$ref": "#/components/schemas/resource"
                      }
                    },
                    "links": {
                      "description": "Link members related to primary data",
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/links"
                        },
                        {
                          "$ref": "#/components/schemas/pagination"
                        }
                      ]
                    },
                    "jsonapi": {
                      "$ref": "#/components/schemas/jsonapi"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not authorized",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["Devices"],
        "description": "Update device.\n\nRequired Permission:\n\n - Resource: ```manufacturing:devices:{id}```\n\n - Action: ```manufacturing:devices:update```",
        "operationId": "Update device",
        "parameters": [
          {
            "name": "ids",
            "in": "path",
            "required": true,
            "description": "Comma-separated globally unique ids (UUID4)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/vnd.api+json": {
              "schema": {
                "required": ["data"],
                "properties": {
                  "data": {
                    "type": "object",
                    "required": ["type", "id"],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "$ref": "#/components/schemas/type"
                      },
                      "id": {
                        "$ref": "#/components/schemas/id"
                      },
                      "links": {
                        "type": "object",
                        "properties": {
                          "self": {
                            "$ref": "#/components/schemas/link"
                          }
                        }
                      },
                      "attributes": {
                        "type": "object",
                        "properties": {
                          "pcbPartNumber": {
                            "type": "string"
                          },
                          "deviceType": {
                            "type": "string"
                          },
                          "fwVersion": {
                            "type": "string"
                          },
                          "partNumber": {
                            "type": "string"
                          },
                          "serialNumber": {
                            "type": "string"
                          },
                          "packageId": {
                            "type": "string"
                          },
                          "palletId": {
                            "type": "string"
                          },
                          "productionOrder": {
                            "type": "string"
                          },
                          "workOrder": {
                            "type": "string"
                          },
                          "connhexId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date"
                          },
                          "deletedAt": {
                            "type": "string",
                            "format": "date"
                          },
                          "tenants": {
                            "type": "array",
                            "items": { "type": "string" },
                            "description": "Tenant IDs to assign to this device. Filtered to the caller's authorized tenants. Defaults to caller's tenants if omitted."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "partial_update/devices/{id}/",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Device"
                    },
                    "included": {
                      "type": "array",
                      "uniqueItems": true,
                      "items": {
                        "$ref": "#/components/schemas/resource"
                      }
                    },
                    "links": {
                      "description": "Link members related to primary data",
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/links"
                        },
                        {
                          "$ref": "#/components/schemas/pagination"
                        }
                      ]
                    },
                    "jsonapi": {
                      "$ref": "#/components/schemas/jsonapi"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not authorized",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "403": {
            "description": "[Forbidden](https://jsonapi.org/format/#crud-updating-responses-403)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "404": {
            "description": "[Related resource does not exist](https://jsonapi.org/format/#crud-updating-responses-404)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "409": {
            "description": "[Conflict](https://jsonapi.org/format/#crud-updating-responses-409)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Devices"],
        "description": "Delete device.\n\nRequired Permission:\n\n - Resource: ```manufacturing:devices:{id}```\n\n - Action: ```manufacturing:devices:delete```",
        "operationId": "Delete device",
        "parameters": [
          {
            "name": "ids",
            "in": "path",
            "required": true,
            "description": "Comma-separated globally unique ids (UUID4)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "[Deleted](https://jsonapi.org/format/#crud-deleting-responses-204)"
          },
          "401": {
            "description": "not authorized",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "403": {
            "description": "[Forbidden](https://jsonapi.org/format/#crud-deleting-responses-403)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "404": {
            "description": "[Related resource does not exist](https://jsonapi.org/format/#crud-deleting-responses-404)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          },
          "409": {
            "description": "[Conflict](https://jsonapi.org/format/#crud-deleting-responses-409)",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "#/components/schemas/failure"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "jsonapi": {
        "type": "object",
        "description": "The server's implementation",
        "properties": {
          "version": {
            "type": "string"
          },
          "meta": {
            "$ref": "#/components/schemas/meta"
          }
        },
        "additionalProperties": false
      },
      "resource": {
        "type": "object",
        "required": ["type", "id"],
        "additionalProperties": false,
        "properties": {
          "type": {
            "$ref": "#/components/schemas/type"
          },
          "id": {
            "$ref": "#/components/schemas/id"
          },
          "attributes": {
            "type": "object"
          },
          "relationships": {
            "type": "object"
          },
          "links": {
            "$ref": "#/components/schemas/links"
          },
          "meta": {
            "$ref": "#/components/schemas/meta"
          }
        }
      },
      "link": {
        "oneOf": [
          {
            "description": "a string containing the link's URL",
            "type": "string",
            "format": "uri-reference"
          },
          {
            "type": "object",
            "required": ["href"],
            "properties": {
              "href": {
                "description": "a string containing the link's URL",
                "type": "string",
                "format": "uri-reference"
              },
              "meta": {
                "$ref": "#/components/schemas/meta"
              }
            }
          }
        ]
      },
      "links": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/components/schemas/link"
        }
      },
      "reltoone": {
        "description": "a singular 'to-one' relationship",
        "type": "object",
        "properties": {
          "links": {
            "$ref": "#/components/schemas/relationshipLinks"
          },
          "data": {
            "$ref": "#/components/schemas/relationshipToOne"
          },
          "meta": {
            "$ref": "#/components/schemas/meta"
          }
        }
      },
      "relationshipToOne": {
        "description": "reference to other resource in a to-one relationship",
        "anyOf": [
          {
            "$ref": "#/components/schemas/nulltype"
          },
          {
            "$ref": "#/components/schemas/linkage"
          }
        ]
      },
      "reltomany": {
        "description": "a multiple 'to-many' relationship",
        "type": "object",
        "properties": {
          "links": {
            "$ref": "#/components/schemas/relationshipLinks"
          },
          "data": {
            "$ref": "#/components/schemas/relationshipToMany"
          },
          "meta": {
            "$ref": "#/components/schemas/meta"
          }
        }
      },
      "relationshipLinks": {
        "description": "optional references to other resource objects",
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "self": {
            "$ref": "#/components/schemas/link"
          },
          "related": {
            "$ref": "#/components/schemas/link"
          }
        }
      },
      "relationshipToMany": {
        "description": "An array of objects each containing the 'type' and 'id' for to-many relationships",
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/linkage"
        },
        "uniqueItems": true
      },
      "ResourceIdentifierObject": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/relationshipToOne"
          },
          {
            "$ref": "#/components/schemas/relationshipToMany"
          }
        ]
      },
      "linkage": {
        "type": "object",
        "description": "the 'type' and 'id'",
        "required": ["type", "id"],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/type"
          },
          "id": {
            "$ref": "#/components/schemas/id"
          },
          "meta": {
            "$ref": "#/components/schemas/meta"
          }
        }
      },
      "pagination": {
        "type": "object",
        "properties": {
          "first": {
            "$ref": "#/components/schemas/pageref"
          },
          "last": {
            "$ref": "#/components/schemas/pageref"
          },
          "prev": {
            "$ref": "#/components/schemas/pageref"
          },
          "next": {
            "$ref": "#/components/schemas/pageref"
          }
        }
      },
      "pageref": {
        "oneOf": [
          {
            "type": "string",
            "format": "uri-reference"
          },
          {
            "$ref": "#/components/schemas/nulltype"
          }
        ]
      },
      "failure": {
        "type": "object",
        "required": ["errors"],
        "properties": {
          "errors": {
            "$ref": "#/components/schemas/errors"
          },
          "meta": {
            "$ref": "#/components/schemas/meta"
          },
          "jsonapi": {
            "$ref": "#/components/schemas/jsonapi"
          },
          "links": {
            "$ref": "#/components/schemas/links"
          }
        }
      },
      "errors": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/error"
        },
        "uniqueItems": true
      },
      "error": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "links": {
            "$ref": "#/components/schemas/links"
          },
          "code": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "source": {
            "type": "object",
            "properties": {
              "pointer": {
                "type": "string",
                "description": "A [JSON Pointer](https://tools.ietf.org/html/rfc6901) to the associated entity in the request document [e.g. `/data` for a primary data object, or `/data/attributes/title` for a specific attribute."
              },
              "parameter": {
                "type": "string",
                "description": "A string indicating which query parameter caused the error."
              },
              "meta": {
                "$ref": "#/components/schemas/meta"
              }
            }
          }
        }
      },
      "onlymeta": {
        "additionalProperties": false,
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/meta"
          }
        }
      },
      "meta": {
        "type": "object",
        "additionalProperties": true
      },
      "datum": {
        "description": "singular item",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/resource"
          }
        }
      },
      "nulltype": {
        "type": "object",
        "nullable": true,
        "default": null
      },
      "type": {
        "type": "string",
        "description": "The [type](https://jsonapi.org/format/#document-resource-object-identification) member is used to describe resource objects that share common attributes and relationships."
      },
      "id": {
        "type": "string",
        "description": "Each resource object’s type and id pair MUST [identify](https://jsonapi.org/format/#document-resource-object-identification) a single, unique resource."
      },
      "Device": {
        "type": "object",
        "required": ["type", "id"],
        "additionalProperties": false,
        "properties": {
          "type": {
            "$ref": "#/components/schemas/type"
          },
          "id": {
            "$ref": "#/components/schemas/id"
          },
          "links": {
            "type": "object",
            "properties": {
              "self": {
                "$ref": "#/components/schemas/link"
              }
            }
          },
          "attributes": {
            "type": "object",
            "properties": {
              "pcbPartNumber": {
                "type": "string"
              },
              "deviceType": {
                "type": "string"
              },
              "fwVersion": {
                "type": "string"
              },
              "partNumber": {
                "type": "string"
              },
              "serialNumber": {
                "type": "string"
              },
              "packageId": {
                "type": "string"
              },
              "palletId": {
                "type": "string"
              },
              "productionOrder": {
                "type": "string"
              },
              "workOrder": {
                "type": "string"
              },
              "connhexId": {
                "type": "string",
                "format": "uuid"
              },
              "createdAt": {
                "type": "string",
                "format": "date"
              },
              "updatedAt": {
                "type": "string",
                "format": "date"
              },
              "deletedAt": {
                "type": "string",
                "format": "date"
              },
              "tenants": {
                "type": "array",
                "items": { "type": "string" },
                "description": "Tenant IDs this device belongs to."
              }
            },
            "required": ["serialNumber", "connhexId"]
          }
        }
      }
    },
    "parameters": {
      "include": {
        "name": "include",
        "in": "query",
        "description": "[list of included related resources](https://jsonapi.org/format/#fetching-includes)",
        "required": false,
        "style": "form",
        "schema": {
          "type": "string"
        }
      },
      "fields": {
        "name": "fields",
        "in": "query",
        "description": "[sparse fieldsets](https://jsonapi.org/format/#fetching-sparse-fieldsets).\nUse fields[\\<typename\\>]=field1,field2,...,fieldN",
        "required": false,
        "style": "deepObject",
        "schema": {
          "type": "object"
        },
        "explode": true
      },
      "sort": {
        "name": "sort",
        "in": "query",
        "description": "[list of fields to sort by](https://jsonapi.org/format/#fetching-sorting)",
        "required": false,
        "style": "form",
        "schema": {
          "type": "string"
        }
      }
    },
    "securitySchemes": {
      "$ref": "../../common.json#/components/securitySchemes"
    }
  },
  "security": [{ "chx_auth_session": [] }, { "bearer": [] }]
}
