Returns the (paginated) list of spare parts and supplies associated with an asset, with their code, description, quantity, unit of measure, status and origin (asset record or task plan). The asset is identified by its code.
GET https://app.fracttal.com/api/items_spare_parts/
GET https://app.fracttal.com/api/items_spare_parts/{code}The asset code is also accepted as part of the path. If it is sent both in the path and as the code parameter, the path value takes precedence.
Input parameters — Required
Sent as query params (or code in the path).
| Parameter | Type | Required | Description |
|---|---|---|---|
code | text | Yes | Asset code. It is a text value: leading zeros are preserved. The search is exact and case-sensitive, and spaces are significant. |
Input parameters — Optional
| Parameter | Type | Required | Description |
|---|---|---|---|
item_type | text | No (recommended) | Asset type, from 1 to 5: 1 Locations, 2 Equipment, 3 Tools, 4 Spare parts and supplies, 5 Digital. An asset code is not unique and can be repeated across types; if the code matches more than one asset and item_type is not sent, the API responds 400 and returns no data. Always sending it is recommended. |
start | text | No | Record from which the query starts. Default 0. A negative or non-numeric value responds 400. |
limit | text | No | Number of records per page. Default and maximum 100. A value lower than 1, greater than 100 or non-numeric responds 400. |
An empty value in any of these parameters is treated as if it had not been sent.
Required permissionsThe application authenticates with OAuth2 (
client_credentials). Its permission group must haveviewon the assets module for Locations, Equipment and Spare Parts and Supplies, and in particular on the type of the queried asset. Without that permission the API responds with an authorization error (see the errors section).
What the query returns
- Only spare parts and supplies are returned. Tools and other resource types of a task plan do not appear.
- From the asset's task plan, only active, non-stopped tasks of active plans are included.
- The same spare part can appear several times: once for the asset record and once for each plan task that uses it. Use
originandtaskto tell them apart. Quantities are never added together.- Inactive spare parts are also returned; they are identified by
is_active = false.- Rows are sorted by
origin(assetbeforetask_plan) and then bycode.- The API does not paginate automatically: if
totalis greater than the number of rows received, repeat the query by increasingstartby the value oflimit.
Output parameters
| Parameter | Type | Description |
|---|---|---|
success | boolean | true if the query was successful. |
message | text | "200" on success; error code or message otherwise. |
total | integer | Total number of rows for the asset, before pagination — not the size of the returned page. |
data | array of objects | Page of results. See the structure in the next table. |
Structure of each element in data:
| Parameter | Type | Description |
|---|---|---|
code | text | Spare part or supply code. |
description | text | Spare part or supply description. |
qty | number | Quantity (decimals allowed). With origin = asset it is the quantity recorded in the asset record; with origin = task_plan it is the quantity per execution of the task. |
unit | text | Unit of measure. null if the spare part has no unit. |
is_active | boolean | true if the spare part is active. |
origin | text | asset: comes from the asset record. task_plan: comes from a task plan of the asset. |
task | text | Description of the plan task that uses the resource. null when origin is asset. |
Errors
| Code | Cause |
|---|---|
400 | code is missing; item_type is outside the 1 to 5 range; start or limit are invalid; or the code matches more than one asset (send item_type). Details are in data[0].ERROR. |
401 | The application does not have view permission on the type of the queried asset. It arrives with data.Error = "UNAUTHORIZED_ENDPOINT". |
404 | The code does not exist in the company. Details are in data[0].ERROR. |
INVALID_TOKEN | Invalid token, or not authorized for the company. |
INVALID_ENDPOINT | The service is not enabled for the application. |
UNAUTHORIZED_ENDPOINT | The application's permission group does not meet the required permission. |
UNAUTHORIZED_USE | The company does not have API usage enabled. |
ERROR_SQL | Unhandled internal error. |
Note on authorization errorsA permissions error can arrive in two forms: with
message: "401"anddata.Error = "UNAUTHORIZED_ENDPOINT", or withmessage: "UNAUTHORIZED_ENDPOINT"anddata: null. In both cases it means the application's permission group does not have the required permission. In400and404error responses, thetotalfield arrives as text ("0").
Example
Request
GET https://app.fracttal.com/api/items_spare_parts/?code=EQ-0042&item_type=2&start=0&limit=50Response 200
200{
"success": true,
"message": "200",
"total": 3,
"data": [
{
"code": "REP-001",
"description": "Rodamiento 6002 { REP-001 }",
"qty": 2,
"unit": "Unidad",
"is_active": true,
"origin": "asset",
"task": null
},
{
"code": "REP-002",
"description": "Filtro de aceite { REP-002 }",
"qty": 1,
"unit": "Litros",
"is_active": true,
"origin": "task_plan",
"task": "Mantenimiento cada 250 hr"
},
{
"code": "REP-002",
"description": "Filtro de aceite { REP-002 }",
"qty": 4,
"unit": "Litros",
"is_active": false,
"origin": "task_plan",
"task": "Mantenimiento anual"
}
]
}Response — Asset without spare parts (200)
200){
"success": true,
"message": "200",
"total": 0,
"data": []
}Response — Missing code (400)
400){
"success": false,
"message": "400",
"total": "0",
"data": [
{ "ERROR": "code is required" }
]
}Response — Repeated code without item_type (400)
item_type (400){
"success": false,
"message": "400",
"total": "0",
"data": [
{ "ERROR": "code matches more than one item, item_type is required: EQ-0042" }
]
}Response — Code does not exist (404)
404){
"success": false,
"message": "404",
"total": "0",
"data": [
{ "ERROR": "code does not exist: EQ-9999" }
]
}Response — No permission on the asset type (401)
401){
"success": false,
"message": "401",
"data": { "Error": "UNAUTHORIZED_ENDPOINT" }
}OpenAPI definition
{
"openapi": "3.1.0",
"info": {
"title": "Spare parts and supplies of an asset",
"version": "2-En"
},
"servers": [
{ "url": "https://app.fracttal.com/api/items_spare_parts" }
],
"security": [{}],
"paths": {
"/": {
"get": {
"summary": "Get spare parts and supplies of an asset",
"description": "",
"operationId": "get-spare-parts-and-supplies-of-an-asset",
"deprecated": false,
"security": []
}
}
},
"x-readme": {
"headers": [],
"explorer-enabled": false,
"proxy-enabled": true
},
"x-readme-fauxas": true
} 200