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

# Import users

> Invite many people at once from a CSV file, or move people and their passwords over from another system.

There are two ways to bring many people into your organization:

* **Invite from a CSV file** in the console. Each person gets an invitation email and sets up their own sign-in.
* **Import people** through the admin API. You create accounts directly, and people can keep their old passwords.

## Invite from a CSV file

Use this when people should accept an invitation, for example a new team.

**1. Open People**

In the console, go to **People** and choose **Upload CSV**. You need the **Manage people** power.

**2. Fill in the template**

Choose **Download template**. The file has two columns, `email` and `role`. Write the role by its key or its name. Leave it blank to use your [default role](https://docs.aiveth.com/access/roles-and-permissions.md#the-default-role).

**3. Check the file**

Upload the file. Aiveth checks every row first without inviting anyone, and shows each row as ready or the reason it isn't.

**4. Invite**

Confirm, and every ready row is invited and emailed.

A row is not ready when:

* the email address isn't valid,
* the same address appears twice in the file,
* the person is already in your organization, or
* the role isn't one of your organization's roles, or has more access than your own.

One refused row never undoes the others. If an invitation email can't be sent, its row says so, and you can copy the link from the person's invitation later.

You can upload at most 200 rows at a time, and send at most 500 invitations from files per hour.

## Import people through the admin API

Use this when you move from another sign-in system and don't want people to start over.

```
POST /v1/admin/people/import
Authorization: Bearer aiveth_sk_live_...
```

The [API key](https://docs.aiveth.com/account/api-keys.md) needs the `people:manage` power. Each call takes at most 500 people.

**people** `array` *required*

The people to create. Each entry has:

* `email` (required)
* `first_name`, `last_name`
* `role`: a role key. Blank means your default role. It must be within the key maker's own access.
* `password_hash` and `password_hasher`: the person's password hash from your old system, and what made it.

An address already in your organization is skipped, never changed. Importing does not mark anyone's email as verified.

### The response

```json theme={null}
{
  "created": 120,
  "with_password": 100,
  "awaiting_check": 15,
  "no_password": 5,
  "skipped": [{ "email": "dup@example.com", "why": "already here" }]
}
```

| Field | Meaning |
| - | - |
| `created` | People created. |
| `with_password` | People who can sign in right away with their old password. |
| `awaiting_check` | People whose password your old system will check at their first sign-in. |
| `no_password` | People who will set a password with "Forgot password". |
| `skipped` | Rows not imported, with the reason. |

### SDK

```ts Node theme={null}
import { Aiveth } from '@gooclaim/aiveth';

const aiveth = new Aiveth({ baseUrl: 'https://accounts.aiveth.com', apiKey: process.env.AIVETH_API_KEY });

// importAll splits a longer list into calls of 500.
const report = await aiveth.people.importAll([
  { email: 'asha@example.com', first_name: 'Asha', password_hash: '$2b$12$...', password_hasher: 'bcrypt' },
]);
```

```python Python theme={null}
import os
from gooclaim_aiveth_sdk import Aiveth

aiveth = Aiveth("https://accounts.aiveth.com", api_key=os.environ["AIVETH_API_KEY"])

report = aiveth.people.import_all([
    {"email": "asha@example.com", "first_name": "Asha", "password_hash": "$2b$12$...", "password_hasher": "bcrypt"},
])
```

## Passwords from your old system

How a password comes across depends on its hash:

* **bcrypt or Argon2id**: Aiveth checks these itself. People sign in with their old password straight away, and Aiveth upgrades the hash at their next sign-in.
* **Any other hash** (for example Firebase scrypt or PBKDF2): Aiveth asks your old system to check the password once, at the person's first sign-in. This only works when a password check is set up before the import (below). Otherwise the person counts as `no_password`.

### Set up the password check

**1. Open Developers**

In the console, go to **Developers** and find **Passwords from your old system**. Only an Owner can change this check.

**2. Enter your old system's address**

Under **Your old system's address**, enter a public `https://` address. Under **Ask it for**, choose how many days the check runs, from 1 to 365. The default is 90.

**3. Save and copy the secret**

The first save shows a signing secret once. Keep it to verify the requests. You can make a new secret later; the old one stops at once.

Every change to the check emails your Owners, because Aiveth sends passwords to this address.

### The request your old system receives

At a marked person's first sign-in, Aiveth sends a `POST` signed the same way as [webhooks](https://docs.aiveth.com/events/webhooks.md#verify-the-signature), with the `webhook-id`, `webhook-timestamp` and `webhook-signature` headers:

```json theme={null}
{ "type": "password_check", "email": "asha@example.com", "password": "the password they typed", "person": { "id": "..." } }
```

Answer `200` with:

```json theme={null}
{ "valid": true }
```

Your system must answer within 3 seconds. If the answer is `true`, Aiveth keeps the password with its own Argon2id hash and never asks again. Any other answer, a timeout, or a malformed reply means the password isn't accepted this time.

> [!WARNING]
>
> Verify the signature before you look at the password, and never log the request body.

Aiveth sends a password only to this address, only for a person imported with a hash it can't check, and only during a sign-in.

### After the check ends

When the check's time runs out, or if you have no old system at all, people set a new password with "Forgot password". To email everyone still waiting a reset link, call:

```
POST /v1/admin/people/import/reset-emails
```

This needs `people:manage` and works once a day. An organization made through self sign-up must [verify a domain](https://docs.aiveth.com/sign-in/verified-domains.md) before it can send these emails.

## Errors

| Status | Message |
| - | - |
| 403 | Verify one of your domains first (Security → Domains): until then an organization can't email people in bulk. |
| 422 | Import at most 500 people at a time. |
| 429 | Reset emails were sent today already. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.