Create a service

Create a new service type for the authenticated company.

If the unit specified by unit_code does not exist, it is created automatically using unit_description.

Endpoint

POST /api/service_types

Request body parameters

ParameterTypeRequiredDescription
descriptionTextYesName of the service type. Maximum 50 characters.
unit_codeTextYesCode of the unit associated with the service type. Maximum 10 characters. If it does not exist in the company, a new unit is created.
unit_descriptionTextConditionalUnit description. Required if unit_code does not exist in the company yet. Maximum 50 characters.

Notes

  • The description and unit_code fields are required. If either one is missing or empty, the function returns code 404 and the message description and unit_code are required.
  • If unit_code does not exist in the company unit catalog and unit_description is not sent, the function returns code 404 and the message unit_description is required.
  • The unit_code lookup is case-insensitive (UPPER).
  • The new unit is created with id_unit_type = 2.

Response parameters

ParameterTypeDescription
idIntegerUnique identifier of the created service type.
id_companyIntegerCompany identifier.
descriptionTextRegistered service type name.
id_unityIntegerIdentifier of the associated unit.
is_changedBooleanIndicates whether the record has been modified. Always false on creation.

Example

When the unit does not exist, send unit_description to create it automatically.

{
  "description": "Corrective maintenance",
  "unit_code": "HRS",
  "unit_description": "Hours"
}

When the unit already exists, you do not need to send unit_description.

{
  "description": "Preventive inspection",
  "unit_code": "HRS"
}

Response
200
Language
LoadingLoading…