> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/azfar-imtiaz/PayPulse-Cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Login

> Authenticate and receive a JWT access token.

## Request body

<ParamField body="email" type="string" required>
  The email address associated with the account.
</ParamField>

<ParamField body="password" type="string" required>
  The account password.
</ParamField>

## Response

<ResponseField name="message" type="string">
  A human-readable confirmation message. Example: `"Login successful!"`
</ResponseField>

<ResponseField name="code" type="number">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="properties" defaultOpen>
    <ResponseField name="username" type="string">
      The display name associated with the authenticated account.
    </ResponseField>

    <ResponseField name="access_token" type="string">
      A signed HS256 JWT token valid for 1 hour.
    </ResponseField>

    <ResponseField name="token_type" type="string">
      Always `"Bearer"`.
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  Include the `access_token` in the `Authorization` header of all subsequent requests that require authentication: `Authorization: Bearer <access_token>`.
</Note>

## Error responses

| Status | Error code              | Description                                                   |
| ------ | ----------------------- | ------------------------------------------------------------- |
| `400`  | `INVALID_JSON`          | The request body is not valid JSON.                           |
| `400`  | `MISSING_FIELDS`        | One or more required fields (`email`, `password`) are absent. |
| `401`  | `INVALID_CREDENTIALS`   | The password does not match the stored credential.            |
| `404`  | `USER_NOT_FOUND`        | No account exists for the given email address.                |
| `500`  | `JWT_ERROR`             | The server failed to generate the JWT token.                  |
| `500`  | `INTERNAL_SERVER_ERROR` | An unexpected server-side error occurred.                     |

Error responses follow this structure:

```json theme={null}
{
  "error": {
    "code": "INVALID_CREDENTIALS",
    "message": "Invalid Credentials"
  }
}
```

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.paypulse.io/v1/auth/login \
    --header 'Content-Type: application/json' \
    --data '{
      "email": "jane@example.com",
      "password": "s3cur3P@ssword!"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "message": "Login successful!",
    "code": 200,
    "data": {
      "username": "Jane Doe",
      "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "token_type": "Bearer"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": "INVALID_CREDENTIALS",
      "message": "Invalid Credentials"
    }
  }
  ```

  ```json 404 theme={null}
  {
    "error": {
      "code": "USER_NOT_FOUND",
      "message": "User not found"
    }
  }
  ```
</ResponseExample>
