# Email and password

Source: https://cubibase.com/docs/auth/email-password

Also available: [Markdown version](https://cubibase.com/docs/auth/email-password.md) · [llms.txt](https://cubibase.com/llms.txt) · [full site content](https://cubibase.com/llms-full.txt)

POST /auth/v1/signup creates a user and returns a session. Sign in later with the password grant; the access token is the JWT for your Data API calls.

## Sign up

**Sign up · request**

```http
POST https://example-project.api.cubibase.com/auth/v1/signup
apikey: cb_pub_EXAMPLE_ONLY
Content-Type: application/json

{
  "email": "mina@example.com",
  "password": "<USER_PASSWORD>"
}
```

**201 · response (trimmed)**

```json
{
  "user": {
    "id": "3f2b8c1e-9a47-4d02-b6e5-1c8f0a3d7e29",
    "email": "mina@example.com",
    "emailVerifiedAt": "2026-11-18T09:12:44.000Z",
    "providers": ["email"],
    "mfaEnabled": false
  },
  "accessToken": "<ACCESS_JWT>",
  "refreshToken": "<REFRESH_TOKEN>",
  "tokenType": "Bearer",
  "expiresIn": 3600
}
```

- The password must meet the project’s minimum length — 8 characters by default — and must not equal the email address.
- An optional `data` object is stored as the user’s metadata.
- The response carries the `user`, an `accessToken`, a `refreshToken`, and the expiry.
- A duplicate email returns `409 user_exists`.

> **note**: Email autoconfirm is on by default: the user is marked verified at signup and no confirmation email is sent. Turn autoconfirm off to manage verification yourself through the control API.

## Sign in

**Sign in · request**

```http
POST https://example-project.api.cubibase.com/auth/v1/token?grant_type=password
apikey: cb_pub_EXAMPLE_ONLY
Content-Type: application/json

{
  "email": "mina@example.com",
  "password": "<USER_PASSWORD>"
}
```

A correct email and password return the same session shape as signup. Wrong credentials return `401 invalid_credentials` — the same error whether the email exists or not.

> **important**: If the user has a verified TOTP factor and MFA is on for the project, the password grant returns an MFA challenge instead of a session. See Multi-factor (TOTP).

## Using the session

1. Store the `refreshToken` safely on the client.
2. Send the `accessToken` as `Authorization: Bearer …` on Data API calls.
3. When it expires (1 hour by default), refresh with `grant_type=refresh_token` and store the new pair.
4. On sign-out, `POST /auth/v1/logout` with the refresh token revokes the session.

**Refresh · request**

```http
POST https://example-project.api.cubibase.com/auth/v1/token?grant_type=refresh_token
apikey: cb_pub_EXAMPLE_ONLY
Content-Type: application/json

{
  "refreshToken": "<REFRESH_TOKEN>"
}
```

## Read and update the user

`GET /auth/v1/user` returns the signed-in user from the bearer token. `PATCH /auth/v1/user` updates the password or metadata (and converts anonymous users — see Anonymous users).

**Read the current user**

```http
GET https://example-project.api.cubibase.com/auth/v1/user
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <ACCESS_JWT>
```

## Additional resources

- [Sessions and tokens](https://cubibase.com/docs/auth/sessions) What rotation and reuse detection mean for your client.
- [Multi-factor (TOTP)](https://cubibase.com/docs/auth/mfa) The challenge flow after password sign-in.
- [Data API](https://cubibase.com/docs/data-api) Where the access token goes next.
