# Error 'Booking duration is shorter than required'

**URL:** <https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388>\
**Category:** API\
**Created:** [September 8, 2023, 3:59pm UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388 "2023-09-08T15:59:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kametter](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@kametter](https://forum.youcanbook.me/u/kametter)\
**Post date:** [September 8, 2023, 3:59pm UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/1 "2023-09-08T15:59:48Z")

</div>

After updating to the new version of the calendar, I’ve started to receive the following error from the Bookings API:

```auto
{
  code: 'ycbm_api_booking_invalid_duration_too_short',
  errors: [],
  httpCode: 400,
  httpStatusCode: 400,
  message: 'Booking duration is shorter than required',
  status: 'BAD_REQUEST',
  type: 'YcbmApiException'
}

```

I can guess from the content that the duration you are trying to book is short.  
However, the duration in the profile is set at 30 minutes,  
The bookings API is populated as follows.

```auto
{
  startsAt: "2023-09-08 12:00:00",
  timeZone: "Asia/Tokyo",
  units: 1,
  numberOfSlots: 1,
  answers: [
    ...answer values
  ]
}

```

Any guidance on how to resolve this would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [September 12, 2023, 3:20pm UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/2 "2023-09-12T15:20:04Z")

</div>

I reached our through a direct message. I would need to know the API endpoint you are using, and how you are making the request.

---

<div class="post-metadata">

**Author:** ![kametter](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@kametter](https://forum.youcanbook.me/u/kametter)\
**Post date:** [September 15, 2023, 10:27am UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/3 "2023-09-15T10:27:02Z")

</div>

I sent the endpoint and the request content via direct message.  
Please confirm.

---

<div class="post-metadata">

**Author:** ![kametter](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@kametter](https://forum.youcanbook.me/u/kametter)\
**Post date:** [September 17, 2023, 12:52pm UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/4 "2023-09-17T12:52:31Z")

</div>

I recently sent details about the API via direct message, but I’m also posting a part of the content here in this topic.

API endpoints

```auto
https://api.youcanbook.me/v1/profiles/[profileId]/bookings

```

Request Data

```auto
{
  startsAt: '2023-09-15T10:00:00',
  timeZone: 'Asia/Tokyo',
  units: 1,
  numberOfSlots: 1,
  answers: [
    ...some answers
  ]
}

```

---

<div class="post-metadata">

**Author:** ![kametter](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@kametter](https://forum.youcanbook.me/u/kametter)\
**Post date:** [September 25, 2023, 3:00am UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/5 "2023-09-25T03:00:51Z")

</div>

Please let me know if there is any other information you need.  
I am really in need of help.

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [September 26, 2023, 5:17pm UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/6 "2023-09-26T17:17:22Z")

</div>

@kametter I am sorry on the delay. I will send you a direct message with some information on the new way to interact with bookings using our intents model.

---

<div class="post-metadata">

**Author:** ![Nao](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@Nao](https://forum.youcanbook.me/u/Nao)\
**Post date:** [March 28, 2024, 8:02am UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/7 "2024-03-28T08:02:57Z")

</div>

Could you tell me how to use the intents model?  
Or if there is documentation, could you please share it with me?

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [March 28, 2024, 12:06pm UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/8 "2024-03-28T12:06:46Z")

</div>

@Nao we are working on updating documentation, that will have some information around booking intents. At a highlevel you first make a POST to: [https://api.youcanbook.me/v1/intents](https://api.youcanbook.me/v1/intents)

```auto
{
	"subdomain": "t2eqsdqw",
	"selections": {
		"timeZone": "Europe/Madrid"
	}
}

```

Change the subdomain you want to book through and the timezone, for the selections you can also pass in additional information there or use the returned intentId and PATCH in:

```auto
{
    "appointmentTypeIds" : ["jsid213858"],
    "duration" : null,
    "form" : [ {
      "id" : "LNAME",
      "value" : "Test"
    }, {
      "id" : "EMAIL",
      "value" : "ben@domain.com"
    }, {
      "id" : "FNAME",
      "value" : "Ben"
    } ],
    "startsAt" : null,
    "teamMemberId" : "AUTO",
    "timeZone" : "Europe/Madrid",
    "units" : null
  }

```

These selections can be done via PATCH to /v1/intents/{intentId}/selections

To get start time you can use the Availability Endpoint. To do this after you have setup your intent with a timezone, you can GET the availability here: `https://api.youcanbook.me/v1/intents/{intentId}/availabilitykey`

That will return an Availability key, which you use as a GET here:  
`https://api.youcanbook.me/v1/availabilities/{availbilityKey}`

This will return the Unix timestamp of availability based off of the selections you have made in the intent.

```auto
{
  "slots" : [ {
    "freeUnits" : 1,
    "startsAt" : "1691588700000"
  }, {
    "freeUnits" : 1,
    "startsAt" : "1691589600000"
  }
}

```

With the time you can PATCH into the selections of your intent: “startsAt”: “1691588700000” or any other time you get from the Availability Endpoint. Then confirm with a PATCH to:  
`https://api.youcanbook.me/v1/intents/{intentId}/confirm`

Feel free to send me a message here if you have specific questions.

---

<div class="post-metadata">

**Author:** ![Nao](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@Nao](https://forum.youcanbook.me/u/Nao)\
**Post date:** [April 3, 2024, 9:04am UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/9 "2024-04-03T09:04:44Z")

</div>

@Ben  
Thanks for sharing information about intents model.  
I have some questions.

1. About endpoint for updating selections  
Is `PATCH https://api.youcanbook.me/v1/intents/{intentId}/selections` right?

2. Update selections not working  
I sent the following values to `PATCH https://api.youcanbook.me/v1/intents/{intentId}/selections`

```auto
{
  "selections": {
    "form": [
      {
        "id": "LNAME",
        "value": "TestLNAME"
      },
      {
        "id": "FNAME",
        "value": "TestFNAME"
      },
      {
        "id": "EMAIL",
        "value": "test@nexample"
      }
    ],
    "startsAt": 1712185200000
  }
}

```

But the response came back with the following.

```auto
{
  "bookingId" : null,
  "createdAt" : 1712134789000,
  "id" : "itt_0f3cd464-c659-44d5-9fe1-c505a5201dc7",
  "intentStatus" : "SETTING_UP",
  "selections" : {
    "appointmentTypeIds" : null,
    "duration" : null,
    "form" : null,
    "startsAt" : null,
    "teamMemberId" : null,
    "timeZone" : "Asia/Tokyo",
    "units" : null
  }
}

```

The value of selections does not appear to be updated.  
Could you help me?

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [April 3, 2024, 4:46pm UTC](https://forum.youcanbook.me/t/error-booking-duration-is-shorter-than-required/2388/10 "2024-04-03T16:46:39Z")

</div>

In your PATCH payload to /selections only send in this:

```auto
{
    "form": [
      {
        "id": "LNAME",
        "value": "TestLNAME"
      },
      {
        "id": "FNAME",
        "value": "TestFNAME"
      },
      {
        "id": "EMAIL",
        "value": "test@nexample.com"
      }
    ],
    "startsAt": 1712185200000
  }

```

Also I added a .com to your email address, as this needs to be a valid email to process the change. I ran this on your intentId and it updated successfully.
