# Bookings

## To Fetch Bookings

## Get Bookings

<mark style="color:blue;">`GET`</mark> `https://app.appointo.me/api/bookings`

Fetch Bookings

#### Query Parameters

| Name         | Type    | Description                                                                     |
| ------------ | ------- | ------------------------------------------------------------------------------- |
| limit        | integer | Limit (max limit: 100. default limit: 100)                                      |
| offset       | integer | Offset                                                                          |
| status       | string  | `past` \| `upcoming`                                                            |
| booking\_id  | integer | to fetch single booking                                                         |
| search\_term | string  | (Optional) Searches on product name, customer name, email, phone and order name |

#### Headers

| Name                                             | Type   | Description        |
| ------------------------------------------------ | ------ | ------------------ |
| APPOINTO-TOKEN<mark style="color:red;">\*</mark> | string | Appointo API token |

{% tabs %}
{% tab title="200 Booking successfully fetched" %}

```json
[
  {
    "id": 969,
    "selected_time": "2023-07-20T00:00:00.000Z",
    "timestring": "2023-07-20",
    "shop_id": 135,
    "appointment_id": 299,
    "created_at": "2023-07-18T16:33:17.565Z",
    "updated_at": "2023-07-18T16:33:18.236Z",
    "customers_count": 1,
    "duration": 30,
    "product_name": "T-shirt",
    "variant_name": "T-shirt - s",
    "order_uuid": "-",
    "price": "",
    "order_name": "-",
    "currency": "",
    "meeting_detail": "",
    "note": "",
    "google_meta": {},
    "google_event_id": "o0sc5qt4dg70u9sghg4hmfgul8",
    "location_value": null,
    "location_type": null,
    "location_meta": null,
    "quantity": 1,
    "team_member_id": null,
    "scenario": "multi_day",
    "day_duration": 1,
    "end_date": "2023-07-20",
    "start_date": "2023-07-20",
    "group_id": null,
    "start_buffer_time": 0,
    "end_buffer_time": 0,
    "category": null,
    "archived": false,
    "notes_count": 0,
    "customers": [
      {
        "id": 1095,
        "email": "abc@xyz.com",
        "payload": {
          "phone": ""
        },
        "name": "Mukul Chaware",
        "shop_id": 135,
        "appointment_id": 299,
        "booking_id": 969,
        "created_at": "2023-07-18T16:33:17.593Z",
        "updated_at": "2023-07-18T16:33:17.593Z",
        "customer_uuid": "6943848005916",
        "reschedule_uuid": null,
        "cancel_uuid": null,
        "order_name": "-",
        "order_uuid": null,
        "shipping_address": {
          "id": 9180953739548,
          "customer_id": 6943848005916,
          "first_name": "ABC",
          "last_name": "TTT",
          "company": null,
          "address1": "ABC",
          "address2": null,
          "city": "Bangalore",
          "province": "Karnataka",
          "country": "India",
          "zip": "111111",
          "phone": null,
          "name": "ABC TTT",
          "province_code": "KA",
          "country_code": "IN",
          "country_name": "India",
          "default": true
        },
        "override": false,
        "signpanda_cust_uuid": null,
        "parent_customer_id": null,
        "is_active_sub": false,
        "sub_interval": null,
        "sub_booking_count": null,
        "sub_booking_num": null,
        "sub_recurring_type": null,
        "customer_type": null,
        "customer_timezone": null,
        "archived": false,
        "subscription_contract_id": null,
        "selling_plan_id": null,
        "checkin": false,
        "checkin_qr_code": null,
        "image_data": null
      }
    ],
    "archived_customers": [],
    "appointment": {
      "id": 299,
      "activate": null,
      "product_uuid": "gid://shopify/Product/7971637428508",
      "duration_uuid": "gid://shopify/ProductVariant/43666758828316",
      "shop_id": 135,
      "product_detail_id": 141,
      "name": "T-shirt - s",
      "is_combo_service": false,
      "price": "100.0",
      "currency": "USD",
      "description": null,
      "archived": false
    }
  }
]
```

{% endtab %}

{% tab title="401 Permission denied" %}
{"error\_code":"invalid\_api\_token","message":"API token is invalid. Please check token in Appointo settings."}
{% endtab %}
{% endtabs %}

## To Create New Booking

## Create New Booking

<mark style="color:green;">`POST`</mark> `https://app.appointo.me/api/bookings`

Create new Booking (max. 100 requests per day)

#### Headers

| Name                                             | Type   | Description        |
| ------------------------------------------------ | ------ | ------------------ |
| APPOINTO-TOKEN<mark style="color:red;">\*</mark> | string | Appointo API token |

#### Request Body

| Name                                              | Type     | Description                              |
| ------------------------------------------------- | -------- | ---------------------------------------- |
| appointment\_id<mark style="color:red;">\*</mark> | integer  | Appointo Appointment Id                  |
| timestring<mark style="color:red;">\*</mark>      | datetime | Timestring for timeslot (iso8601 string) |
| quantity                                          | integer  | Number of bookings. Default: 1           |
| email<mark style="color:red;">\*</mark>           | string   | Email of the customer                    |
| name<mark style="color:red;">\*</mark>            | string   | Name of the customer                     |
| phone                                             | string   | phone number of the customer             |

{% tabs %}
{% tab title="200 Booking successfully created" %}

```json
[
  {
    "id": 969,
    "selected_time": "2023-07-20T00:00:00.000Z",
    "timestring": "2023-07-20",
    "shop_id": 135,
    "appointment_id": 299,
    "created_at": "2023-07-18T16:33:17.565Z",
    "updated_at": "2023-07-18T16:33:18.236Z",
    "customers_count": 1,
    "duration": 30,
    "product_name": "T-shirt",
    "variant_name": "T-shirt - s",
    "order_uuid": "-",
    "price": "",
    "order_name": "-",
    "currency": "",
    "meeting_detail": "",
    "note": "",
    "google_meta": {},
    "google_event_id": "o0sc5qt4dg70u9sghg4hmfgul8",
    "location_value": null,
    "location_type": null,
    "location_meta": null,
    "quantity": 1,
    "team_member_id": null,
    "scenario": "multi_day",
    "day_duration": 1,
    "end_date": "2023-07-20",
    "start_date": "2023-07-20",
    "group_id": null,
    "start_buffer_time": 0,
    "end_buffer_time": 0,
    "category": null,
    "archived": false,
    "notes_count": 0,
    "customers": [
      {
        "id": 1095,
        "email": "abc@xyz.com",
        "payload": {
          "phone": ""
        },
        "name": "Mukul Chaware",
        "shop_id": 135,
        "appointment_id": 299,
        "booking_id": 969,
        "created_at": "2023-07-18T16:33:17.593Z",
        "updated_at": "2023-07-18T16:33:17.593Z",
        "customer_uuid": "6943848005916",
        "reschedule_uuid": null,
        "cancel_uuid": null,
        "order_name": "-",
        "order_uuid": null,
        "shipping_address": {
          "id": 9180953739548,
          "customer_id": 6943848005916,
          "first_name": "ABC",
          "last_name": "TTT",
          "company": null,
          "address1": "ABC",
          "address2": null,
          "city": "Bangalore",
          "province": "Karnataka",
          "country": "India",
          "zip": "111111",
          "phone": null,
          "name": "ABC TTT",
          "province_code": "KA",
          "country_code": "IN",
          "country_name": "India",
          "default": true
        },
        "override": false,
        "signpanda_cust_uuid": null,
        "parent_customer_id": null,
        "is_active_sub": false,
        "sub_interval": null,
        "sub_booking_count": null,
        "sub_booking_num": null,
        "sub_recurring_type": null,
        "customer_type": null,
        "customer_timezone": null,
        "archived": false,
        "subscription_contract_id": null,
        "selling_plan_id": null,
        "checkin": false,
        "checkin_qr_code": null,
        "image_data": null
      }
    ],
    "archived_customers": [],
    "appointment": {
      "id": 299,
      "activate": null,
      "product_uuid": "gid://shopify/Product/7971637428508",
      "duration_uuid": "gid://shopify/ProductVariant/43666758828316",
      "shop_id": 135,
      "product_detail_id": 141,
      "name": "T-shirt - s",
      "is_combo_service": false,
      "price": "100.0",
      "currency": "USD",
      "description": null,
      "archived": false
    }
  }
]
```

{% endtab %}

{% tab title="401: Unauthorized Permission denied" %}
{"error\_code":"invalid\_api\_token","message":"API token is invalid. Please check token in Appointo settings."}
{% endtab %}

{% tab title="400: Bad Request Invalid field error" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Reschedule Booking

<mark style="color:green;">`PUT`</mark> `https://app.appointo.me/api/bookings/reschedule`

Reschedule Booking (max. 100 requests per day)

#### Headers

| Name                                             | Type   | Description        |
| ------------------------------------------------ | ------ | ------------------ |
| APPOINTO-TOKEN<mark style="color:red;">\*</mark> | string | Appointo API token |

#### Request Body

| Name                                          | Type     | Description                                                                                                        |
| --------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------ |
| booking\_id<mark style="color:red;">\*</mark> | integer  | Booking Id to reschedule                                                                                           |
| timestring<mark style="color:red;">\*</mark>  | datetime | Timestring for timeslot (iso8601 string)                                                                           |
| customer\_ids                                 | array    | Array of customer ids to reschedule (Optional). if customer ids are not sent, it will reschedule the whole booking |
| override                                      | boolean  | default: *false*. If true, it will forcefully reschedule for above timeslot                                        |

{% tabs %}
{% tab title="200 Booking successfully rescheduled" %}

```json
{
response: {
 status: "ok",
 booking: {
 ....
 }
}
}
```

{% endtab %}
{% endtabs %}

## Cancel Booking

<mark style="color:green;">`PUT`</mark> `https://app.appointo.me/api/bookings/cancel`

Cancel Booking (max. 100 requests per day)

#### Headers

| Name                                             | Type   | Description        |
| ------------------------------------------------ | ------ | ------------------ |
| APPOINTO-TOKEN<mark style="color:red;">\*</mark> | string | Appointo API token |

#### Request Body

| Name                                          | Type    | Description                                                                                                |
| --------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| booking\_id<mark style="color:red;">\*</mark> | integer | Booking Id to reschedule                                                                                   |
| customer\_ids                                 | array   | Array of customer ids to cancel (Optional). if customer ids are not sent, it will cancel the whole booking |

{% tabs %}
{% tab title="200 Booking successfully rescheduled" %}

```json
{
response: {
 status: "ok",
 booking: {
 ....
 }
}
}
```

{% endtab %}
{% endtabs %}

## Update Booking

<mark style="color:green;">`PUT`</mark> `https://app.appointo.me/api/bookings/:booking_id`

Update Booking (max. 100 requests per day)

#### Headers

| Name                                             | Type   | Description        |
| ------------------------------------------------ | ------ | ------------------ |
| APPOINTO-TOKEN<mark style="color:red;">\*</mark> | string | Appointo API token |

#### Request Body

| Name                                          | Type    | Description                              |
| --------------------------------------------- | ------- | ---------------------------------------- |
| booking\_id<mark style="color:red;">\*</mark> | integer | Booking Id to reschedule                 |
| start\_buffer\_time                           | integer | Start Buffer Time for the booking ( > 0) |
| end\_buffer\_time                             | integer | End Buffer Time for the booking (> 0)    |

{% tabs %}
{% tab title="200 Booking successfully rescheduled" %}

```json
{
response: {
 status: "ok",
 booking: {
 ....
 }
}
}
```

{% endtab %}
{% endtabs %}
