Skip to main content

Select and update identities in bulk

createBulkJob changes attributes on many identities at once. You describe who with a selection and what with a list of changes, preview the result, then run it as a job and read the job until it finishes. The mutation and the job queries need the identity.modify permission.

Identities are the only thing a bulk job can change today, so entityType is always IDENTITY.

Describe the selection​

A selection has an include list and an optional exclude list of selectors. Owlie takes every identity matched by any include selector, then removes every identity matched by any exclude selector. An empty include selects nobody: to select everyone, include a selector of kind ALL.

kindSelectsFields
ALLEvery identity.None.
IDENTITYThe identities you name.identity_ids
GROUPMembers of the groups.group_ids, and membership: EFFECTIVE (the default, which counts nested groups) or DIRECT.
ROLEIdentities holding the Owlie roles.role_ids
FILTERIdentities matching a filter.filter
ASSIGNMENTIdentities who currently hold a resource, or specific Grants on it.resource_id, and optionally grants, each with kind and unique_id.

Describe the changes​

Each change sets one attribute: key names the attribute, and expression is an OXL expression that gives its new value. There is no separate form for a fixed value, so a literal is written as an expression too:

expressionSets the attribute to
"Finance Operations"That text. The quotes are part of the expression.
lower(identity.email)A value computed from the identity being changed.
nullNothing: it clears the attribute.

An expression reads the identity as identity, as it was before any of the job's changes. Several changes to one identity all see the same starting values.

key is an identity attribute your organization can edit, such as department, or a custom attribute. A job takes 1 to 50 changes, each with a different key. System fields are refused, and each computed value is checked the same way a single edit is.

Preview​

Run the mutation with mode: PREVIEW first. A preview changes nothing and creates no job.

mutation PreviewBulkJob($selection: IdentitySelectionInput!, $changes: [IdentityChangeInput!]!) {
createBulkJob(mode: PREVIEW, entityType: IDENTITY, selection: $selection, changes: $changes) {
preview {
complete
counts {
included
excluded
total
}
rows {
identity {
id
display_name
}
changes {
key
before
after
}
error
}
excludedRows {
identity {
id
display_name
}
}
}
}
}

Variables:

{
"selection": {
"include": [{ "kind": "FILTER", "filter": { "department": "Finance Ops" } }],
"exclude": [{ "kind": "GROUP", "group_ids": ["019d1f37-0ee5-7eb0-a26d-62b7e8f706f6"] }]
},
"changes": [{ "key": "department", "expression": "\"Finance Operations\"" }]
}
{
"data": {
"createBulkJob": {
"preview": {
"complete": true,
"counts": { "included": 14, "excluded": 2, "total": 12 },
"rows": [
{
"identity": { "id": "019d1f36-0000-7000-8000-000000000005", "display_name": "Ava Moreau" },
"changes": [{ "key": "department", "before": "Finance Ops", "after": "Finance Operations" }],
"error": null
}
],
"excludedRows": [
{ "identity": { "id": "019d1f36-0000-7000-8000-000000000012", "display_name": "Noor Haddad" } }
]
}
}
}
}

The response above is shortened to one row of each kind.

  • counts.total is the number of identities the job would change: those included, less those excluded. The counts are exact.
  • rows shows the value of each changed attribute before and after. A row whose expression fails, or whose result is not a valid value for the attribute, has an error and no changes.
  • complete is true when rows holds every selected identity, which is the case up to 100 identities. Above 100, rows is a sample of 100 drawn across the selectors, and excludedRows is a sample of at most 25. The counts still cover everyone.

A preview reads the data as it is now. If identities change before you run the job, the job's selection can differ from the preview.

Run​

Run the same selection and changes with mode: RUN, and add maxTargets: the largest number of identities you are willing to change, from 1 to 25,000. Use the preview's counts.total, or a little above it.

mutation RunBulkJob($selection: IdentitySelectionInput!, $changes: [IdentityChangeInput!]!, $maxTargets: Int!) {
createBulkJob(mode: RUN, entityType: IDENTITY, selection: $selection, changes: $changes, maxTargets: $maxTargets) {
job {
id
status
maxTargets
}
}
}

Variables:

{
"selection": {
"include": [{ "kind": "FILTER", "filter": { "department": "Finance Ops" } }],
"exclude": [{ "kind": "GROUP", "group_ids": ["019d1f37-0ee5-7eb0-a26d-62b7e8f706f6"] }]
},
"changes": [{ "key": "department", "expression": "\"Finance Operations\"" }],
"maxTargets": 12
}

The mutation returns as soon as the job is queued, with status QUEUED. No identity has changed yet. When the job starts, Owlie evaluates the selection again. If it now matches more identities than maxTargets, the job fails before it changes anyone.

A run does not need a preview first, but without one you have not seen what it will write.

Read the result​

Poll bulkJob until the status is final:

query BulkJob($id: ID!) {
bulkJob(id: $id) {
id
status
targetCount
completedCount
failedCount
attentionRequiredCount
failures {
identityId
status
error
}
error
completedAt
}
}

Variables:

{ "id": "019d1f38-4b1e-7c2a-9d57-3e0a6b7c8d90" }
statusMeaning
QUEUEDAccepted, not started.
MATERIALIZINGOwlie is working out which identities the selection matches.
RUNNINGChanges are being applied. completedCount rises toward targetCount.
COMPLETEDEvery selected identity was changed.
COMPLETED_WITH_ERRORSThe job finished, and some identities failed. failedCount says how many.
ATTENTION_REQUIREDThe job finished, and for some identities Owlie cannot tell whether the change was applied. attentionRequiredCount says how many.
FAILEDThe job stopped without finishing. error says why, for example a selection larger than maxTargets.

A finished job is not a job in which every identity changed. Read failedCount and attentionRequiredCount, not only status. failures lists up to 25 of the most recent identities that failed or need attention, each with its error. Owlie does not retry an identity in ATTENTION_REQUIRED on its own: check that identity and correct it by hand.

bulkJobs lists recent jobs, newest first, with first and after for paging and optional status and entityType filters. Owlie keeps a finished job and its details for seven days. The changes themselves stay in each identity's history.

Select identities without changing them​

The identities list accepts the same selection, so you can read exactly who a selection matches. includeCounts: true adds the exact counts.

query SelectedIdentities($selection: IdentitySelectionInput, $first: Int, $after: String) {
identities(selection: $selection, includeCounts: true, first: $first, after: $after) {
counts {
included
excluded
total
}
data {
id
display_name
department
}
pageInfo {
hasNextPage
nextCursor
}
}
}

If you send both filter and selection, an identity must match both.