Tools
- GET /api/tools/
Get an object mapping tool ID to tool.
- Query Parameters:
durable (string) – set to
durable
to include only durable tools orconsumable
to exclude themunassigned (int) – set to
1
to only include tools that are not assigned to a processprocess (int) – set to a process ID to include only tools assigned to that process
machine (int) – set to a machine ID to include only tools in use by that machine’s currently loaded process
active (int) – set to
1
to include only tools assigned to any active processinventory_item (int) – set to an inventory item ID to include only tools that use that item
assembly (int) – set to a ToolAssembly ID to get only tools that are in that assembly
favorite (int) – set to
1
to include only tools that the current user has marked as favoriteslife (int) – set to
1
to calculate the average number of parts between replacements of each tool and return it as an additionalaverage_tool_life
field in each tool object. This slows down the request processing significantly, so only use it when necessary.warn_life (int) – set to
1
to include only tools past their warning life thresholdusage_mode (int) – set to a usage mode value (numeric) to include only tools with that usage mode. Can be passed multiple times to include multiple usage modes. If not set, all usage modes are included.
Note
The following parameters are mutually exclusive, so only one of them can be specified at a time:
unassigned
process
active
inventory_item
assembly
machine
- Status Codes:
400 Bad Request – if multiple mutually-exclusive filters are specified in the same request
424 Failed Dependency – if the provided
process
,inventory_item
,tool_assembly
, ormachine
ID does not exist.
- Returns:
a JSON object mapping tool IDs to tool objects
- GET /api/tools/(int: tool_id)
Get data about a single tool.
- Parameters:
tool_id – The tool to query
- Returns:
the tool object
- Status Codes:
404 Not Found – if the tool does not exist
- PUT /api/tools/
Create a new tool.
- Reqjsonobj:
a (partial) tool object
- Returns:
the new tool object
- Status Codes:
201 Created – on success
- PATCH /api/tools/(int: tool_id)
Edit an existing tool to set new data.
The request body should be a (partial) tool object.
Note
Certain users may not be able to set all fields. Errors will be silently ignored.
Field
Admin
Planner
Shop
notes
X
X
X
part_count
X
X
X
name
X
X
part_life, warn_life
X
X
location
X
X
reorder_point
X
X
order_qty
X
X
tags
X
X
monitoring_dest
X
X
used_orders
X
X
inventory_item_id
X
X
- Request JSON Object:
life_modification_notes (string) – if any expected life fields have been modified, text provided here will be saved in the tool life change record.
- Parameters:
tool_id – The ID to the tool to modify
- Status Codes:
404 Not Found – if the tool doesn’t exist
400 Bad Request – if the request body is invalid
- Returns:
the modified tool object
- DELETE /api/tools/(int: tool_id)
Delete an existing tool.
- Parameters:
tool_id – The ID of the tool to delete
- Status Codes:
204 No Content – on success
404 Not Found – if the tool does not exist
- GET /api/tools/(int: tool_id)/replacements
Get the replacement history for a tool.
- Query Parameters:
limit (int) – maximum number of items to return (defaults to all). More recent replacements are returned first.
offset (int) – skip past this many results
- Parameters:
tool_id – The ID of the tool to query.
- Returns:
an object mapping replacement ID to replacement object
- Status Codes:
404 Not Found – if the tool doesn’t exist
- GET /api/tools/(int: tool_id)/lifeHistory
Get the life history for a tool.
- Query Parameters:
start (float) – get only changes made to this tool’s life on or after the given UNIX timestamp
end (float) – get only changes made to this tool’s life on or before the given UNIX timestamp
- Parameters:
tool_id – ID of the tool to get the life history for
- Status Codes:
404 Not Found – if the tool doesn’t exist
- Returns:
an object mapping ToolLifeRecord ID to ToolLifeRecord
- GET /api/tools/(int: tool_id)/replace
Get the information needed to prompt for a tool replacement.
- Parameters:
tool_id – the ID of the tool that will be replaced
- Status Codes:
404 Not Found – if the tool does not exist
400 Bad Request – if the tool is not active on exactly one machine
- Response JSON Object:
default_inventory_point_id (int) – The ID of the default inventory point to take an item from, or null.
last_replacement – the Tool’s most recent ToolReplacement object or
null
if it has never been replaced
- POST /api/tools/(int: tool_id)/replace
Mark a tool as replaced and add an entry to its history.
An image can be uploaded to the newly created tool replacement record using
POST /api/tools/replacements/<id>/image
.- Query Parameters:
forceSub (int) – set to
1
to reassign substitute tools that are already in another assembly instead of returning an error
- Parameters:
tool_id – the ID of the tool to replace
- Request JSON Object:
reason (int) – why the tool is being replaced. See the
reason
field of theToolReplacement
model for allowed values.condition (int) – the state of the old tool that is being replaced. See the
condition
field of theToolReplacement
model for details.notes (string) – user-supplied notes to save with this tool replacement.
indexed (bool) – whether the tool was indexed (inventory will not be subtracted)
substitute (int) – when replacing tools, this can be set to the ID of another tool to move into this one’s place. If this field is non-null, the rebuilt tool will be removed from its assembly and the tool whose ID was specified here will be added in its place. Note that the replacement object will still be recorded for the tool that has
tool_id
.maintenance_status (int) – set the maintenance status of the tool
inv_pt (int) – ID of the inventory point the replacement came from
timestamp (float) – a UNIX timestamp to override the replacement timestamp (which defaults to the current time if not specified). This timestamp must be later than that of the previous replacement of this tool (if one exists) but not later than the current time. The replacement’s part and time counters will only account for production up until this timestamp, and any production after this timestamp will be left on the tool’s active counters.
- Response JSON Object:
tool – the tool object that was replaced with reset counters
replacement – the tool replacement history object that was created
substitute – if
substitute
was set in the request object, this field in the response will contain the tool that is taking the rebuilt tool’s place, and is now in its assembly.
- Response JSON Array of Objects:
list (string) – post-replacement checklist
- Status Codes:
400 Bad Request – if the tool was not indexed and the inventory point is missing or does not have at least one of this tool, or if it runs out of corners to index
403 Forbidden – if the current user is not allowed to replace a tool with the data provided
404 Not Found – if the tool doesn’t exist
409 Conflict – if the substitute tool is in an assembly
424 Failed Dependency – if
substitute
is set to an invalid tool ID425 – if the tool’s usage is less than the value set in the
tool_replacement_min_usage
option
- POST /api/tools/bulkAdjustPartCount
Adjust the part count of multiple tools.
- Request JSON Object:
count (int) – positive adds to the part count, negative decreases it
- Request JSON Array of Objects:
tools (int) – list of tool IDs to modify
- Returns:
a JSON object of modified tools
- POST /api/tools/bulkChangeTags
Adds and/or removes tags across multiple tools.
Tags will not be duplicated on tools that already have one or more of the new tags. If a tag is present in both
add
andremove
, it will be removed.- Request JSON Array of Objects:
tools (int) – list of tool IDs to modify
add (string) – list of tags to add
remove (string) – list of tags to remove
- Returns:
a JSON object of modified tools
- POST /api/tools/updatePartLife
Update the part life of all selected tools to their calculated average life.
- Request JSON Array of Objects:
int – list of tool IDs to update
- Returns:
a JSON object containing all updated tools, keyed by tool ID
- GET /api/tools/(int: tool_id)/dayCount/(force_type)
Get the day count of a tool for any type of day counting, not just the one it has set.
- Parameters:
tool_id – the ID of the tool to query
force_type – the type of day counting to use
- Returns:
the number of days the tool has been in use
- Status Codes:
404 Not Found – if the tool does not exist
400 Bad Request – if the counting type is invalid
- GET /api/tools/(int: tool_id)/processLife
Get a single tool’s usage and life for each process that uses it.
- Parameters:
tool_id – the ID of the tool to get information about
- Returns:
an object mapping process ID (or
""
for the tool’s intrinsic life without a process) to ToolProcessLife object.- Status Codes:
404 Not Found – if the tool does not exist
- PATCH /api/tools/(int: tool_id)/processLife/(int: process_id)
Edit a single tool’s usage and life for a single process. :param tool_id: the ID of the tool to edit life for :param process_id: the ID of the process to edit this tool’s life for :return: the created or modified ToolProcessLife object :status 404: if the tool and/or process IDs are invalid
- GET /api/tools/import
Get a copy of the tool import template that can be filled in to bulk import tools.
- Returns:
an XLTX file
- POST /api/tools/import
Upload a filled-in copy of the tool import template.
The request body should be the binary file.
- Query Parameters:
process (int) – if provided, tool assemblies created during this import will be assigned to the process with this ID.
- Status Codes:
201 Created – on success
404 Not Found – if an invalid process ID is provided
422 Unprocessable Entity – if the workbook is invalid for any reason
- Resjsonobj:
maps tool ID to new tool object
- GET /api/tools/(int: obj_id)/image
Get the current image file of the Tool.
- Parameters:
obj_id – ID of the Tool to get the image for
- Status Codes:
200 OK – if the Tool exists and an image is set
404 Not Found – if the Tool does not exist
412 Precondition Failed – if the Tool exists but does not have an image
- Returns:
the image file, with the
Content-Type
header set to its MIME type
- POST /api/tools/(int: obj_id)/image
Upload a new image file for the Tool.
The request body should be an image file, and the
Content-Type
header should contain its MIME type.- Parameters:
obj_id – ID of the Tool to set the image for
- Status Codes:
200 OK – on success
404 Not Found – if the Tool does not exist
413 Request Entity Too Large – if the image file is larger than 5 MB
415 Unsupported Media Type – if the image file is invalid or of an unsupported type
- Returns:
the modified Tool
- DELETE /api/tools/(int: obj_id)/image
Remove the image from the Tool.
- Parameters:
obj_id – ID of the Tool to clear the image from
- Status Codes:
404 Not Found – if the Tool does not exist
200 OK – on success
- Returns:
the modified Tool
Tool Replacements
- GET /api/tools/replacements/process/(int: process_id)
Get the data to chart the replacement history for all tools assigned to a process.
The output format is an object mapping tool ID to the Tool object, but with an added
replacements
field that is an object mapping tool replacement ID to ToolReplacement object.{ "17": { "id": 17, ..., "replacements": { "31895": { "id": 31895, "tool_id": 17, ... }, ... } }, ... }
It is strongly recommended to set
start
andend
as the returned data can get quite large and require several seconds to generate for large time spans.- Parameters:
process_id – the ID of the process to query
- Query Parameters:
start (int) – Optional, UNIX timestamp. Only replacements at or after this time will be returned
end (int) – Optional, UNIX timestamp. Only replacements at or before this time will be returned
- Returns:
an object mapping tool ID to replacement objects
- Status Codes:
404 Not Found – if the program doesn’t exist
- PATCH /api/tools/replacements/(int: repl_id)
Edit an existing tool replacement.
The request body should be a (partial) ToolReplacement object. Omitted fields will not be changed.
- Status Codes:
403 Forbidden – if the request is blocked from changing the replacement’s
testing
value404 Not Found – if the tool replacement does not exist
- DELETE /api/tools/replacements/(int: repl_id)
Delete a single tool replacement.
The current state of the tool will not be affected unless
undo
is set, in which case the replacement’s part count will be added to the tool’s part count and, if the tool was not indexed, one will be added back to the inventory point that was selected during replacement. This can only be used when deleting the most recent replacement of a given tool.- Query Parameters:
undo (int) – set to
1
to undo the replacement on the tool when deleting it
- Status Codes:
404 Not Found – if the replacement does not exist
409 Conflict – if
undo
was set but the tool has a more recent replacement202 Accepted – if
undo
was set but the tool for this replacement does not exist. This should be an impossible case as replacements are deleted with their tool.204 No Content – on success
- GET /api/tools/replacements/(int: obj_id)/image
Get the current image file of the ToolReplacement.
- Parameters:
obj_id – ID of the ToolReplacement to get the image for
- Status Codes:
200 OK – if the ToolReplacement exists and an image is set
404 Not Found – if the ToolReplacement does not exist
412 Precondition Failed – if the ToolReplacement exists but does not have an image
- Returns:
the image file, with the
Content-Type
header set to its MIME type
- POST /api/tools/replacements/(int: obj_id)/image
Upload a new image file for the ToolReplacement.
The request body should be an image file, and the
Content-Type
header should contain its MIME type.- Parameters:
obj_id – ID of the ToolReplacement to set the image for
- Status Codes:
200 OK – on success
404 Not Found – if the ToolReplacement does not exist
413 Request Entity Too Large – if the image file is larger than 5 MB
415 Unsupported Media Type – if the image file is invalid or of an unsupported type
- Returns:
the modified ToolReplacement
- DELETE /api/tools/replacements/(int: obj_id)/image
Remove the image from the ToolReplacement.
- Parameters:
obj_id – ID of the ToolReplacement to clear the image from
- Status Codes:
404 Not Found – if the ToolReplacement does not exist
200 OK – on success
- Returns:
the modified ToolReplacement
Tool Assemblies
- GET /api/tools/assemblies/
Get all current tool assemblies.
- Query Parameters:
process (int) – if set, only tool assemblies with the specified process ID will be returned.
shared (int) – if set to
1
, shared tool assemblies from other processes on the same machine as the specifiedprocess
will be included. Ignored ifprocess
is not specified.
- Status Codes:
424 Failed Dependency – if the process ID specified does not exist
- Return:
an object mapping IDs to assembly objects
- PUT /api/tools/assemblies/
Create a new tool assembly.
- Reqjson:
partial ToolAssembly object (name is required, everything else is optional)
- Status Codes:
400 Bad Request – if the name is missing
201 Created – on success
- Returns:
the new assembly object
- PATCH /api/tools/assemblies/(int: asm_id)
Edit an existing assembly.
- Parameters:
asm_id – the ID of the assembly to edit
- Return:
the modified assembly object.
- Status Codes:
404 Not Found – if the assembly does not exist
- DELETE /api/tools/assemblies/(int: asm_id)
Delete a tool assembly.
- Parameters:
asm_id – the ID of the assembly to delete
- Status Codes:
404 Not Found – if the assembly does not exist
204 No Content – on success
- POST /api/tools/assemblies/(int: asm_id)/duplicate
Duplicate a tool assembly.
- Parameters:
asm_id – the ID of the original assembly to duplicate
- Request JSON Array of Objects:
tools (int) – optional list of tool IDs to place into the new assembly. Tools listed must not already be in an assembly.
- Resjsonobj:
the new assembly object
- Returns:
the new ToolAssembly object
- Status Codes:
201 Created – on success
400 Bad Request – if any tools referenced in provided fields do not exist or are already used in an assembly
404 Not Found – if the original assembly does not exist
Example request body:
- POST /api/tools/assemblies/(int: asm_id)/addTools
Add tools to an assembly.
Any tools that are already in the assembly will be silently ignored.
- Parameters:
asm_id – the ID of the target assembly
- Request JSON Array of Objects:
tools (int) – list of tool IDs to add
- Return:
the modified assembly object
- Status Codes:
400 Bad Request – if the tools array is missing or invalid
404 Not Found – if the assembly does not exist
- GET /api/tools/assemblies/(int: asm_id)/replacements
Get the replacement history for a tool.
- Query Parameters:
limit (int) – maximum number of items to return (defaults to all). More recent replacements are returned first.
offset (int) – skip past this many results
- Parameters:
asm_id – The ID of the tool assembly to query.
- Returns:
an object mapping replacement ID to replacement object
- Status Codes:
404 Not Found – if the tool assembly doesn’t exist
- POST /api/tools/assemblies/(int: asm_id)/merge
Merge several source tool assemblies into this one destination tool assembly. This will move all tools from the source assemblies into the destination assembly, and then delete the now-empty source assemblies.
- Parameters:
asm_id – the ID of the destination assembly
- Reqjsonarr:
list of source assembly IDs
- Resjsonobj:
destination assembly object after the merge
- Status Codes:
412 Precondition Failed – if any assembly IDs listed do not exist
- GET /api/tools/assemblies/(int: obj_id)/image
Get the current image file of the ToolAssembly.
- Parameters:
obj_id – ID of the ToolAssembly to get the image for
- Status Codes:
200 OK – if the ToolAssembly exists and an image is set
404 Not Found – if the ToolAssembly does not exist
412 Precondition Failed – if the ToolAssembly exists but does not have an image
- Returns:
the image file, with the
Content-Type
header set to its MIME type
- POST /api/tools/assemblies/(int: obj_id)/image
Upload a new image file for the ToolAssembly.
The request body should be an image file, and the
Content-Type
header should contain its MIME type.- Parameters:
obj_id – ID of the ToolAssembly to set the image for
- Status Codes:
200 OK – on success
404 Not Found – if the ToolAssembly does not exist
413 Request Entity Too Large – if the image file is larger than 5 MB
415 Unsupported Media Type – if the image file is invalid or of an unsupported type
- Returns:
the modified ToolAssembly
- DELETE /api/tools/assemblies/(int: obj_id)/image
Remove the image from the ToolAssembly.
- Parameters:
obj_id – ID of the ToolAssembly to clear the image from
- Status Codes:
404 Not Found – if the ToolAssembly does not exist
200 OK – on success
- Returns:
the modified ToolAssembly