Add service time

This endpoint allows saving service times by day type within a specific period.

PUT /api/v1/businesses/{businessId}/services/{serviceId}/periods/{periodId}/service-times

The fields that make up the body of the request are detailed below, some of which are mandatory for it to be carried out successfully.

Mandatory fields are marked with an asterisk (*).

Request body

JSON analysis
{
    "dayType": {
        "name": "string"
    },
    "type": "string",
    "openingHours": {
        "start": 0,
        "end": 0
    },
    "serviceHours": {
        "start": 0,
        "end": 0
    },
    "restHours": [
        {
            "start": 0,
            "end": 0
        }
    ]
}
Details
  • dayType*: type of day. It can be a system day type or one created at the business level.

    • name*: name of the day type.

  • type*: type of service time. It can take one of the following values: OPEN, CLOSE, OPEN_HOLIDAY, and CLOSE_HOLIDAY. Both CLOSE and CLOSE_HOLIDAY apply to the entire day, from 0 to 1440.

  • openingHours*: service opening hours. The value is expressed in minutes since midnight (00:00 local time).

    • start*: start of the interval expressed in minutes since midnight.

    • end*: end of the interval expressed in minutes since midnight.

  • serviceHours*: public service hours. The value is expressed in minutes since midnight (00:00 local time).

    • start*: start of the interval expressed in minutes since midnight.

    • end*: end of the interval expressed in minutes since midnight.

  • restHours: interval, if applicable, during which the service will be closed. The value is expressed in minutes since midnight (00:00 local time).

    • start*: start of the interval expressed in minutes since midnight.

    • end*: end of the interval expressed in minutes since midnight.

Request example

Once the different fields have been analyzed, an example of the request body is shown below:

{
    "dayType": {
        "name": "SUNDAY"
    },
    "type": "OPEN",
    "openingHours": {
        "start": 0,
        "end": 0
    },
    "serviceHours": {
        "start": 540,
        "end": 1260
    },
    "restHours": [
        {
            "start": 840,
            "end": 870
        },
        {
            "start": 1080,
            "end": 1110
        }
    ]
}

If all data is correct, an open schedule (OPEN) will be created for Sunday (SUNDAY) with the following intervals:

  • Open 24 hours.

  • Public service hours from 9:00 (540) to 21:00 (1260).

  • Break from 14:00 (840) to 14:30 (870) and from 18:00 (1080) to 18:30 (1110).

Considerations

The day type name (name) must exactly match a system day type or one defined at the business level.

Fields expressed in minutes since midnight take into account the service time zone. For example, if the service is in UTC+2, 540 refers to 09:00 UTC+2. The allowed values for these fields range from 0 to 1439.

If a service time is already defined for the same day type within the period, it will be overwritten with the data in the request.

Error codes

In addition to the common errors, this endpoint can return the following codes:

Code Message Description

400 Bad Request

-

The type field does not have one of the allowed values (OPEN, CLOSE, OPEN_HOLIDAY, CLOSE_HOLIDAY), or the request body is not valid JSON.

404 Not Found

Period not found

The periodId specified in the URL does not exist for the service. You can check the different periods of a service through this request.

Day type not found

The name specified in dayType.name does not match any system day type or any defined at the business level.

406 Not Acceptable

must not be null

One of the required fields is missing (type, dayType, or the minutes of openingHours/serviceHours).

must be greater than or equal to 0 / must be less than or equal to 1439

One of the minute fields is outside the allowed range (0 to 1439).

contained_service_time

The break time (restHours) must be contained within the opening hours (openingHours).

invalid_service_time_rest

The break times (restHours) overlap each other, or the opening hours are not valid.

409 Conflict

-

A conflict occurred while saving the service time. It is recommended to check that the data sent does not violate any integrity constraint.

What is a service? And what is a service time?

What is a day type?