Verify Token

Verify a JWT and retrieve the authenticated user

POST /api/v1/tokens/verify

Verifies a Clowk JWT and returns the associated user. The token must belong to the same instance as the secret key used for authentication.

Request

curl -X POST https://myapp.clowk.dev/api/v1/tokens/verify \
  -H "Content-Type: application/json" \
  -H "X-Clowk-Secret-Key: sk_live_..." \
  -d '{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }'

Headers

HeaderRequiredDescription
X-Clowk-Secret-KeyYesYour instance secret key
Content-TypeYesapplication/json

Body

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
FieldTypeRequiredDescription
tokenstringYesThe JWT to verify

Response

200 — Token valid

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "resource": "token",
  "data": {
    "valid": true,
    "email": "jane@example.com",
    "name": "Jane Doe",
    "avatar_url": "https://lh3.googleusercontent.com/...",
    "provider": "google"
  }
}

400 — Missing token

{
  "error": "Missing token"
}

401 — Invalid token

{
  "valid": false,
  "error": "Token invalid signature"
}

This also returns 401 if the token belongs to a different instance:

{
  "valid": false,
  "error": "Token does not belong to this instance"
}

404 — User not found

{
  "error": "User not found"
}

JWT payload structure

When you decode a Clowk JWT, the payload contains:

{
  "iss": "clowk",
  "iat": 1711152000,
  "exp": 1711155600,
  "sub": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "email": "jane@example.com",
  "name": "Jane Doe",
  "avatar_url": "https://lh3.googleusercontent.com/...",
  "provider": "google",
  "instance_id": "inst_abc123",
  "app_id": "app_xyz789"
}
ClaimDescription
issAlways "clowk"
subUser ID (UUID)
emailUser email address
nameUser display name
avatar_urlProfile picture URL from the OAuth provider
providerAuthentication provider (google, github, twitter, email)
instance_idYour Clowk instance ID
app_idYour Clowk app ID
iatIssued at (Unix timestamp)
expExpires at (Unix timestamp, 1 hour after iat)

Tokens are signed with HS256 using your instance's secret key.

On this page