Auth API reference

Auth API · End-Users

post/v1/apps/{app_id}/end-users/import/mappingsAuth

Save an import mapping (or a draft) for this app.

The server validates the mapping against `columns` (every issue in `details.issues`), computes `header_fingerprint`, and refuses personal data: value-map entries and constants must be role or tenant names, and column names must not look like data. A mapping holds column names, transforms and role tables only. Audited as `users.import_mapping.created`.

Path parameters

app_id*string

Id of the app.

Headers

Idempotency-Keystring

Retry safety: a repeat with the same key and body replays the first response instead of creating a mapping again. Same key with a different body: 409 `IDEMPOTENCY_KEY_REUSE`. 24 h window.

Request body

namestring

Name, 1-80 characters after trimming, unique per app. Omit or `null` to store a draft (what the console does for a one-off run: a job needs a `mapping_id`).

Example: "Clerk export"

mapping*object

Mapping v1 (`@repo/user-import`): `{ version: 1, fields: { <target>: { source | sources[], transform?, options? } | { constant } }, metadata?: { columns[], json_column? }, value_maps?: { role: { <file value>: <role name> } } }`. Targets: `email` (required), `username`, `display_name`, `role`, `tenant_slugs`, `external_id`, `email_verified`, `password_hash`, `password_hash_algorithm`, `disabled`. Transforms: `join`, `boolean`, `present`, `split_list`, `value_map`, `hash_algorithm`, `json`, `in_list`. Constants only for `email_verified`, `role`, `disabled`, `tenant_slugs`.

Example: {"version":1,"fields":{"email":{"source":"primary_email_address"},"external_id":{"source":"id"},"display_name":{"sources":["first_name","last_name"],"transform":"join"},"email_verified":{"source":"verified_email_addresses","transform":"in_list"},"password_hash":{"source":"password_digest"},"password_hash_algorithm":{"sources":["password_hasher"],"transform":"hash_algorithm"},"role":{"source":"role","transform":"value_map"}},"value_maps":{"role":{"administrator":"admin"}}}

columns*array

Column names of the file (headers, or `column_1…N` for a headerless file), at most 200. Every column the mapping reads must be listed. Names that look like data (an email, a hash, a long number) are refused.

Example: ["id","first_name","last_name","primary_email_address","verified_email_addresses","password_digest","password_hasher","role"]

Response · 201 Mapping stored.

id*string · uuid

Unique identifier of the mapping.

app_id*string · uuid

The Auth app the mapping belongs to.

name*string

Name shown in the console, unique per app. `null` marks a draft: hidden from the list and deleted 7 days after its last edit.

Example: "Clerk export"

mapping*object

Mapping v1 (`@repo/user-import`): `{ version: 1, fields: { <target>: { source | sources[], transform?, options? } | { constant } }, metadata?: { columns[], json_column? }, value_maps?: { role: { <file value>: <role name> } } }`. Targets: `email` (required), `username`, `display_name`, `role`, `tenant_slugs`, `external_id`, `email_verified`, `password_hash`, `password_hash_algorithm`, `disabled`. Transforms: `join`, `boolean`, `present`, `split_list`, `value_map`, `hash_algorithm`, `json`, `in_list`. Constants only for `email_verified`, `role`, `disabled`, `tenant_slugs`.

Example: {"version":1,"fields":{"email":{"source":"primary_email_address"},"external_id":{"source":"id"},"display_name":{"sources":["first_name","last_name"],"transform":"join"},"email_verified":{"source":"verified_email_addresses","transform":"in_list"},"password_hash":{"source":"password_digest"},"password_hash_algorithm":{"sources":["password_hasher"],"transform":"hash_algorithm"},"role":{"source":"role","transform":"value_map"}},"value_maps":{"role":{"administrator":"admin"}}}

columns*array

Column names of the file the mapping was made for.

Example: ["id","first_name","last_name","primary_email_address","verified_email_addresses","password_digest","password_hasher","role"]

header_fingerprint*string

Order-insensitive fingerprint of `columns` (`hf1_…`), computed by the server. Filter the list with it to find a mapping for a file with the same headers.

Example: "hf1_5c3a9e1f0b7d2a64"

created_by*string · uuid

Platform user who created the mapping, when known.

created_at*string · date-time

When the mapping was created (ISO 8601).

updated_at*string · date-time

When the mapping was last changed (ISO 8601).

Example

Request

POST https://api.auth.productcraft.co/v1/apps/{app_id}/end-users/import/mappings
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "name": "Clerk export",
  "mapping": {
    "version": 1,
    "fields": {
      "email": {
        "source": "primary_email_address"
      },
      "external_id": {
        "source": "id"
      },
      "display_name": {
        "sources": [
          "first_name",
          "last_name"
        ],
        "transform": "join"
      },
      "email_verified": {
        "source": "verified_email_addresses",
        "transform": "in_list"
      },
      "password_hash": {
        "source": "password_digest"
      },
      "password_hash_algorithm": {
        "sources": [
          "password_hasher"
        ],
        "transform": "hash_algorithm"
      },
      "role": {
        "source": "role",
        "transform": "value_map"
      }
    },
    "value_maps": {
      "role": {
        "administrator": "admin"
      }
    }
  },
  "columns": [
    "id",
    "first_name",
    "last_name",
    "primary_email_address",
    "verified_email_addresses",
    "password_digest",
    "password_hasher",
    "role"
  ]
}

Response

{
  "id": "00000000-0000-0000-0000-000000000000",
  "app_id": "00000000-0000-0000-0000-000000000000",
  "name": "Clerk export",
  "mapping": {
    "version": 1,
    "fields": {
      "email": {
        "source": "primary_email_address"
      },
      "external_id": {
        "source": "id"
      },
      "display_name": {
        "sources": [
          "first_name",
          "last_name"
        ],
        "transform": "join"
      },
      "email_verified": {
        "source": "verified_email_addresses",
        "transform": "in_list"
      },
      "password_hash": {
        "source": "password_digest"
      },
      "password_hash_algorithm": {
        "sources": [
          "password_hasher"
        ],
        "transform": "hash_algorithm"
      },
      "role": {
        "source": "role",
        "transform": "value_map"
      }
    },
    "value_maps": {
      "role": {
        "administrator": "admin"
      }
    }
  },
  "columns": [
    "id",
    "first_name",
    "last_name",
    "primary_email_address",
    "verified_email_addresses",
    "password_digest",
    "password_hasher",
    "role"
  ],
  "header_fingerprint": "hf1_5c3a9e1f0b7d2a64",
  "created_by": "00000000-0000-0000-0000-000000000000",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}