> For the complete documentation index, see [llms.txt](https://stroheimdesign.gitbook.io/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stroheimdesign.gitbook.io/api/methods.md).

# Methods

## Reservations

## Get Reservations

<mark style="color:blue;">`GET`</mark> `https://yourdomain.com/apibaseurl/reservations/get/`

Get reservation entries.

#### Query Parameters

| Name      | Type    | Description                                                                                   |
| --------- | ------- | --------------------------------------------------------------------------------------------- |
| past      | Boolean | If **TRUE**, returned entries will include past reservations. Default is **FALSE**.           |
| providers | String  | Comma-separated Provider IDs.                                                                 |
| services  | String  | Comma-separated Service IDs.                                                                  |
| customers | String  | Comma-separated Customer IDs.                                                                 |
| status    | String  | Status of the requsted reservations. Possible values are "pending", "confirmed", "cancelled". |
| full      | Boolean | If **TRUE**, returned entries will include all the metadata. Default is **FALSE**.            |

#### Headers

| Name                                             | Type   | Description                   |
| ------------------------------------------------ | ------ | ----------------------------- |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer) |

{% tabs %}
{% tab title="200 Reservations successfully retrieved. " %}
{% tabs %}
{% tab title="Response" %}

```
{
    "response": [
      {
        "id" : "r_MP4WdkOw32TSain2tjORQFD3KPikzWTp",
        "db_id" :  "13",
        "serviceId" : "s_AO4WdkOw32XSyrn2tjORQFD4KPikzWTK",
        "providerId" : 3
        "customerId" : "c_AO4WdkOw32XSyrn2tjORQFD4KPikzWTK",
        "start" : 1567949246
        "end" : 1567949564,
        "status" : "confirmed",
        "created" : 1567949246
      },
      {
        "id" : "r_MP4WdkOw32TSain2tjORQFD3KPikzWTp",
        "db_id" :  "15",
        "serviceId" : "s_AO4WdkOw32XSyrn2tjORQFD4KPikzWTK",
        "providerId" : 2
        "customerId" : "c_AO4WdkOw32XSyrn2tjORQFD4KPikzWTK",
        "start" : 1567949246
        "end" : 1567949564,
        "status" : "cancelled",
        "created" : 1567949246
      },
      ...
    ]
}
```

{% endtab %}

{% tab title="Response with full data" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## Add Reservation

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/reservations/add/`

This endpoint allows you to create a reservation.

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                          | Type   | Description                                          |
| --------------------------------------------- | ------ | ---------------------------------------------------- |
| reservation<mark style="color:red;">\*</mark> | Object | The **reservation object** that needs to be created. |

{% tabs %}
{% tab title="200 Reservation record succesfully created." %}

{% endtab %}
{% endtabs %}

## Edit reservation

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/reservations/edit/`

This endpoint allows you to edit a reservation entry.

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                          | Type   | Description                                                                                                                |
| --------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------- |
| reservation<mark style="color:red;">\*</mark> | Object | The edited **reservation object** (can be partial, but it *must* contain the ID at least, otherwise an error is returned). |

{% tabs %}
{% tab title="200 Reservation record succesfully edited." %}

{% endtab %}
{% endtabs %}

## Remove reservation

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/reservations/remove/`

This endpoint allows you to remove a reservation from the database. The operation won't trigger any event down the line. \
An error is returned if the reservation is confirmed or pending. If you need to remove a database record of a reservation which is confirmed or pending, edit it first.

#### Query Parameters

| Name                                 | Type   | Description                                     |
| ------------------------------------ | ------ | ----------------------------------------------- |
| id<mark style="color:red;">\*</mark> | String | ID of the reservation that needs to be deleted. |

#### Headers

| Name                                             | Type   | Description                                                                                        |
| ------------------------------------------------ | ------ | -------------------------------------------------------------------------------------------------- |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations, otherwise an error is returned. |

{% tabs %}
{% tab title="200 Reservation record succesfully deleted." %}

{% endtab %}

{% tab title="304 Reservation is confirmed or pending." %}

{% endtab %}

{% tab title="404 Reservation entry not found." %}

{% endtab %}
{% endtabs %}

## Services

## Get Services

<mark style="color:blue;">`GET`</mark> `https://yourdomain.com/apibaseurl/services/get/`

This endpoint allows you to get service entries.

#### Query Parameters

| Name | Type    | Description                                                                   |
| ---- | ------- | ----------------------------------------------------------------------------- |
| full | Boolean | If **TRUE**, the entries will include all the metadata. Default is **FALSE**. |

#### Headers

| Name                                             | Type   | Description                   |
| ------------------------------------------------ | ------ | ----------------------------- |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer) |

{% tabs %}
{% tab title="200 Services succesfully retrieved." %}

```javascript
{
    "entries" : [
        {
            "type" : "service",
            "id" : "music-class",
            "name" : "Music Class",
            "color" : "#81D742",
            "class" : "appointment",
            "description" : "Violin music class",
            "isActive" : true,
            "bookable" : "everyone",
            "location" : {
                "setting" : "fixed",
                "address" : "Empire State Building, 5th Avenue, New York"
            },
            "redirectURL" : "http://www.hello.com",
            "notificationEmailAdmin": {
                "send" : true,
                "address" : "admin@example.com",
                "subject" : "Just got a new reservation",
                "body" : "<p>e-mail message body</p>"
            },
            "notificationEmailCustomer": {
                "send" : true,
                "subject" : "Just got a new reservation",
                "body" : "<p>e-mail message body</p>"
            },
            "reminderEmail": {
                "send" : false,
                "subject" : "Don't forget your reservation",
                "body" : "We are getting close!"
            },
            "cancellationByCustomer" : {
                "allow" : false
            }
            "payments" : {
                "fares" : {
                    "normal" : {
                        "name" : "Regular fare",
                        "desc" : "Regular fare",
                        "price" : 10
                    },
                    "fare_1" : {
                        "name" : "Super fare",
                        "desc" : "Super fare",
                        "price" : 14
                    }
                },
                "required" : "immediately"
            },
            "approval": {
                "requireFrom" : "admin",
                "keepFreeUntilApproval": false
            }
        }
    ]
}

```

{% endtab %}
{% endtabs %}

## Add Service

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/services/add/`

This endpoint allows you to create a service.

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                      | Type   | Description                                      |
| ----------------------------------------- | ------ | ------------------------------------------------ |
| service<mark style="color:red;">\*</mark> | Object | The **service object** that needs to be created. |

{% tabs %}
{% tab title="200 Service record succesfully created." %}

{% endtab %}
{% endtabs %}

## Edit service

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/services/edit/`

This endpoint allows you to edit a service entry.

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                      | Type   | Description                                                                                                            |
| ----------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------- |
| service<mark style="color:red;">\*</mark> | Object | The edited **service object** (can be partial, but it *must* contain the ID at least, otherwise an error is returned). |

{% tabs %}
{% tab title="200 Service record succesfully edited." %}

{% endtab %}
{% endtabs %}

## Remove service

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/services/remove/`

This endpoint allows you to remove a service from the database.\
An error is returned if there are reservations in place for the service.

#### Query Parameters

| Name                                 | Type   | Description                                 |
| ------------------------------------ | ------ | ------------------------------------------- |
| id<mark style="color:red;">\*</mark> | String | ID of the service that needs to be deleted. |

#### Headers

| Name                                             | Type   | Description                                                                                        |
| ------------------------------------------------ | ------ | -------------------------------------------------------------------------------------------------- |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations, otherwise an error is returned. |

{% tabs %}
{% tab title="200: OK Service record succesfully deleted." %}

{% endtab %}

{% tab title="403: Forbidden There are reservations for the service." %}

{% endtab %}

{% tab title="404: Not Found Service entry not found." %}

{% endtab %}
{% endtabs %}

## Providers

## Get Providers

<mark style="color:blue;">`GET`</mark> `https://yourdomain.com/apibaseurl/providers/get/`

This endpoint allows you to get providers entries.

#### Headers

| Name                                             | Type   | Description                   |
| ------------------------------------------------ | ------ | ----------------------------- |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer) |

{% tabs %}
{% tab title="200 Providers succesfully retrieved." %}

```javascript
{
    "entries" : [
        {
            "type" : "service",
            "id" : "music-class",
            "name" : "Music Class",
            "color" : "#81D742",
            "class" : "appointment",
            "description" : "Violin music class",
            "isActive" : true,
            "bookable" : "everyone",
            "location" : {
                "setting" : "fixed",
                "address" : "Empire State Building, 5th Avenue, New York"
            },
            "redirectURL" : "http://www.hello.com",
            "notificationEmailAdmin": {
                "send" : true,
                "address" : "admin@example.com",
                "subject" : "Just got a new reservation",
                "body" : "<p>e-mail message body</p>"
            },
            "notificationEmailCustomer": {
                "send" : true,
                "subject" : "Just got a new reservation",
                "body" : "<p>e-mail message body</p>"
            },
            "reminderEmail": {
                "send" : false,
                "subject" : "Don't forget your reservation",
                "body" : "We are getting close!"
            },
            "cancellationByCustomer" : {
                "allow" : false
            }
            "payments" : {
                "fares" : {
                    "normal" : {
                        "name" : "Regular fare",
                        "desc" : "Regular fare",
                        "price" : 10
                    },
                    "fare_1" : {
                        "name" : "Super fare",
                        "desc" : "Super fare",
                        "price" : 14
                    }
                },
                "required" : "immediately"
            },
            "approval": {
                "requireFrom" : "admin",
                "keepFreeUntilApproval": false
            }
        }
    ]
}

```

{% endtab %}
{% endtabs %}

## Edit Provider

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/providers/edit/`

This endpoint allows you to edit a provider entry.

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                       | Type   | Description                                                                                                             |
| ------------------------------------------ | ------ | ----------------------------------------------------------------------------------------------------------------------- |
| provider<mark style="color:red;">\*</mark> | Object | The edited **provider object** (can be partial, but it *must* contain the ID at least, otherwise an error is returned). |

{% tabs %}
{% tab title="200: OK Provider record succesfully edited." %}

{% endtab %}
{% endtabs %}

## Edit Provider Service settings

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/providers/edit/service/`

This endpoint allows you to edit provider service settings.

#### Query Parameters

| Name                                        | Type   | Description            |
| ------------------------------------------- | ------ | ---------------------- |
| serviceId<mark style="color:red;">\*</mark> | String | The ID of the service  |
| providerId                                  | String | The ID of the provider |

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                       | Type   | Description                                                       |
| ------------------------------------------ | ------ | ----------------------------------------------------------------- |
| settings<mark style="color:red;">\*</mark> | Object | The edited **provider service settings object** (can be partial). |

{% tabs %}
{% tab title="200: OK Provider service settings succesfully edited." %}

{% endtab %}
{% endtabs %}

## Customers

## Get Customers

<mark style="color:blue;">`GET`</mark> `https://yourdomain.com/apibaseurl/customers/get/`

This endpoint allows you to get customers entries.

#### Headers

| Name                                             | Type   | Description                   |
| ------------------------------------------------ | ------ | ----------------------------- |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer) |

{% tabs %}
{% tab title="200 Customers succesfully retrieved." %}

```javascript
{
    "entries" : [
        {
            "type" : "service",
            "id" : "music-class",
            "name" : "Music Class",
            "color" : "#81D742",
            "class" : "appointment",
            "description" : "Violin music class",
            "isActive" : true,
            "bookable" : "everyone",
            "location" : {
                "setting" : "fixed",
                "address" : "Empire State Building, 5th Avenue, New York"
            },
            "redirectURL" : "http://www.hello.com",
            "notificationEmailAdmin": {
                "send" : true,
                "address" : "admin@example.com",
                "subject" : "Just got a new reservation",
                "body" : "<p>e-mail message body</p>"
            },
            "notificationEmailCustomer": {
                "send" : true,
                "subject" : "Just got a new reservation",
                "body" : "<p>e-mail message body</p>"
            },
            "reminderEmail": {
                "send" : false,
                "subject" : "Don't forget your reservation",
                "body" : "We are getting close!"
            },
            "cancellationByCustomer" : {
                "allow" : false
            }
            "payments" : {
                "fares" : {
                    "normal" : {
                        "name" : "Regular fare",
                        "desc" : "Regular fare",
                        "price" : 10
                    },
                    "fare_1" : {
                        "name" : "Super fare",
                        "desc" : "Super fare",
                        "price" : 14
                    }
                },
                "required" : "immediately"
            },
            "approval": {
                "requireFrom" : "admin",
                "keepFreeUntilApproval": false
            }
        }
    ]
}

```

{% endtab %}
{% endtabs %}

## Add Customer

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/customers/add/`

This endpoint allows you to create a customer.

#### Query Parameters

| Name       | Type    | Description                                                                  |
| ---------- | ------- | ---------------------------------------------------------------------------- |
| createUser | Boolean | If **TRUE**, a WordPress user will be created as well. Default is **FALSE**. |

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                       | Type   | Description                                       |
| ------------------------------------------ | ------ | ------------------------------------------------- |
| customer<mark style="color:red;">\*</mark> | Object | The **customer object** that needs to be created. |

{% tabs %}
{% tab title="201: Created Customer record succesfully created. ID of the new customer is returned." %}

```json
{
    "id": "c_XXXXXXXXXXX"
}
```

{% endtab %}
{% endtabs %}

## Edit Customer

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/customer/edit/`

This endpoint allows you to edit a customer entry.

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

#### Request Body

| Name                                       | Type   | Description                                                                                                             |
| ------------------------------------------ | ------ | ----------------------------------------------------------------------------------------------------------------------- |
| customer<mark style="color:red;">\*</mark> | Object | The edited **customer object** (can be partial, but it *must* contain the ID at least, otherwise an error is returned). |

{% tabs %}
{% tab title="200 Customer record succesfully edited." %}

{% endtab %}
{% endtabs %}

## Remove Customer

<mark style="color:green;">`POST`</mark> `https://yourdomain.com/apibaseurl/customers/remove/`

This endpoint allows you to remove a customer from the database.\
An error is returned if there are reservations in place for the customer.

#### Query Parameters

| Name                                 | Type   | Description                                  |
| ------------------------------------ | ------ | -------------------------------------------- |
| id<mark style="color:red;">\*</mark> | String | ID of the customer that needs to be deleted. |

#### Headers

| Name                                             | Type   | Description                                                        |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------ |
| Authentication<mark style="color:red;">\*</mark> | String | Authentication token (Bearer). It must allow **write** operations. |

{% tabs %}
{% tab title="200: OK Customer record succesfully deleted." %}

{% endtab %}

{% tab title="403: Forbidden There are reservations for the customer." %}

{% endtab %}

{% tab title="404: Not Found Customer not found." %}

{% endtab %}
{% endtabs %}

## Availability

## Get Availability

<mark style="color:blue;">`GET`</mark> `https://yourdomain.com/apibaseurl/availability/get/`

This endpoint allows you to get timeslot entries (services of **Unscheduled** type are excluded).

#### Query Parameters

| Name                                             | Type   | Description                                                                         |
| ------------------------------------------------ | ------ | ----------------------------------------------------------------------------------- |
| max\_timestamp<mark style="color:red;">\*</mark> | Int    | Unix time. The returned set will contain only timeslots that end before this time.  |
| min\_timestamp<mark style="color:red;">\*</mark> | Int    | Unix time. The returned set will contain only timeslots that start after this time. |
| services                                         | String | Comma-separated Service IDs.                                                        |
| providers                                        | String | Comma-separated Provider IDs.                                                       |

#### Headers

| Name                                             | Type   | Description                   |
| ------------------------------------------------ | ------ | ----------------------------- |
| Authentication<mark style="color:red;">\*</mark> | string | Authentication token (Bearer) |

{% tabs %}
{% tab title="200: OK Succesful response." %}

```json
"entries" : [
    {
            "serviceId": "music-class",
            "start": 1568253600,
            "end": 1568257200,
            "providerId": 1,
            "isFull": false,
            "isAllday": false,
            "location": "Empire State Building, 5th Avenue, New York",
            "timezone": "America/New_York",
            "fares": {
                "normal": 10,
                "fare_1": 14
            },
            "max_tickets": 6,
            "bookableUntil": 1568250000,
            "readOnly": false,
            "paddingAfter": 0
        }
]
```

{% endtab %}
{% endtabs %}
