Create resources on a task of a task plan

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

ParameterTypeRequiredDescription
id_group_taskintegerYesTask plan identifier. Sent in the path.
id_taskintegerYesIdentifier of the task the resources are added to. It must belong to the plan given in id_group_task. Sent in the path.
resourcesarray of objectYesResources to create. It must include between 1 and 50 elements. See the structure in the table below.

Structure of each element in resources:

ParameterTypeRequiredDescription
type_descriptiontextYesResource type. Allowed values: INVENTORY, HUMAN_RESOURCES, SERVICES.
id_itemintegerYes, if type_description is INVENTORYInventory item identifier. It must be a tool or a spare part.
id_hourly_rateintegerYes, if type_description is HUMAN_RESOURCESHourly rate identifier of the human resource.
id_service_typeintegerYes, if type_description is SERVICESService type identifier.
notetextNoNote associated with the resource.

Rules for resources

  • 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 with unit_cost equal to 0.
  • 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

ParameterTypeDescription
successbooleanIndicates whether the operation was successful.
messagetextResult code ("201" if successful).
dataarray of objectCreated resources. See the structure in the table below.
totalintegerNumber of resources created.

Structure of each element in data:

ParameterTypeDescription
idintegerIdentifier of the created resource.
type_descriptiontextResource type: INVENTORY, HUMAN_RESOURCES, or SERVICES.
quantityintegerResource quantity. Always 1.
unit_costnumberUnit cost applied, taken from the source record.
id_itemintegerItem identifier. Only returned when the type is INVENTORY.
id_hourly_rateintegerHourly rate identifier. Only returned when the type is HUMAN_RESOURCES.
id_service_typeintegerService type identifier. Only returned when the type is SERVICES.

Errors

CodeCause
401Missing or invalid token.
403The token does not have edit permission on task plans, or the company does not have the ADVANCED APIS add-on.
404The task given in id_task does not exist.
422Validation 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 codes

This service reports the result in the message field of the response. When one or more resources fail validation (422), the data field includes one element per resource with an error, with its position index (starting at 0) and the detail in error. 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

{
  "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)

{
  "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)

{
  "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
}
Path Params
integer
required

Task plan identifier.

integer
required

Identifier of the task the resources are added to. It must belong to the plan given in id_group_task.

Language
LoadingLoading…