Submit a Login Flow

POST {{baseUrl}}/self-service/login?flow=<string>

Use this endpoint to complete a login flow. This endpoint behaves differently for API and browser flows.

API flows expect application/json to be sent in the body and responds with HTTP 200 and a application/json body with the session token on success; HTTP 410 if the original flow expired with the appropriate error messages set and optionally a use_flow_id parameter in the body; HTTP 400 on form validation errors.

Browser flows expect a Content-Type of application/x-www-form-urlencoded or application/json to be sent in the body and respond with a HTTP 303 redirect to the post/after login URL or the return_to value if it was set and if the login succeeded; a HTTP 303 redirect to the login UI URL with the flow ID containing the validation errors otherwise.

Browser flows with an accept header of application/json will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a Set-Cookie header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors.

If this endpoint is called with Accept: application/json in the header, the response contains the flow without a redirect. In the case of an error, the error.id of the JSON response body can be one of:

session_already_available: The user is already signed in. security_csrf_violation: Unable to fetch the flow because a CSRF violation occurred. security_identity_mismatch: The requested ?return_to address is not allowed to be used. Adjust this in the configuration! browser_location_change_required: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.

More information can be found at Ory Kratos User Login and User Registration Documentation.

Request Params

KeyDatatypeRequiredDescription
flowstring(Required) The Login Flow ID

The value for this parameter comes from flow URL Query parameter sent to your application (e.g. /login?flow=abcde). |

Request Body

[{"name"=>"method", "value"=>"<string>", "datatype"=>"string"}, {"name"=>"password", "value"=>"<string>", "datatype"=>"string"}, {"name"=>"identifier", "value"=>"<string>", "datatype"=>"string"}, {"name"=>"csrf_token", "value"=>"<string>", "datatype"=>"string"}, {"name"=>"password_identifier", "value"=>"<string>", "datatype"=>"string"}]

HEADERS

KeyDatatypeRequiredDescription
X-Session-TokenstringThe Session Token of the Identity performing the settings flow.
CookiestringHTTP Cookies

When using the SDK in a browser app, on the server side you must include the HTTP Cookie Header sent by the client to your server here. This ensures that CSRF and session cookies are respected. | | Content-Type | string | | | | Accept | string | | |

RESPONSES

status: OK

{&quot;session&quot;:{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;active&quot;:&quot;\u003cboolean\u003e&quot;,&quot;authenticated_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;authentication_methods&quot;:[{&quot;aal&quot;:&quot;aal0&quot;,&quot;completed_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;method&quot;:&quot;v0.6_legacy_session&quot;,&quot;organization&quot;:&quot;\u003cstring\u003e&quot;,&quot;provider&quot;:&quot;\u003cstring\u003e&quot;},{&quot;aal&quot;:&quot;aal1&quot;,&quot;completed_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;method&quot;:&quot;webauthn&quot;,&quot;organization&quot;:&quot;\u003cstring\u003e&quot;,&quot;provider&quot;:&quot;\u003cstring\u003e&quot;}],&quot;authenticator_assurance_level&quot;:&quot;aal0&quot;,&quot;devices&quot;:[{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;ip_address&quot;:&quot;\u003cstring\u003e&quot;,&quot;location&quot;:&quot;\u003cstring\u003e&quot;,&quot;user_agent&quot;:&quot;\u003cstring\u003e&quot;},{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;ip_address&quot;:&quot;\u003cstring\u003e&quot;,&quot;location&quot;:&quot;\u003cstring\u003e&quot;,&quot;user_agent&quot;:&quot;\u003cstring\u003e&quot;}],&quot;expires_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;identity&quot;:{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;schema_id&quot;:&quot;\u003cstring\u003e&quot;,&quot;schema_url&quot;:&quot;\u003cstring\u003e&quot;,&quot;traits&quot;:{&quot;description&quot;:&quot;Traits represent an identity&#39;s traits. The identity is able to create, modify, and delete traits\nin a self-service manner. The input will always be validated against the JSON Schema defined\nin `schema_url`.&quot;},&quot;created_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;credentials&quot;:{&quot;dolore__e&quot;:{&quot;config&quot;:{},&quot;created_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;identifiers&quot;:[&quot;\u003cstring\u003e&quot;,&quot;\u003cstring\u003e&quot;],&quot;type&quot;:&quot;profile&quot;,&quot;updated_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;version&quot;:&quot;\u003clong\u003e&quot;},&quot;in_&quot;:{&quot;config&quot;:{},&quot;created_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;identifiers&quot;:[&quot;\u003cstring\u003e&quot;,&quot;\u003cstring\u003e&quot;],&quot;type&quot;:&quot;webauthn&quot;,&quot;updated_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;version&quot;:&quot;\u003clong\u003e&quot;}},&quot;metadata_admin&quot;:{&quot;description&quot;:&quot;NullJSONRawMessage represents a json.RawMessage that works well with JSON, SQL, and Swagger and is NULLable-&quot;,&quot;nullable&quot;:true},&quot;metadata_public&quot;:{&quot;description&quot;:&quot;NullJSONRawMessage represents a json.RawMessage that works well with JSON, SQL, and Swagger and is NULLable-&quot;,&quot;nullable&quot;:true},&quot;organization_id&quot;:&quot;\u003cstring\u003e&quot;,&quot;recovery_addresses&quot;:[{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;value&quot;:&quot;\u003cstring\u003e&quot;,&quot;via&quot;:&quot;\u003cstring\u003e&quot;,&quot;created_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;updated_at&quot;:&quot;\u003cdateTime\u003e&quot;},{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;value&quot;:&quot;\u003cstring\u003e&quot;,&quot;via&quot;:&quot;\u003cstring\u003e&quot;,&quot;created_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;updated_at&quot;:&quot;\u003cdateTime\u003e&quot;}],&quot;state&quot;:&quot;active&quot;,&quot;state_changed_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;updated_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;verifiable_addresses&quot;:[{&quot;value&quot;:&quot;\u003cstring\u003e&quot;,&quot;verified&quot;:&quot;\u003cboolean\u003e&quot;,&quot;via&quot;:&quot;email&quot;,&quot;status&quot;:&quot;\u003cstring\u003e&quot;,&quot;created_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;updated_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;verified_at&quot;:&quot;\u003cdateTime\u003e&quot;},{&quot;value&quot;:&quot;\u003cstring\u003e&quot;,&quot;verified&quot;:&quot;\u003cboolean\u003e&quot;,&quot;via&quot;:&quot;sms&quot;,&quot;status&quot;:&quot;\u003cstring\u003e&quot;,&quot;created_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;updated_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;verified_at&quot;:&quot;\u003cdateTime\u003e&quot;}]},&quot;issued_at&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;tokenized&quot;:&quot;\u003cstring\u003e&quot;},&quot;continue_with&quot;:[{&quot;action&quot;:&quot;show_verification_ui&quot;,&quot;flow&quot;:{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;verifiable_address&quot;:&quot;\u003cstring\u003e&quot;,&quot;url&quot;:&quot;\u003cstring\u003e&quot;}},{&quot;action&quot;:&quot;show_verification_ui&quot;,&quot;flow&quot;:{&quot;id&quot;:&quot;\u003cuuid\u003e&quot;,&quot;verifiable_address&quot;:&quot;\u003cstring\u003e&quot;,&quot;url&quot;:&quot;\u003cstring\u003e&quot;}}],&quot;session_token&quot;:&quot;\u003cstring\u003e&quot;}