Create a work order label

This endpoint creates a new label in the catalog of the authenticated dispatcher's company. The operation is idempotent: if a label with the same description already exists (case-insensitive comparison), the service returns the existing label without creating a duplicate and without raising an error.

📘

Required add-on: general use. This endpoint does not require a specific add-on.

Input parameters

Sent within the body:

Required

ParameterTypeRequiredDescription
account_codeTextYesCode of the staff member with an active dispatcher account. Obtained from the code field in the personnel endpoint. It cannot be null or empty.
descriptionTextYesLabel description. Maximum 200 characters; trim is applied. If a label with the same text already exists (case-insensitive), the existing one is returned without creating a duplicate.

Optional

ParameterTypeRequiredDescription
colorTextOptionalColor in hexadecimal format (maximum 10 characters). Default FFFFFF.

Output parameters

Successful response HTTP 200:

ParameterTypeDescription
successBooleantrue if the operation was successful.
messageTextHTTP response code.
totalInteger1 when the label was created or already existed.
dataJSONLabel object.

Structure of the data object:

FieldTypeDescription
idIntegerUnique label identifier.
id_companyIntegerIdentifier of the company that owns the label.
descriptionTextName or description of the label.
colorTextLabel color in hexadecimal format (without #).
enabledBooleantrue if the label is enabled.

Validations and errors

  • 400account_code or description missing, null, empty or only whitespace; or description exceeds 200 characters.
  • 401 — Not authenticated or account not authorized as dispatcher.
  • 404account_code does not exist in personnel or has no active account.
  • 500 — Internal system error.

Difference from PUT /api/work_orders_labels/

AspectPUT /api/work_orders_labels/POST /api/work_orders_labels/ (this endpoint)
FunctionAssigns an existing label to a work order.Creates a label in the company catalog.
Required parameterswork order folio + label id + account_code.description + account_code.
Optional parametercolor (default FFFFFF).
ResultLabel assigned to the work order.Label created, or existing label if already present.

Example:

Request: (POST) https://app.fracttal.com/api/work_orders_labels/

Body (new label):

{
  "account_code": "USR001",
  "description": "Correctivo urgente",
  "color": "FF5733"
}

Response (new label created):

{
  "success": true,
  "message": "200",
  "total": 1,
  "data": {"id": 1004, "id_company": 5, "description": "Correctivo urgente", "color": "FF5733", "enabled": true}
}

Response (label already existed — same result):

{
  "success": true,
  "message": "200",
  "total": 1,
  "data": {"id": 1001, "id_company": 5, "description": "Correctivo urgente", "color": "FF5733", "enabled": true}
}

Response (error — description > 200 characters):

{
  "success": false,
  "message": "400",
  "total": 0,
  "data": [{"ERROR": "description exceeds maximum length of 200 characters"}]
}

Response
200
Language
LoadingLoading…