Nest Authbeta

POST /auth/refresh-token

Refresh access token. Response format depends on accessTokenType configuration:

Refresh Token

POST/auth/refresh-token

Refresh access token. Response format depends on accessTokenType configuration: - Header mode (default): Returns new tokens in response body - Cookie mode: Sets new tokens in HTTP-only cookies and returns success message

Request body

NestAuthRefreshTokenRequestDto

FieldTypeRequiredDescription
refreshTokenstringoptionalRefresh token to obtain new access token
Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ0eXBlIjoicmVmcmVz…

Examples

Example
{
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ0eXBlIjoicmVmcmVzaCJ9.abc123"
}

Responses

200Header mode: Returns message + tokens in body

AuthWithTokensResponseDto

FieldTypeRequiredDescription
accessTokenstringrequiredJWT access token (short-lived)
Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJpYXQiOjE2OTk5OTk5…
refreshTokenstringrequiredJWT refresh token (long-lived)
Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ0eXBlIjoicmVmcmVz…
messagestringoptionalSuccess message (added by controller based on configuration)
Example: Login successful
isRequiresMfabooleanrequiredWhether multi-factor authentication is required
Example: false
mfaMethods"email" | "sms" | "totp"[]optionalAvailable MFA methods when isRequiresMfa is true
Example: ["email","totp"]
defaultMfaMethod"email" | "sms" | "totp"optionalDefault/recommended MFA method
emailsmstotp
Example: email
trustTokenstringoptionalTrust token for trusted device verification
Example: 1234567890

Example response

{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJpYXQiOjE2OTk5OTk5OTksImV4cCI6MTY5OTk5OTk5OX0.xyz",
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ0eXBlIjoicmVmcmVzaCIsImlhdCI6MTY5OTk5OTk5OX0.abc",
  "message": "Login successful",
  "isRequiresMfa": false,
  "mfaMethods": [
    "email",
    "totp"
  ],
  "defaultMfaMethod": "email",
  "trustToken": "1234567890"
}

Try it

curl -X POST 'https://api.example.com/auth/refresh-token' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -d '{"refreshToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ0eXBlIjoicmVmcmVzaCJ9.abc123"}'

On this page