> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Login with Username and Password

> -  Although none of the body parameters are required, it's mandatory to include  either the `user` AND `password`  or only the `resume` parameter.

- To authenticate a request, you need to pass the `userId` and `authToken` values from this JSON response object as headers in the request. The `authToken` is passed as `X-Auth-Token` header, while the `userId` as `X-User-Id` header.

-  If LDAP authentication is enabled, you must maintain the login in the same way as you normally do. Similarly, if 2FA is enabled for an LDAP user, everything stays the same.
  
### Changelog
| Version      | Description | 
 | ---------------- | ------------|
 |1.0.0            | Added `avatarUrl` property to response       |
 |0.64.0            | Added `me` property.      |
 |0.60.0            | Added      |

## OpenAPI

````json POST /api/v1/login
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Authentication"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "Authentication"
    },
    {
      "name": "Two-Factor Authentication"
    }
  ],
  "paths": {
    "/api/v1/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Login with Username and Password",
        "description": "-  Although none of the body parameters are required, it's mandatory to include  either the `user` AND `password`  or only the `resume` parameter.\n\n- To authenticate a request, you need to pass the `userId` and `authToken` values from this JSON response object as headers in the request. The `authToken` is passed as `X-Auth-Token` header, while the `userId` as `X-User-Id` header.\n\n-  If LDAP authentication is enabled, you must maintain the login in the same way as you normally do. Similarly, if 2FA is enabled for an LDAP user, everything stays the same.\n  \n### Changelog\n| Version      | Description | \n | ---------------- | ------------|\n |1.0.0            | Added `avatarUrl` property to response       |\n |0.64.0            | Added `me` property.      |\n |0.60.0            | Added      |",
        "operationId": "post-api-v1-login",
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user": {
                    "type": "string",
                    "description": "Your user name or email.",
                    "example": "myusername"
                  },
                  "password": {
                    "type": "string",
                    "description": "Your pasword.",
                    "example": "my$up3erP@ssw0rd"
                  },
                  "resume": {
                    "type": "string",
                    "description": "Your previously issued `authToken`.",
                    "example": "9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq"
                  },
                  "code": {
                    "type": "string",
                    "description": "The 2FA code. It is required if your account has two-factor authentication enabled .",
                    "example": "2246d10"
                  }
                }
              },
              "examples": {
                "Example": {
                  "value": {
                    "user": "test@rocket.test",
                    "password": "vanvica32"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "authToken": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "me": {
                          "type": "object",
                          "properties": {
                            "_id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "emails": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "address": {
                                    "type": "string"
                                  },
                                  "verified": {
                                    "type": "boolean"
                                  }
                                }
                              }
                            },
                            "status": {
                              "type": "string"
                            },
                            "statusConnection": {
                              "type": "string"
                            },
                            "username": {
                              "type": "string"
                            },
                            "utcOffset": {
                              "type": "integer"
                            },
                            "active": {
                              "type": "boolean"
                            },
                            "roles": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "settings": {
                              "type": "object",
                              "properties": {
                                "preferences": {
                                  "type": "object"
                                }
                              }
                            },
                            "avatarUrl": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  },
                  "x-examples": {
                    "Example": {
                      "status": "success",
                      "data": {
                        "authToken": "9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq",
                        "userId": "aobEdbYhXfu5hkeqG",
                        "me": {
                          "_id": "aYjNnig8BEAWeQzMh",
                          "name": "Rocket Cat",
                          "emails": [
                            {
                              "address": "rocket.cat@rocket.chat",
                              "verified": "false"
                            }
                          ],
                          "status": "offline",
                          "statusConnection": "offline",
                          "username": "rocket.cat",
                          "utcOffset": "-3",
                          "active": "true",
                          "roles": [
                            "admin"
                          ],
                          "settings": {
                            "preferences": {}
                          },
                          "avatarUrl": "http://localhost:3000/avatar/test"
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "Login successful": {
                    "value": {
                      "status": "success",
                      "data": {
                        "authToken": "9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq",
                        "userId": "aobEdbYhXfu5hkeqG",
                        "me": {
                          "_id": "aYjNnig8BEAWeQzMh",
                          "name": "Rocket Cat",
                          "emails": [
                            {
                              "address": "rocket.cat@rocket.chat",
                              "verified": "false"
                            }
                          ],
                          "status": "offline",
                          "statusConnection": "offline",
                          "username": "rocket.cat",
                          "utcOffset": "-3",
                          "active": "true",
                          "roles": [
                            "admin"
                          ],
                          "settings": {
                            "preferences": {}
                          },
                          "avatarUrl": "http://localhost:3000/avatar/test"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
````

