[POST] Reanalyze Session

Re-runs the sleep analysis of a specific session. If you specify an analysis range with start_time/end_time, the session is re-analyzed based on that range.

The analysis range information of a session with a specified analysis range can be checked via the analysis object of Get Session (v4).

Request

URL

POST https://api.asleep.ai/data/v1/sessions/{session_id}/reanalyze

Header

FieldTypeRequiredDescription
x-api-keyStringOAPI Key
x-user-idStringOIssued user id

Path parameter

FieldTypeRequiredDescription
session_idStringOid of the session you want to re-analyze

Body

  • Both start_time and end_time must be in UTC.
  • start_time must be before end_time.
FieldTypeRequiredDescription
start_timeString (YYYY-MM-DDThh:mm:ss+00:00)?XStart time of the analysis range (must be UTC)
end_timeString (YYYY-MM-DDThh:mm:ss+00:00)?XEnd time of the analysis range (must be UTC)

Example

curl "https://api.asleep.ai/data/v1/sessions/{session_id}/reanalyze" -XPOST \
  -H "x-api-key: <YOUR_API_KEY>" \
  -H "x-user-id: <USER_ID>" \
  -H "Content-Type: application/json" \
  -d '{
    "start_time": "2025-01-15T03:00:00+00:00",
    "end_time": "2025-01-15T07:00:00+00:00"
}'

Response

200 OK

  • Reanalysis successful
{
	"detail": "reanalyze success"
}
  • The session has already been analyzed under the same conditions, so no reanalysis was performed
{
	"detail": "already analyzed"
}

400 Bad Request

  • session_id: invalid format
{
	"detail": "The format of sleep session id 20230608020315_hz82 is not valid"
}
  • start_time or end_time is not in UTC
{
	"detail": "analysis times must be UTC"
}
  • start_time is not before end_time
{
	"detail": "start_time must be before end_time"
}
  • The analysis range exceeds the available sleep data of the session
{
	"detail": "analysis range exceeds the available sleep data"
}

401 Unauthorized

  • Invalid or missing authentication credentials
{
	"detail": "Unauthorized"
}

403 Forbidden

  • An inaccessible customer has made a request
{
	"detail": "An inaccessible customer has made a request"
}

404 Not Found

  • The session corresponding to session_id is not found
{
	"detail": "Unable to find the sleep session of id {session_id}"
}
  • The sleep analysis of the session is not found
{
	"detail": "Unable to find the sleep analysis of the sleep session {session_id}"
}

409 Conflict

  • A reanalysis of the session is already in progress
{
	"detail": "The reanalysis of the sleep session {session_id} is in progress"
}

410 Gone

  • The analysis result of the session no longer exists
{
	"detail": "Unable to find the analysis result of the sleep session {session_id}"
}

422 Unprocessable Entity

  • The session is not in the COMPLETE state
{
	"detail": "The sleep session {session_id} is not complete"
}

Did this page help you?