# Logging in

<mark style="color:green;">`POST`</mark> `/login`

This endpoint allows users to log in to the app using their email and password. The user must first be created in Firebase Authentication. Upon successful login, a token is returned, which is necessary for authentication in subsequent requests.

#### Steps to Create User in Firebase Authentication

1. **Go to your Firebase project.**
2. **Navigate to Authentication.**
3. **Click on "Add User".**
4. **Provide the email and password.**
5. **Add the user.**

#### **Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Body**

| Name       | Type   | Description          |
| ---------- | ------ | -------------------- |
| `email`    | string | Email of the user    |
| `password` | string | Password of the user |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "token":"bearertoken"
}
```

{% endtab %}

{% tab title="400" %}
{% code overflow="wrap" %}

```json
{
    "error": "ERROR: {'error': {'code': 400, 'message': 'INVALID_LOGIN_CREDENTIALS', 'errors': [{'message': 'INVALID_LOGIN_CREDENTIALS', 'domain': 'global', 'reason': 'invalid'}]}}"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Notes

* Ensure that the email and password provided are correct and match the credentials used in Firebase Authentication.
* The token returned in the response is necessary for all subsequent requests to the API. Store it securely and include it in the `Authorization` header as `Bearer <token>` for authenticated endpoints.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.momentum.sh/using-momentum/logging-in.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
