/v1/apps/{app_id}/end-users/import/mappings/suggestAuthSuggest a mapping for a file from its column descriptions (AI with a rule-based fallback).
Send the output of `describeColumns` (`@repo/user-import`): header names, shape tags, fill rates and the values of categorical columns, never the rows. The server checks the payload again and refuses anything that looks like personal data (an email, a hash, a long number, a token) with 400, naming the column but never the value. The payload and this app's role names go to Google's Gemini API; the answer is verified (sources must be given columns, transforms from the closed set, no constants, value-map targets must be roles of this app) and anything failing a check is dropped. When no model is configured, it fails, or it takes longer than 15 seconds, the rule-based mapping is returned with `source: heuristic`. Limits: 30 suggestions an hour per app, 100 per workspace, and a service-wide daily cap. Audited as `users.import_mapping.suggested` (column count and source; never the payload).
Path parameters
app_id*stringId of the app.
Request body
format*objectFormat of the file the columns come from.
headerbooleanCSV: whether the file has a header row (default true). Ignored for NDJSON.
columns*arrayColumn descriptions from `describeColumns` (`@repo/user-import`), at most 200. This, and the app's role names, is everything the AI model sees.
Response · 200 A verified mapping suggestion.
mapping*objectSuggested mapping, already verified: every source is one of the given columns, transforms are from the closed set, there are no constants, and value-map targets are roles of this app. 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"}}}
confidence*objectConfidence per mapped target.
Example: {"email":"high","display_name":"medium"}
source*object`ai`: Google's Gemini API proposed it. `heuristic`: the built-in header and shape rules (no AI configured, the model failed or timed out, or its answer was unusable).
sent*objectExactly what was sent to the AI model (with the app's role names), or `null` when nothing was sent.
Example
Request
POST https://api.auth.productcraft.co/v1/apps/{app_id}/end-users/import/mappings/suggest
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"format": {},
"header": false,
"columns": [
{
"name": "Rôle",
"shape": "text",
"fill_rate": 1,
"values": [
"Admin",
"Member",
"Viewer"
]
}
]
}Response
{
"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"
}
}
},
"confidence": {
"email": "high",
"display_name": "medium"
},
"source": {},
"sent": {}
}