Error 'Booking duration is shorter than required'

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

{
  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.

{
  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.

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.

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

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

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

Request Data

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

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

@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.

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

@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

{
	"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:

{
    "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.

{
  "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.

@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

{
  "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.

{
  "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?

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

{
    "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.