Skip to content

Identity Mapper API

DRAFT — Internal Developer Use Only

This API reference is for internal development teams.

Overview

What it is: The Identity Mapper API provides programmatic access to Hydden's identity mapping engine. Use these endpoints to check mapping status, test regex rules before deploying them, preview how a rule would affect accounts, trigger a full mapping run, and prune orphaned owners.

Source: src/iam/mapper/rest/rest.go

Base Path

/internal/v1/idmapper

Authentication

All endpoints require JWT cookie or API token authentication.

Endpoints

MethodPathDescriptionAuth required
GET/internal/v1/idmapper/statusGet mapper status and last run statisticsJWT + API token
POST/internal/v1/idmapper/rule/testTest a regex pattern against a stringJWT + API token
POST/internal/v1/idmapper/rule/previewPreview a mapping rule's impact on accountsJWT + API token
POST/internal/v1/idmapper/runTrigger an identity mapping runJWT + API token
POST/internal/v1/idmapper/pruneDelete all unmapped (orphaned) ownersJWT + API token

GET /internal/v1/idmapper/status

Get the current status of the identity mapper, including statistics from the last mapping run.

Request:

http
GET /internal/v1/idmapper/status
Authorization: Bearer <token>

Response (200):

json
{
  "lastMapStart": 1707700800000,
  "lastMapFinish": 1707701100000,
  "orphanCount": 23,
  "mappedAccounts": 4521,
  "newIdentities": 12,
  "deletedIdentities": 3
}

Response fields:

FieldTypeDescription
lastMapStartint64Timestamp (ms) when the last mapping run started
lastMapFinishint64Timestamp (ms) when the last mapping run completed
orphanCountint64Number of owners with no mapped accounts
mappedAccountsint64Total number of accounts currently mapped to owners
newIdentitiesint64Identities created during the last run
deletedIdentitiesint64Identities removed during the last run

POST /internal/v1/idmapper/rule/test

Test a regex pattern and optional replacement against a test string. Use this to validate mapping rule patterns before saving them.

Request:

http
POST /internal/v1/idmapper/rule/test
Content-Type: application/json
Authorization: Bearer <token>
json
{
  "pattern": "^(.+)@company\\.com$",
  "replace": "$1",
  "testString": "john.doe@company.com"
}

Request fields:

FieldTypeRequiredDescription
patternstringYesRegex pattern to test
replacestringNoReplacement string (supports $1, $2 capture groups)
testStringstringYesString to test the pattern against

Response (200):

json
{
  "match": true,
  "result": "john.doe",
  "error": false
}

Response fields:

FieldTypeDescription
matchboolWhether the pattern matched the test string
resultstringResult after applying pattern and replacement
errorboolWhether the regex compilation failed

POST /internal/v1/idmapper/rule/preview

Preview the effect of a mapping rule on actual account data. Returns a list of accounts that would match, along with the identity they would map to.

Request:

http
POST /internal/v1/idmapper/rule/preview
Content-Type: application/json
Authorization: Bearer <token>
json
{
  "rule": {
    "ruleCategory": "email",
    "matchTemplate": "email",
    "matchProperty": "email",
    "pattern": "^(.+)@company\\.com$",
    "replace": "$1",
    "accountType": ["User"],
    "classifications": [],
    "accountTemplate": "upn",
    "createOption": 1,
    "max": 100,
    "dataSourceId": "",
    "accountFilter": "",
    "showAll": false,
    "providerFilter": "",
    "showMapped": true
  }
}

Key request fields:

FieldTypeDescription
ruleCategorystringRule category (e.g., email, upn, custom)
matchTemplatestringTemplate for matching (e.g., email, upn, samaccountname)
matchPropertystringAccount property to match against
patternstringRegex pattern for matching
replacestringReplacement string with capture groups
accountTypestring[]Filter by account types (User, Service, etc.)
classificationsstring[]Filter by account classifications
createOptionint32Owner creation behavior (0=none, 1=create if needed)
maxint32Maximum accounts to return in preview
dataSourceIdstringFilter to a specific data source (empty = all)
showAllboolShow all accounts, not just matches
showMappedboolInclude already-mapped accounts

Response (200):

json
{
  "uniqueId": "rule-preview-uuid",
  "error": false,
  "reason": "",
  "accounts": [
    {
      "id": "acct-uuid-1",
      "name": "jdoe",
      "displayName": "John Doe",
      "email": "john.doe@company.com",
      "matchedOnValue": ["john.doe@company.com"],
      "platform": "Azure AD",
      "dataSourceId": "ds-uuid",
      "dataSource": "Corporate Azure",
      "accountType": "User",
      "mappedIdentity": "owner-uuid",
      "mappedName": "John Doe",
      "upn": "john.doe@company.com",
      "match": true,
      "reason": "",
      "provider": "AzureAD"
    }
  ],
  "numAccounts": 1,
  "numOrphans": 0
}

POST /internal/v1/idmapper/run

Trigger the identity mapper to execute a full mapping run. The mapper processes all accounts against configured mapping rules and creates or updates owner-to-account relationships.

Request:

http
POST /internal/v1/idmapper/run
Authorization: Bearer <token>

No request body required.

Response (200):

Returns the same IdmapperStatus structure as the status endpoint, reflecting the newly initiated run.

json
{
  "lastMapStart": 1707701200000,
  "lastMapFinish": 0,
  "orphanCount": 23,
  "mappedAccounts": 4521,
  "newIdentities": 0,
  "deletedIdentities": 0
}

Note: The lastMapFinish will be 0 while the run is in progress. Poll the status endpoint to check completion.


POST /internal/v1/idmapper/prune

Delete all owner identities that are not currently mapped to any account. This permanently removes orphaned owners from the system.

Request:

http
POST /internal/v1/idmapper/prune
Authorization: Bearer <token>

No request body required.

Response (200):

Returns the same IdmapperStatus structure with updated orphanCount (expected to be 0 after successful prune) and updated deletedIdentities count.

json
{
  "lastMapStart": 1707701200000,
  "lastMapFinish": 1707701500000,
  "orphanCount": 0,
  "mappedAccounts": 4521,
  "newIdentities": 0,
  "deletedIdentities": 23
}

Caution: This operation is destructive. Pruned owners cannot be recovered. Verify the orphan count via the status endpoint before pruning.


Error Responses

StatusDescription
400Invalid request body or malformed regex pattern
403Authentication failed or insufficient permissions
500Internal server error during mapping or prune operation

Hydden Documentation and Training Hub