post
https://app.fracttal.com/api/group_tasks//tasks//resources
Adds one or more resources to an existing task of a task plan. Three resource types are supported: inventory (tools and spare parts), human resources, and services. Each resource is created with a quantity of 1 and the default unit cost from its source record.
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id_group_task | integer | Yes | Task plan identifier. Sent in the path. |
id_task | integer | Yes | Identifier of the task the resources are added to. It must belong to the plan given in id_group_task. Sent in the path. |
resources | array of object | Yes | Resources to create. It must include between 1 and 50 elements. See the structure in the table below. |
Structure of each element in resources:
| Parameter | Type | Required | Description |
|---|---|---|---|
type_description | text | Yes | Resource type. Allowed values: INVENTORY, HUMAN_RESOURCES, SERVICES. |
id_item | integer | Yes, if type_description is INVENTORY | Inventory item identifier. It must be a tool or a spare part. |
id_hourly_rate | integer | Yes, if type_description is HUMAN_RESOURCES | Hourly rate identifier of the human resource. |
id_service_type | integer | Yes, if type_description is SERVICES | Service type identifier. |
note | text | No | Note associated with the resource. |
Rules forresources
- The quantity of each resource is always set to
1, regardless of what is sent in the request.- The unit cost is taken from the source record: average cost of the item (
INVENTORY), value of the hourly rate (HUMAN_RESOURCES), or cost of the service (SERVICES). If the source record has no cost configured, the resource is created withunit_costequal to0.- A resource that already exists on the task (same type and same reference) cannot be added, and the same resource cannot be repeated within the same request.
- The operation is atomic: if any resource fails validation, none is created and the response indicates, for each resource with an error, its position (
index) and the reason.- The token must have edit permission on task plans, and the task must belong to the company of the token used.
Output parameters
| Parameter | Type | Description |
|---|---|---|
success | boolean | Indicates whether the operation was successful. |
message | text | Result code ("201" if successful). |
data | array of object | Created resources. See the structure in the table below. |
total | integer | Number of resources created. |
Structure of each element in data:
| Parameter | Type | Description |
|---|---|---|
id | integer | Identifier of the created resource. |
type_description | text | Resource type: INVENTORY, HUMAN_RESOURCES, or SERVICES. |
quantity | integer | Resource quantity. Always 1. |
unit_cost | number | Unit cost applied, taken from the source record. |
id_item | integer | Item identifier. Only returned when the type is INVENTORY. |
id_hourly_rate | integer | Hourly rate identifier. Only returned when the type is HUMAN_RESOURCES. |
id_service_type | integer | Service type identifier. Only returned when the type is SERVICES. |
Errors
| Code | Cause |
|---|---|
401 | Missing or invalid token. |
403 | The token does not have edit permission on task plans, or the company does not have the ADVANCED APIS add-on. |
404 | The task given in id_task does not exist. |
422 | Validation failed: id_group_task or id_task is missing, the plan does not exist, the task does not belong to the plan, resources is missing, empty, or has more than 50 elements, or a resource is invalid (type not allowed, missing or nonexistent reference, item that is neither a tool nor a spare part, duplicated resource). |
Note on error codesThis service reports the result in the
messagefield of the response. When one or more resources fail validation (422), thedatafield includes one element per resource with an error, with its positionindex(starting at0) and the detail inerror. Error messages are returned in English.
Example
Request body
{
"resources": [
{
"type_description": "INVENTORY",
"id_item": 4521,
"note": "Impact wrench for bolt tightening"
},
{
"type_description": "HUMAN_RESOURCES",
"id_hourly_rate": 310
},
{
"type_description": "SERVICES",
"id_service_type": 87
}
]
}Response 201
201{
"success": true,
"message": "201",
"data": [
{
"id": 90211,
"type_description": "INVENTORY",
"quantity": 1,
"unit_cost": 45.5,
"id_item": 4521
},
{
"id": 90212,
"type_description": "HUMAN_RESOURCES",
"quantity": 1,
"unit_cost": 18,
"id_hourly_rate": 310
},
{
"id": 90213,
"type_description": "SERVICES",
"quantity": 1,
"unit_cost": 0,
"id_service_type": 87
}
],
"total": 3
}Response — Invalid resource (422)
422){
"success": false,
"message": "422",
"data": [
{
"index": 1,
"error": "id_hourly_rate is required for HUMAN_RESOURCES"
},
{
"index": 2,
"error": "Resource SERVICES id_service_type 87 already exists for this task"
}
],
"total": 0
}Response — Task not found (404)
404){
"success": false,
"message": "404",
"data": [
{
"ERROR": "id_task not found"
}
],
"total": 0
}OpenAPI definition
{
"openapi": "3.1.0",
"info": {
"title": "group_tasks_resources",
"version": "2-En"
},
"servers": [
{ "url": "https://app.fracttal.com/api/group_tasks" }
],
"security": [{}],
"paths": {
"/{id_group_task}/tasks/{id_task}/resources": {
"post": {
"summary": "Create resources on a task of a task plan",
"description": "",
"operationId": "create-resources-on-a-task-of-a-task-plan",
"deprecated": false,
"security": []
}
}
},
"x-readme": {
"headers": [],
"explorer-enabled": false,
"proxy-enabled": true
},
"x-readme-fauxas": true
}