Skip to main content

Endpoints

This API is available to specific customers and partners. It will be updated in future versions with sufficient notice.

The following endpoints can be hit via https://api.machinemetrics.com with an API key retrieved from https://app.machinemetrics.com/settings/api-keys with the part-adjustment scope and reporting scopes. Further, machine_id can be retrieved from each machine form on the Machine Settings page in the General Information tab labeled Import ID. API access to retrieve machine_id can also be provided, but isn’t currently documented.

For information about making requests and applying the appropriate content type and authorization headers, see the documentation here: /docs/overview

There are two types of part-adjustments:

  • Rejects
  • Part Corrections

Part Corrections are modifications to the parts that were reported directly from the machine and do not affect the quality score. The count parameter is used to indicate the number of parts you want to add or remove at the indicated adjustmenttime.

Rejects also have a few options:

  • They can indicate that the part is scrap or nonconform via reject_behavior.
  • The scrapcount property indicates how many rejects should be added.
  • If you want these scrapped parts to deduct from the total good parts produced, set the count to the negative of scrapcount. For example, if you want to scrap 5 parts and want to deduct 5 parts that were reported by the machine, you’d have a scrapcount of 5 and a count of -5.
  • If the partadjustment_type has a reject_behavior other than operator, any reject_behavior passed to the endpoint is ignored and the reject will default to what was specified by the partadjustment-type (scrap or nonconform).

Troubleshooting tips:

  • Providing a non-existent part-adjustment-type will result in the error cannot read property id of null
  • Attempting to update a non-existent part-adjustment will result in cannot read property 'machine' of null

POST /part-adjustment (create)

/**
* Responsible for rejecting parts
* @param {String} machine_id - machine uuid
* @param {Int} scrapcount - number of parts that are considered scrap
* @param {Int} count - number of parts to add or remove from quality score
* @param {String} reject_behavior - enum string ['nonconform', 'scrap']
* @param {Int} category_id - int id for "reject reason" aka partadjustment_type
* @param {String} message - user generated text
* @param {String} adjustmenttime - the time of the adjustment in UTC (defaults to NOW)
* @returns {Object}
*/
{
category_id: int,
id: string uuid,
adjustmenttime: string datetime,
message: string,
scrapcount: int,
count: int,
reject_behavior: string // indicates whether scrap or nonconform
}

PUT /part-adjustment/:id (update)

The following is the body of a POST as a JSON document.

/**
* Responsible for updating part adjustments
* @routeParam {String} - part-adjustment id - uuid
* @param {Int} count - required
* @param {Int} scrapcount - required
* @param {String} message - user generated text
* @param {String} adjustmenttime - the time of the adjustment in UTC
* @param {String} reject_behavior - enum string ['nonconform', 'scrap']
* @param {Int} category_id - int id for "reject reason" aka partadjustment_type
*/
[
{
id: string uuid,
machine_id: string uuid,
adjustmenttime: string datetime,
category_id: int,
message: string,
scrapcount: int,
count: int,
reject_behavior: string, // indicates whether scrap or nonconform
},
]

DELETE /part-adjustment/:id (delete)

/**
* Responsible for deleting a part adjustment
* @routeParam {string} - part-adjustment uuid
*/

GET /part-adjustments (read)

The following (in comments) are query string parameters for the request. The response is an array of partadjustments in the shape below the comments.

/**
* Responsible for rejecting parts
* @param {String} machine_id - machine uuid
* @param {String} start - datetime, beginning of query range
* @param {String} end - datetime, end of query range
* @param {Int} limit - limit num. rows
* @param {Bool} scrap - include partadjustment type info, for scrap parts
* @param {Bool} correction - include partadjustment type info, for correction
* Can use scrap or correction to include type info, not both
*/
[
{
id: string uuid,
adjustmenttime: string datetime,
category_id: int,
message: string,
scrapcount: int,
count: int,
reject_behavior: string, // indicates whether scrap or nonconform
},
]

GET /part-adjustment-types (read)

The following (in comments) are query string parameters for the request. The response is an array of partadjustment_types in the shape below the comments.

/**
* Fetches the current company's part adjustment types
* @param {Boolean} scrapOnly - optional (defaults to false)
* @param {Boolean} includeHidden - optional (defaults to false)
* @returns {Object} (array of objects)
*/
[
{
id: int,
company_id: string uuid,
name: string,
color: string,
correction: bool,
scrap: bool,
reject_behavior: string
hidden: bool,
},
]