Skip to main content
GET
/
auth
/
isloggedin
Check authentication
curl --request GET \
  --url https://api.example.com/auth/isloggedin \
  --header 'x-access'\''courser-auth-token: <x-access'\''courser-auth-token>'
{
  "user": {
    "_id": "<string>",
    "email": "<string>",
    "name": "<string>",
    "courses": [
      "<string>"
    ]
  }
}
Verifies the provided JWT token and returns the authenticated user’s profile from the database. Use this endpoint to confirm a token is still valid and to retrieve up-to-date user data.
This endpoint requires authentication. Include your token in the x-access'courser-auth-token header.

Request headers

x-access'courser-auth-token
string
required
A valid JWT token obtained from any auth endpoint. Note the apostrophe in the header name.

Response

200 — Authenticated

user
object
required
The authenticated user’s full profile document.

401 — Unauthorized

Returned as a JSON string (not an object) in one of the following cases:
Response bodyCause
"not-logged-in"The x-access'courser-auth-token header is absent
"no user found"Token is valid but no matching user exists in the database
"ERROR"Token verification failed (invalid signature or expired)

Example

curl --request GET \
  --url http://localhost:8000/auth/isloggedin \
  --header "x-access'courser-auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
200
{
  "user": {
    "_id": "a3f8c1e09b2d7f4e6a1c3d5b",
    "email": "[email protected]",
    "name": "Dr. Jane Smith",
    "courses": [
      "64b1f2e3c4a5d6f7e8a9b0c1",
      "64b1f2e3c4a5d6f7e8a9b0c2"
    ]
  }
}
401
"not-logged-in"

Build docs developers (and LLMs) love