# User imports

Source: https://www.pontive.com/docs/api-reference/management/user-imports

Base URL: `https://api.{region}.pontive.com/v1` (operations that name another server say so).

Authentication: send `Authorization: Bearer <token>` with a secret key (`pontive_sk_…`, which implies its instance) or an access token issued for this API. A token that can reach several instances also names one with `X-Pontive-Instance-ID: inst_…`. Secret keys are for servers only.

## Import organizations

```http
POST https://api.{region}.pontive.com/v1/organizations/import
```

Apply, or with dry_run (default true) plan, a batch of at most 100 organizations and 1,000 member entries under an import run, after their users (pontive-spec 46 §5.3). external_id is each row's key. A member names its user by exactly one of user_id, user_external_id or legacy_subject (the run's source), with roles of the org type; one that names no user fails as a warning on the row, not the organization. A new organization needs at least one resolved member with owner (owners_required). An existing one (same external_id) takes new members and, with on_existing update, its name, metadata and changed roles; its owners change by transfer, never by import (owner_requires_transfer). An organization larger than one batch is sent again with its next members. A b2c instance refuses the call (tenancy_mode_b2c). Needs sys:org:create on the instance root, and sys:member:manage on each existing organization the batch changes.

Operation ID: `ImportOrganizations`

### Request body (`application/json`, required): ImportOrganizationsRequest

Batch

### Responses

- `200` OK: UserImportBatch
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` user_import_not_found: ErrResponse
- `409` user_import_reverted, tenancy_mode_b2c: ErrResponse
- `422` too_many_records: ErrResponse
- `500` Internal Server Error: ErrResponse

## List user imports

```http
GET https://api.{region}.pontive.com/v1/user-imports
```

The instance's import runs, newest first. Needs sys:user:read on the instance root.

Operation ID: `ListUserImports`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | "open" \| "reverting" \| "reverted" |  | Only runs in this status |
| `migration_source_id` | string |  | Only runs from this migration source (msrc_) |
| `created_after` | string |  | Created at or after this time (RFC 3339) |
| `created_before` | string |  | Created before this time (RFC 3339) |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page, 1 to 100 |

### Responses

- `200` OK: ListUserImportsResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## Create user import

```http
POST https://api.{region}.pontive.com/v1/user-imports
```

Start an import run (pontive-spec 46 §5.1): a migration's batches of users and organizations, its counters, a record per applied row, and revert. migration_source_id is optional; without one, rows match existing users by external_id only and carry no legacy_subject or firebase_scrypt hash. options are checked now and fixed: on_existing (skip, default, or update), password_policy_violation (require_change, default, or allow), identity_connections (at most 20; each app must have that connection, of that type), totp_app_ids (at most 20; each app must have TOTP on with an issuer) and emit_events (default true: pontive.user.created for each user the run creates). Needs sys:user:manage on the instance root.

Operation ID: `CreateUserImport`

### Request body (`application/json`, required): CreateUserImportRequest

Run

### Responses

- `201` Created: UserImport
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` migration_source_not_found: ErrResponse
- `422` connection_not_found, connection_type_mismatch, totp_not_enabled: ErrResponse
- `500` Internal Server Error: ErrResponse

## Get user import

```http
GET https://api.{region}.pontive.com/v1/user-imports/{user_import_id}
```

The run with its options and counters. Needs sys:user:read on the instance root.

Operation ID: `GetUserImport`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_import_id` | string | yes | User import ID (uimp_) |

### Responses

- `200` OK: UserImport
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` user_import_not_found: ErrResponse
- `500` Internal Server Error: ErrResponse

## List user import records

```http
GET https://api.{region}.pontive.com/v1/user-imports/{user_import_id}/records
```

The run's records, one per applied row, in the order applied: what matched the row (key), what happened (outcome) and why a row failed (errors, never a value from the row). Records are kept 90 days after the run's last batch. Needs sys:user:read on the instance root.

Operation ID: `ListUserImportRecords`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_import_id` | string | yes | User import ID (uimp_) |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `kind` | "user" \| "organization" |  | Only records of this kind |
| `outcome` | "created" \| "updated" \| "skipped" \| "failed" |  | Only records with this outcome |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page, 1 to 100 |

### Responses

- `200` OK: ListUserImportRecordsResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` user_import_not_found: ErrResponse
- `500` Internal Server Error: ErrResponse

## Revert user import

```http
POST https://api.{region}.pontive.com/v1/user-imports/{user_import_id}/revert
```

Undo, or with dry_run (default true) plan undoing, up to 1,000 of what the run created (pontive-spec 46 §5.5): the organizations it created whose every member is a user it created who has not signed in, then those users, deleted outright so their identifiers are free for a re-import. Users who signed in, organizations with other members and everything the run updated are kept; kept lists them with why. The run takes no more batches; call again while remaining is above 0, and the run is reverted once a call finds nothing left. Needs sys:user:manage on the instance root, and sys:org:delete on each organization it deletes.

Operation ID: `RevertUserImport`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_import_id` | string | yes | User import ID (uimp_) |

### Request body (`application/json`): RevertUserImportRequest

Revert

### Responses

- `200` OK: UserImportRevert
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` user_import_not_found: ErrResponse
- `409` user_import_reverted: ErrResponse
- `500` Internal Server Error: ErrResponse

## Import users

```http
POST https://api.{region}.pontive.com/v1/users/import
```

Apply, or with dry_run (default true) plan, a batch of at most 100 users under an import run (pontive-spec 46 §5.2). Each row is POST /v1/users's fields plus legacy_subject (the user's id in the run's migration source), created_at (in the past), status (active or deactivated), and one of password (plaintext, hashed now) or password_hash: bcrypt, argon2, scrypt, firebase_scrypt, pbkdf2, django, werkzeug, aspnet_identity, wordpress, ldap or digest (§6.1). Hashes under OWASP's minimum are wrapped in argon2id; every imported hash is replaced by a native one at the user's first sign-in, when the password is also checked against the password policy (a change is required on failure unless the run allows it). totp (base32 secret, SHA1, 6 digits, 30 seconds, with up to 16 recovery codes) is stored for the run's totp_app_ids; external_identities are written to the run's identity_connections of their type (google, github, apple, oidc; microsoft and entra are identity_not_portable). A row matches an existing user by its legacy subject, else external_id, never by email: a match is skipped or, with on_existing update, updated; an email, phone or username held by a user it does not match fails identifier_conflict. Each row stands alone and answers a record: created, updated, skipped or failed with errors, never a value from the row. Nothing is sent to the users. Without user_import_id an applied batch starts a run with the default options. The call answers 200 whatever its rows' outcomes. Needs sys:user:manage on the instance root, and sys:user:credentials when a row carries password, password_hash, totp or external_identities (never a token acting for a user).

Operation ID: `ImportUsers`

### Request body (`application/json`, required): ImportUsersRequest

Batch

### Responses

- `200` OK: UserImportBatch
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` actor_refused: a token acting for a user cannot import credentials: ErrResponse
- `404` user_import_not_found: ErrResponse
- `409` user_import_reverted: ErrResponse
- `422` too_many_records: ErrResponse
- `500` Internal Server Error: ErrResponse

## Schemas

### ImportOrganizationsRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `dry_run` | boolean |  |  |
| `organizations` | ImportOrganizationRow[] |  |  |
| `user_import_id` | string |  |  |

### UserImportBatch

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `batch` | integer |  | Batch is the batch's number in the run; absent in a dry run. |
| `counts` | BatchCounts |  |  |
| `dry_run` | boolean |  |  |
| `object` | string |  |  |
| `records` | RecordResult[] |  |  |
| `user_import_id` | string |  |  |

### ErrResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | ErrBody |  |  |

### ListUserImportsResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | UserImport[] |  |  |
| `object` | string |  |  |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### CreateUserImportRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `migration_source_id` | string |  |  |
| `name` | string |  |  |
| `options` | UserImportOptions |  |  |

### UserImport

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `counts` | UserImportCounts |  |  |
| `created_at` | string |  |  |
| `id` | string |  |  |
| `last_batch_at` | string |  |  |
| `migration_source_id` | string |  |  |
| `name` | string |  |  |
| `object` | string |  |  |
| `options` | UserImportOptions |  |  |
| `reverted_at` | string |  |  |
| `status` | "open" \| "reverting" \| "reverted" |  |  |
| `updated_at` | string |  |  |

### ListUserImportRecordsResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | UserImportRecord[] |  |  |
| `object` | string |  |  |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### RevertUserImportRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `dry_run` | boolean |  | DryRun (default true) answers what would go and deletes nothing. |

### UserImportRevert

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `dry_run` | boolean |  |  |
| `kept` | RevertKept[] |  |  |
| `object` | string |  |  |
| `organizations_deleted` | integer |  |  |
| `remaining` | integer |  | Remaining is what is left for the next call; 0 when the run is reverted. |
| `users_deleted` | integer |  |  |

### ImportUsersRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `dry_run` | boolean |  | DryRun (default true) answers the plan and writes nothing. |
| `user_import_id` | string |  | UserImportID names the run; omitted, an applied batch starts a run with the default options and no source. |
| `users` | ImportUserRow[] |  |  |

### ImportOrganizationRow

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `external_id` | string |  |  |
| `members` | ImportMemberRow[] |  |  |
| `metadata` | Record<string, string> |  |  |
| `name` | string |  |  |
| `slug` | string |  |  |

### BatchCounts

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created` | integer |  |  |
| `failed` | integer |  |  |
| `skipped` | integer |  |  |
| `updated` | integer |  |  |

### RecordResult

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `errors` | RowError[] |  |  |
| `index` | integer |  |  |
| `key` | string |  |  |
| `organization_id` | string |  |  |
| `outcome` | "created" \| "updated" \| "skipped" \| "failed" |  |  |
| `user_id` | string |  |  |
| `warnings` | RowError[] |  |  |

### ErrBody

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code is the spec's machine-readable code for this error, in snake case: a domain code such as seat_limit_reached where the refusal has one, otherwise a generic one such as permission_denied, not_found, conflict, invalid_request or service_unavailable. |
| `details` | ErrDetail[] |  | Details are per-field findings, present only on a refusal that has them, e.g. a 422 invalid_theme names each invalid value by its path, a 422 package_invalid each problem, and a 409 capability_in_use each count by its name. |
| `doc_url` | string |  | DocURL links to documentation about this error, when available. |
| `message` | string |  | Message is a human-readable description of what went wrong. |
| `object` | string |  | Object is the discriminator; always "error". |
| `param` | string |  | Param names the request parameter this error refers to, when applicable. |
| `type` | "validation_error" \| "authentication_error" \| "authorization_error" \| "not_found" \| "conflict_error" \| "rate_limit_error" \| "internal_error" |  | Type is the error's category, set by its HTTP status: one of validation_error, authentication_error, authorization_error, not_found, conflict_error, rate_limit_error, internal_error. |

### Pagination

Pagination is the page answered (api-route-review D9).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer |  | Limit is the maximum number of items per page. |
| `page` | integer |  | Page is the 1-based index of the returned page. |
| `total` | integer |  | Total is the total number of items across all pages. |
| `total_pages` | integer |  | TotalPages is the total number of pages available. |

### UserImportOptions

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `emit_events` | boolean |  | EmitEvents (default true) fires pontive.user.created for each user the run creates. |
| `identity_connections` | IdentityConnection[] |  | IdentityConnections (at most 20) are the app connections imported external identities are written to, per connection type. |
| `on_existing` | "skip" \| "update" |  | OnExisting is what a row matching an existing user does: skip (default), or update its profile, metadata and verified flags, and its credentials while the user has not set a password since. |
| `password_policy_violation` | "require_change" \| "allow" |  | PasswordPolicyViolation is what a password failing the password policy leads to: require_change (default) at the next sign-in, or allow. |
| `totp_app_ids` | string[] |  | TOTPAppIDs (at most 20) are the apps imported TOTP secrets are stored for: each must have TOTP on with an issuer. |
| `totp_apps` | TOTPApp[] |  | TOTPApps are the apps with their issuers, as resolved. Read-only. |

### UserImportCounts

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `batches` | integer |  |  |
| `memberships_written` | integer |  |  |
| `organizations_created` | integer |  |  |
| `organizations_failed` | integer |  |  |
| `organizations_updated` | integer |  |  |
| `users_created` | integer |  |  |
| `users_failed` | integer |  |  |
| `users_skipped` | integer |  |  |
| `users_updated` | integer |  |  |

### UserImportRecord

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `batch` | integer |  |  |
| `created_at` | string |  |  |
| `errors` | RowError[] |  |  |
| `id` | string |  |  |
| `index` | integer |  |  |
| `key` | string |  |  |
| `kind` | "user" \| "organization" |  |  |
| `object` | string |  |  |
| `organization_id` | string |  |  |
| `outcome` | "created" \| "updated" \| "skipped" \| "failed" |  |  |
| `reverted` | boolean |  |  |
| `user_id` | string |  |  |
| `user_import_id` | string |  |  |

### RevertKept

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `organization_id` | string |  |  |
| `reason` | "signed_in" \| "has_other_members" \| "owns_organization" \| "forbidden" \| "error" |  |  |
| `user_id` | string |  |  |

### ImportUserRow

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `email` | string |  |  |
| `email_verified` | boolean |  |  |
| `external_id` | string |  |  |
| `external_identities` | ImportedExternalIdentity[] |  |  |
| `family_name` | string |  |  |
| `given_name` | string |  |  |
| `legacy_subject` | string |  |  |
| `locale` | string |  |  |
| `metadata` | Record<string, string> |  |  |
| `middle_name` | string |  |  |
| `name` | string |  |  |
| `nickname` | string |  |  |
| `password` | string |  |  |
| `password_hash` | PasswordHash |  |  |
| `phone` | string |  |  |
| `phone_verified` | boolean |  |  |
| `picture` | string |  |  |
| `private_metadata` | Record<string, string> |  |  |
| `status` | "active" \| "deactivated" |  |  |
| `totp` | ImportedTOTP |  |  |
| `username` | string |  |  |
| `zoneinfo` | string |  |  |

### ImportMemberRow

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `legacy_subject` | string |  |  |
| `roles` | string[] |  |  |
| `user_external_id` | string |  |  |
| `user_id` | string |  |  |

### RowError

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  |  |
| `field` | string |  |  |
| `message` | string |  |  |

### ErrDetail

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string |  | Field is where the finding is: for a theme, its dotted path. |
| `message` | string |  | Message is what is wrong there. |

### IdentityConnection

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `app_id` | string |  |  |
| `connection_slug` | string |  |  |
| `connection_type` | "google" \| "github" \| "apple" \| "oidc" \| "microsoft" \| "entra" |  |  |

### TOTPApp

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `app_id` | string |  |  |
| `issuer` | string |  |  |

### ImportedExternalIdentity

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `connection_type` | "google" \| "github" \| "apple" \| "oidc" \| "microsoft" \| "entra" |  |  |
| `email` | string |  |  |
| `provider_user_id` | string |  |  |

### PasswordHash

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `hasher` | "bcrypt" \| "argon2" \| "scrypt" \| "firebase_scrypt" \| "pbkdf2" \| "django" \| "werkzeug" \| "aspnet_identity" \| "wordpress" \| "ldap" \| "digest" |  |  |
| `params` | PasswordHashParams |  |  |
| `salt` | string |  |  |
| `value` | string |  |  |

### ImportedTOTP

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `algorithm` | string |  | Algorithm, Digits and Period, when the exporter states them, must be SHA1, 6 and 30. |
| `digits` | integer |  |  |
| `period` | integer |  |  |
| `recovery_codes` | string[] |  | RecoveryCodes (at most 16) are stored hashed; each works once. |
| `secret` | string |  | Secret is base32, 16 to 64 characters. |

### PasswordHashParams

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `algorithm` | "md5" \| "sha1" \| "sha256" \| "sha512" |  |  |
| `digest` | "sha1" \| "sha256" \| "sha512" |  |  |
| `encoding` | "hex" \| "base64" |  |  |
| `iterations` | integer |  |  |
| `key_length` | integer |  |  |
| `n` | integer |  |  |
| `normalize` | "nfkc" |  |  |
| `p` | integer |  |  |
| `r` | integer |  |  |
| `salt_encoding` | "utf8" \| "hex" \| "base64" |  |  |
| `salt_position` | "none" \| "prefix" \| "suffix" |  |  |
