01-17-2021 09:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-17-2021 09:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
When making a Sleep Log request we get this error - "Duration is out of bounds". It looks like a Sleep Log with a duration less than 10 minutes causes this error. Is that correct? Is 10 minutes the minimum duration for a sleep log?
Thanks,
Chris
Answered! Go to the Best Answer.
Accepted Solutions
01-20-2021 09:13 - edited 01-20-2021 09:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-20-2021 09:13 - edited 01-20-2021 09:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @bickster
It looks like a sleep log needs to have a length between 10 and 1440 minutes. I tried to manually enter a sleep log through the web site and got this message.
We will make certain to include this requirement in the documentation.
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

01-19-2021 11:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-19-2021 11:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @bickster
I'm not aware of a sleep duration less than 10 minutes causing a "duration out of bounds" error. Would you please post the endpoint that you're executing and the exact status code and error message that you're receiving?
Thanks!
Gordon
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

01-19-2021 15:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-19-2021 15:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
POST:https://api.fitbit.com/1.2/user/-/sleep.json
2021-01-17 11:36:02.219 PARAMS:{
date = "2020-12-20";
duration = 510000;
startTime = "23:26";
}
2021-01-17 11:36:02.219 +[FitbitApiHelper getSessionManager:]
2021-01-17 11:36:02.377 POST:FAILURE:{"errors":[{"errorType":"validation","fieldName":"date/startTime","message":"Duration is out of bounds"}]}:https://api.fitbit.com/1.2/user/-/sleep.json
{
"Accept-Language" = "en-US;q=1, de-US;q=0.9";
Authorization = "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIyMjg1MzgiLCJzdWIiOiI1UDZZTUMiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZXMiOiJ3cHJvIHdudXQgd3NsZSB3d2VpIHdhY3Qgd3NldCIsImV4cCI6MTYxMjY1Njc2MiwiaWF0IjoxNjEwNTg3MDQzfQ.mroqj-95KS2fIC3rYb7_MegM53hTsuMsUawQRV3s0oU";
"Content-Type" = "application/x-www-form-urlencoded";
} COMPLETE ERROR: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo={NSLocalizedDescription=Request failed: bad request (400), NSErrorFailingURLKey=https://api.fitbit.com/1.2/user/-/sleep.json , com.alamofire.serialization.response.error.data={length = 106, bytes = 0x7b226572 726f7273 223a5b7b 22657272 ... 756e6473 227d5d7d }, com.alamofire.serialization.response.error.response= 0x283ec7100=""> { URL: https://api.fitbit.com/1.2/user/-/sleep.json } { Status Code: 400, Headers {
"Cache-Control" = (
"no-cache, private"
);
"Content-Encoding" = (
gzip
);
"Content-Language" = (
en
);
"Content-Type" = (
"application/json;charset=UTF-8"
);
Date = (
"Sun, 17 Jan 2021 16:36:02 GMT"
);
Server = (
cloudflare
);
Vary = (
"Origin,Accept-Encoding"
);
Via = (
"1.1 google"
);
"cf-cache-status" = (
DYNAMIC
);
"cf-ray" = (
"61317e2a4971efe4-EWR"
);
"cf-request-id" = (
07b2cd2e6e0000efe481b33000000001
);
"expect-ct" = (
"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" );
"fitbit-rate-limit-limit" = (
150
);
"fitbit-rate-limit-remaining" = (
150
);
"fitbit-rate-limit-reset" = (
1438
);
"x-frame-options" = (
SAMEORIGIN
);
} }}

01-20-2021 09:13 - edited 01-20-2021 09:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-20-2021 09:13 - edited 01-20-2021 09:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @bickster
It looks like a sleep log needs to have a length between 10 and 1440 minutes. I tried to manually enter a sleep log through the web site and got this message.
We will make certain to include this requirement in the documentation.
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

01-20-2021 15:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-20-2021 15:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

