Saltar al contenido
Logotipo de Aurabase
aurabase

Importación masiva de usuarios

Importe hasta 1000 usuarios por lote con hashes de contraseña bcrypt heredados o Argon2id modernos. Actualización transparente a Argon2id en el próximo inicio de sesión.

Guía práctica5 min leerNivel intermedio

La fuente en inglés ha cambiado desde esta traducción. Es posible que parte de la información esté desactualizada.
Esta página fue traducida automáticamente. La versión en inglés es autorizada.

Importing users from another platform#

When migrating from Supabase, Firebase, Auth0, or a custom authentication database, users expect their existing passwords to keep working without a global password reset.

Aurabase provides a high-throughput bulk import endpoint (POST /v1/auth/admin/users/import) capable of ingesting up to 1,000 users per request. The operation returns an itemized status report so invalid records do not block the rest of the batch.

Supported password hashes and transparent upgrade#

The import endpoint supports the following password hashing algorithms:

AlgorithmIdentifiersBehavior
Argon2id$argon2id$v=19$m=...Verified directly using OWASP parameters.
bcrypt$2a$, $2b$, $2y$Verified on login and transparently re-encoded to Argon2id upon first successful authentication.

If no password_hash is provided for a user, the account is created without a password. The user can authenticate using Magic Links, Email/SMS OTP, or a password reset link.

Bulk import endpoint#

Requires administrator authorization (service_role key).

curl -X POST "$NEXT_PUBLIC_AURABASE_URL/v1/auth/admin/users/import" \
  -H "apikey: $AURABASE_SERVICE_ROLE_KEY" \
  -H "Authorization: Bearer $AURABASE_SERVICE_ROLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "users": [
      {
        "email": "[email protected]",
        "email_verified": true,
        "password_hash": "$2b$12$e8kPM4QJ8a2x4K7hM0uL.OeQ7f...",
        "name": "Alice Johnson",
        "user_metadata": { "department": "Engineering" }
      },
      {
        "email": "[email protected]",
        "email_verified": false,
        "password_hash": "$argon2id$v=19$m=65536,t=3,p=4$..."
      }
    ]
  }'

Response (200 OK)

The response details the total number of records processed along with an itemized report:

{
  "data": {
    "created": 2,
    "skipped": 0,
    "errors": 0,
    "report": [
      {
        "index": 0,
        "email": "[email protected]",
        "status": "created",
        "id": "e3b0c442-98fc-1c14-9afb-f4c599684824"
      },
      {
        "index": 1,
        "email": "[email protected]",
        "status": "created",
        "id": "7d2b5129-3bdf-48bc-8919-4b684df69921"
      }
    ]
  }
}

If an email already exists in the project, it is marked as skipped rather than raising a fatal error.

TypeScript SDK#

Use authAdmin.importUsers():

import { createClient } from '@aurabase/aurabase-js'

const aura = createClient(process.env.NEXT_PUBLIC_AURABASE_URL!, process.env.AURABASE_SERVICE_ROLE_KEY!)

const usersToImport = [
  {
    email: '[email protected]',
    emailVerified: true,
    passwordHash: '$2b$12$e8kPM4QJ8a2x4...',
    name: 'User One',
    userMetadata: { plan: 'pro' },
  },
  {
    email: '[email protected]',
    emailVerified: false,
    passwordHash: '$argon2id$v=19$m=65536,t=3,p=4$...',
    name: 'User Two',
  },
]

const { data, error } = await aura.authAdmin.importUsers(usersToImport)

if (error) {
  console.error('Import failed:', error.message)
} else {
  console.log(`Import summary: ${data.created} created, ${data.skipped} skipped, ${data.errors} errors`)

  for (const item of data.report) {
    if (item.status === 'error') {
      console.warn(`Row ${item.index} (${item.email}) error: ${item.error}`)
    }
  }
}

Import via Aurabase Studio#

You can also import users directly through the web interface:

  1. Navigate to Authentication › Users in your project dashboard.
  2. Click the Import users button in the top toolbar.
  3. Choose JSON or CSV format. You can click Insert sample to inspect the expected schema.
  4. Paste your data and click Start Import.
  5. Inspect the batch summary and row-by-row status report.
@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Informar un problema