<@U04UQ68083H> is it possible to read the otp duri...
# ory-copilot
r
@chilly-king-10285 is it possible to read the otp during the update of the login flow
c
A message from kapa.ai
Yes, it is possible to read (i.e., receive and process) the OTP (TOTP code) during the update of the login flow in Ory Kratos. When updating the login flow using the TOTP method, you must provide the OTP code in the request body. The required fields for this operation are: - `method`: should be set to
"totp"
- `totp_code`: the TOTP code provided by the user Optionally, for browser flows, you may also need to include the
csrf_token
. Here is the relevant structure for the request body:
Copy code
json {   "method": "totp",   "totp_code": "123456",   "csrf_token": "your-csrf-token" // only for browser flows }
This means that during the update of the login flow, Ory Kratos expects the OTP (TOTP code) to be submitted, and it will validate the code as part of the authentication process. If the code is invalid, an error will be returned; if valid, the flow will proceed successfully [Ory API Reference – updateLoginFlow](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json) [Kratos API Reference – updateLoginFlow](https://raw.githubusercontent.com/ory/kratos/master/spec/api.json).
r
@chilly-king-10285 how about after the code has been sent out, and I retrieve the code on the backend side
c
A message from kapa.ai
I'm sorry, but the knowledge sources do not contain information about retrieving the OTP code on the backend side after it has been sent out. Ory Kratos is designed to send the OTP (such as a TOTP or one-time code via email/SMS) directly to the user, and the backend is not intended to access or retrieve the code itself for security reasons. The expected flow is that the user receives the code and submits it back to the system for verification during the login or settings flow. If you need to verify the code, you should prompt the user to enter it and then submit it to the appropriate Ory Kratos API endpoint for validation. There is no documented method to programmatically retrieve the code from Ory Kratos after it has been sent out [Docs > Kratos > Passwordless > Email and SMS one-time-code authentication](https://www.ory.sh/docs/kratos/passwordless/one-time-code) [Docs > Kratos > Mfa > Time-based one-time passwords (TOTP)](https://www.ory.sh/docs/kratos/mfa/totp). If you are using a custom SMS or email provider via a webhook, you might be able to access the code in your own delivery infrastructure, but this is outside the scope of Ory Kratos itself.