Skip to content

Tasks

Service for managing UiPath Action Center

Tasks are task-based automation components that can be integrated into applications and processes. They represent discrete units of work that can be triggered and monitored through the UiPath API. UiPath Action Center Guide

Usage

Prerequisites: Initialize the SDK first - see Getting Started

import { Tasks } from '@uipath/uipath-typescript/tasks';

const tasks = new Tasks(sdk);
const allTasks = await tasks.getAll();

Methods

assign()

assign(options: TaskAssignmentOptions | TaskAssignmentOptions[]): Promise<OperationResponse<TaskAssignmentOptions[] | TaskAssignmentResponse[]>>

Assigns tasks to users

Parameters

Parameter Type Description
options TaskAssignmentOptions | TaskAssignmentOptions[] Single task assignment or array of task assignments

Returns

Promise<OperationResponse<TaskAssignmentOptions[] | TaskAssignmentResponse[]>>

Promise resolving to array of task assignment results TaskAssignmentResponse

Examples

// Assign a single task to a user by ID
const result = await tasks.assign({
  taskId: <taskId>,
  userId: <userId>
});

// Or using instance method
const task = await tasks.getById(<taskId>);
const result = await task.assign({
  userId: <userId>
});

// Assign a single task to a user by email
const result = await tasks.assign({
  taskId: <taskId>,
  userNameOrEmail: "user@example.com"
});

// Assign multiple tasks
const result = await tasks.assign([
  { taskId: <taskId1>, userId: <userId> },
  { taskId: <taskId2>, userNameOrEmail: "user@example.com" }
]);
import { TaskAssignmentCriteria } from '@uipath/uipath-typescript/tasks';

// Assign to a directory group by userId + criteria — Action Center
// distributes the task across the group's members based on the criteria
const result = await tasks.assign({
  taskId: <taskId>,
  userId: <groupId>, // a DirectoryGroup id from tasks.getUsers()
  assignmentCriteria: TaskAssignmentCriteria.AllUsers
});

// ...or identify the group by name instead of id
const result2 = await tasks.assign({
  taskId: <taskId>,
  userNameOrEmail: "<groupName>",
  assignmentCriteria: TaskAssignmentCriteria.AllUsers
});

complete()

complete(options: TaskCompletionOptions, folderId: number): Promise<OperationResponse<TaskCompletionOptions>>

Completes a task with the specified type and data

Parameters

Parameter Type Description
options TaskCompletionOptions The completion options including task type, taskId, data, and action
folderId number Required folder ID

Returns

Promise<OperationResponse<TaskCompletionOptions>>

Promise resolving to completion result TaskCompleteOptions

Example

// Complete an app task
await tasks.complete({
  type: TaskType.App,
  taskId: <taskId>,
  data: {},
  action: "submit"
}, <folderId>); // folderId is required

// Complete an external task
await tasks.complete({
  type: TaskType.External,
  taskId: <taskId>
}, <folderId>); // folderId is required

create()

create(task: TaskCreateOptions, folderId: number): Promise<TaskCreateResponse>

Creates a new task. Pass type: TaskType.QuickForm (with taskSchemaKey and schema) for a schema-first HITL task rendered in Action Center; otherwise the default TaskType.External shape is used.

For QuickForm, schema is registered under taskSchemaKey on first use and reused (not updated) on subsequent calls with the same key, then the task is created in the same call. Schema keys are unique per tenant.

Parameters

Parameter Type Description
task TaskCreateOptions The task to create. Set type to select the task shape.
folderId number Required folder ID

Returns

Promise<TaskCreateResponse>

Promise resolving to the created TaskCreateResponse.

Example

import { TaskPriority, TaskType } from '@uipath/uipath-typescript';

// External task (default)
await tasks.create({
  title: "My Task",
  priority: TaskPriority.Medium
}, <folderId>);

// QuickForm task
await tasks.create({
  type: TaskType.QuickForm,
  title: "Approve invoice",
  taskSchemaKey: "8e4f2a91-3c7e-4d2b-9b5c-1a6f8d3e2c91",
  schema: {
    id: "8e4f2a91-3c7e-4d2b-9b5c-1a6f8d3e2c91",
    fields: [{ id: "invoice", type: "text", label: "Invoice", direction: "input" }],
    outcomes: [{ id: "approve", name: "Approve", type: "string", isPrimary: true }],
  },
  data: { invoice: "INV-1234" },
}, <folderId>);

createComment()

createComment(taskId: number, text: string, options?: FolderScopedOptions): Promise<TaskCommentGetResponse>

Creates a comment on a task.

Parameters

Parameter Type Description
taskId number Id of the task the comment belongs to
text string Comment text (max 512 characters)
options? FolderScopedOptions Folder scope (folderId, folderKey, or folderPath)

Returns

Promise<TaskCommentGetResponse>

Promise resolving to TaskCommentGetResponse

Example

const comment = await tasks.createComment(<taskId>, "Escalated", { folderId: <folderId> });

editMetadata()

editMetadata(taskId: number, options?: TaskEditMetadataOptions): Promise<void>

Edits a task's metadata (title, priority, catalog association, etc.).

Parameters

Parameter Type Description
taskId number Id of the task to edit
options? TaskEditMetadataOptions Fields to change plus folder scope (folderId, folderKey, or folderPath)

Returns

Promise<void>

Promise resolving once the edit completes

Example

import { TaskPriority } from '@uipath/uipath-typescript/tasks';
await tasks.editMetadata(<taskId>, { title: "Review invoice", priority: TaskPriority.High, folderId: <folderId> });

getAll()

getAll<T>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<TaskGetResponse> : NonPaginatedResponse<TaskGetResponse>>

Gets all tasks across folders with optional filtering

Type Parameters

Type Parameter Default type
T extends TaskGetAllOptions TaskGetAllOptions

Parameters

Parameter Type Description
options? T Query options including optional folderId, asTaskAdmin flag and pagination options

Returns

Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<TaskGetResponse> : NonPaginatedResponse<TaskGetResponse>>

Promise resolving to either an array of tasks NonPaginatedResponse or a PaginatedResponse when pagination options are used. TaskGetResponse

Example

// Standard array return
const allTasks = await tasks.getAll();

// Get tasks within a specific folder
const folderTasks = await tasks.getAll({
  folderId: 123
});

// Get tasks with admin permissions
// This fetches tasks across folders where the user has Task.View, Task.Edit and TaskAssignment.Create permissions
const adminTasks = await tasks.getAll({
  asTaskAdmin: true
});

// Get tasks without admin permissions (default)
// This fetches tasks across folders where the user has Task.View and Task.Edit permissions
const userTasks = await tasks.getAll({
  asTaskAdmin: false
});

// First page with pagination
const page1 = await tasks.getAll({ pageSize: 10 });

// Navigate using cursor
if (page1.hasNextPage) {
  const page2 = await tasks.getAll({ cursor: page1.nextCursor });
}

// Jump to specific page
const page5 = await tasks.getAll({
  jumpToPage: 5,
  pageSize: 10
});

getById()

getById(id: number, options?: TaskGetByIdOptions, folderId?: number): Promise<TaskGetResponse>

Gets a task by ID

Parameters

Parameter Type Description
id number The ID of the task to retrieve
options? TaskGetByIdOptions Optional query parameters including taskType for faster retrieval TaskGetByIdOptions
folderId? number Optional folder ID (REQUIRED when options.taskType is provided)

Returns

Promise<TaskGetResponse>

Promise resolving to the task TaskGetResponse

Example

// Get a task by ID
const task = await tasks.getById(<taskId>);

// Get a form task by ID
const formTask = await tasks.getById(<taskId>, {}, <folderId>);

// Access form task properties
console.log(formTask.formLayout);

// Get a document validation task by ID (faster with taskType provided in the options)
const dvTask = await tasks.getById(<taskId>, { taskType: TaskType.DocumentValidation }, <folderId>);

getComments()

getComments<T>(taskId: number, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<TaskCommentGetResponse> : NonPaginatedResponse<TaskCommentGetResponse>>

Gets the comments for a task.

Type Parameters

Type Parameter Default type
T extends TaskCommentGetByTaskIdOptions TaskCommentGetByTaskIdOptions

Parameters

Parameter Type Description
taskId number The task to list comments for
options? T Folder scope (folderId, folderKey, or folderPath) plus query and pagination options

Returns

Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<TaskCommentGetResponse> : NonPaginatedResponse<TaskCommentGetResponse>>

Promise resolving to either a NonPaginatedResponse or PaginatedResponse of TaskCommentGetResponse items, paginated when pagination options are used.

Example

const comments = await tasks.getComments(<taskId>, { folderId: <folderId> });

// Paginated
const page1 = await tasks.getComments(<taskId>, { folderId: <folderId>, pageSize: 20 });
if (page1.hasNextPage) {
  const page2 = await tasks.getComments(<taskId>, { folderId: <folderId>, cursor: page1.nextCursor });
}

getDataById()

getDataById(id: number, options?: FolderScopedOptions): Promise<TaskDataGetResponse>

Gets a task's data (form/task payload) and core metadata, by task id.

Works for any task type (Form, App, External, etc.).

Parameters

Parameter Type Description
id number The task id to fetch data for
options? FolderScopedOptions Folder scope (folderId, folderKey, or folderPath)

Returns

Promise<TaskDataGetResponse>

Promise resolving to TaskDataGetResponse

Example

const task = await tasks.getDataById(<taskId>, { folderId: <folderId> });
console.log(task.data);

getDataByKey()

getDataByKey(key: string, options?: FolderScopedOptions): Promise<TaskDataGetResponse>

Gets a task's data (form/task payload) and core metadata, by task key.

Works for any task type (Form, App, External, etc.).

Parameters

Parameter Type Description
key string The task key (GUID) to fetch data for
options? FolderScopedOptions Folder scope (folderId, folderKey, or folderPath)

Returns

Promise<TaskDataGetResponse>

Promise resolving to TaskDataGetResponse

Example

const task = await tasks.getDataByKey("<taskKey>", { folderId: <folderId> });
console.log(task.data);

getSchema()

getSchema(taskId: number, options?: FolderScopedOptions): Promise<null | TaskGetSchemaResponse>

Experimental

Gets the schema of a task: the fields it holds and the outcomes it can be completed with. Use it to render the task's form in your own UI.

Supported for App tasks and QuickForm tasks. The type of the response tells which shape it has: - TaskType.App: schema has inputs (read-only), outputs (filled in by the user), inOuts (pre-filled, editable) and outcomes. A property's name is its key in the task's data, and an outcome's name is the action to pass to complete(). - TaskType.QuickForm: the schema the task was created with, same as getSchemaByKey() returns for the task's taskSchemaKey. Its schema body is returned as it was registered.

An App task's schema is returned only to a caller who can view apps in the task's folder and whose token has the Apps or Apps.Read scope. Without them, or when the task's app is no longer deployed in that folder, the schema has no fields and no outcomes.

Other task types have no schema here and return null. A Form task's form definition is the formLayout returned by getById().

The task's type and keys are looked up automatically (one extra read). When called on a task object returned by the SDK, they are already known, so no lookup happens.

Parameters

Parameter Type Description
taskId number The task to get the schema for
options? FolderScopedOptions Folder scope (folderId, folderKey, or folderPath)

Returns

Promise<null | TaskGetSchemaResponse>

Promise resolving to a TaskGetSchemaResponse, or null when the task has no schema (task types other than App and QuickForm, or a task whose schema is not available).

Examples

const result = await tasks.getSchema(<taskId>, { folderId: <folderId> });
const task = await tasks.getById(<taskId>, {}, <folderId>);
const result = await task.getSchema();
import { TaskType } from '@uipath/uipath-typescript/tasks';

const task = await tasks.getById(<taskId>, {}, <folderId>);
const result = await task.getSchema();

if (result?.type === TaskType.App) {
  // Editable fields of an App task, with their current values
  const { outputs, inOuts, outcomes } = result.schema;
  const editable = [...inOuts, ...outputs].map((property) => ({
    name: property.name,
    type: property.type,
    required: property.required,
    value: task.data?.[property.name],
  }));

  // Complete with one of the schema's outcomes (the schema has none when the caller cannot read it)
  if (outcomes.length > 0) {
    await task.complete({
      type: TaskType.App,
      data: { ...task.data, comment: "Looks good" },
      action: outcomes[0].name,
    });
  }
}

if (result?.type === TaskType.QuickForm) {
  // The schema body, as registered when the task was created
  console.log(result.name, result.schema);
}

getSchemaByKey()

getSchemaByKey(key: string, options?: FolderScopedOptions): Promise<TaskSchemaGetResponse>

Experimental

Gets the schema a QuickForm task was created with.

The key is the taskSchemaKey of a QuickForm task, returned by getAll(), getById(), getDataById() and getDataByKey(). The folder is only used to check task view permission; it does not have to be the folder the schema was registered in.

Parameters

Parameter Type Description
key string The schema key (a task's taskSchemaKey)
options? FolderScopedOptions Folder scope (folderId, folderKey, or folderPath)

Returns

Promise<TaskSchemaGetResponse>

Promise resolving to the schema as a TaskSchemaGetResponse

Examples

const schema = await tasks.getSchemaByKey('<taskSchemaKey>', { folderId: <folderId> });
console.log(schema.name, schema.schema);
// Get the schema of a QuickForm task
const task = await tasks.getDataById(<taskId>, { folderId: <folderId> });
if (task.taskSchemaKey) {
  const schema = await tasks.getSchemaByKey(task.taskSchemaKey, { folderId: <folderId> });
  console.log(schema.name, schema.schema);
}

getUsers()

getUsers<T>(folderId: number, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<UserLoginInfo> : NonPaginatedResponse<UserLoginInfo>>

Gets task users (users, robots, groups etc) in the given folder who have Tasks.View and Tasks.Edit permissions Returns a NonPaginatedResponse with data and totalCount when no pagination parameters are provided, or a PaginatedResponse when any pagination parameter is provided

Type Parameters

Type Parameter Default type
T extends TaskGetUsersOptions TaskGetUsersOptions

Parameters

Parameter Type Description
folderId number The folder ID to get task users from
options? T Optional query and pagination parameters

Returns

Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<UserLoginInfo> : NonPaginatedResponse<UserLoginInfo>>

Promise resolving to either an array of task users NonPaginatedResponse or a PaginatedResponse when pagination options are used. UserLoginInfo

Example

// Get task users from a folder
const users = await tasks.getUsers(<folderId>);

// Access user properties
console.log(users.items[0].name);
console.log(users.items[0].emailAddress);

reassign()

reassign(options: TaskAssignmentOptions | TaskAssignmentOptions[]): Promise<OperationResponse<TaskAssignmentOptions[] | TaskAssignmentResponse[]>>

Reassigns tasks to new users

Parameters

Parameter Type Description
options TaskAssignmentOptions | TaskAssignmentOptions[] Single task assignment or array of task assignments

Returns

Promise<OperationResponse<TaskAssignmentOptions[] | TaskAssignmentResponse[]>>

Promise resolving to array of task assignment results TaskAssignmentResponse

Examples

// Reassign a single task to a user by ID
const result = await tasks.reassign({
  taskId: <taskId>,
  userId: <userId>
});

// Or using instance method
const task = await tasks.getById(<taskId>);
const result = await task.reassign({
  userId: <userId>
});

// Reassign a single task to a user by email
const result = await tasks.reassign({
  taskId: <taskId>,
  userNameOrEmail: "user@example.com"
});

// Reassign multiple tasks
const result = await tasks.reassign([
  { taskId: <taskId1>, userId: <userId> },
  { taskId: <taskId2>, userNameOrEmail: "user@example.com" }
]);
import { TaskAssignmentCriteria } from '@uipath/uipath-typescript/tasks';

// Reassign to a directory group by userId + criteria
const result = await tasks.reassign({
  taskId: <taskId>,
  userId: <groupId>, // a DirectoryGroup id from tasks.getUsers()
  assignmentCriteria: TaskAssignmentCriteria.AllUsers
});

// ...or identify the group by name instead of id
const result2 = await tasks.reassign({
  taskId: <taskId>,
  userNameOrEmail: "<groupName>",
  assignmentCriteria: TaskAssignmentCriteria.AllUsers
});

saveData()

saveData(taskId: number, data: Record<string, unknown>, options?: TaskSaveDataOptions): Promise<void>

Saves a task's data (form/task payload), replacing the existing payload.

Routes to the correct save endpoint by task type: Form and App tasks use their own endpoints, everything else uses the generic one. If type is not passed, it is looked up automatically (one extra read). When called on a task object returned by the SDK, the type is already known, so no lookup happens.

Parameters

Parameter Type Description
taskId number The task to update
data Record<string, unknown> The task data to save (replaces the existing payload)
options? TaskSaveDataOptions Task type plus folder scope (folderId, folderKey, or folderPath)

Returns

Promise<void>

Promise resolving once the save completes

Examples

await tasks.saveData(<taskId>, { amount: 1200, approved: true }, { folderId: <folderId> });
import { TaskType } from '@uipath/uipath-typescript/tasks';
await tasks.saveData(<taskId>, { amount: 1200, approved: true }, { type: TaskType.Form, folderId: <folderId> });

saveTags()

saveTags(taskId: number, tags: Tag[], options?: FolderScopedOptions): Promise<void>

Saves the tags on a task, replacing any existing tags.

Parameters

Parameter Type Description
taskId number The task to tag
tags Tag[] The tags to set
options? FolderScopedOptions Folder scope (folderId, folderKey, or folderPath)

Returns

Promise<void>

Promise resolving once the save completes

Example

await tasks.saveTags(<taskId>, [{ name: "priority", displayName: "Priority", displayValue: "High" }], { folderId: <folderId> });

unassign()

unassign(taskId: number | number[]): Promise<OperationResponse<TaskAssignmentResponse[] | { taskId: number; }[]>>

Unassigns tasks (removes current assignees)

Parameters

Parameter Type Description
taskId number | number[] Single task ID or array of task IDs to unassign

Returns

Promise<OperationResponse<TaskAssignmentResponse[] | { taskId: number; }[]>>

Promise resolving to array of task assignment results TaskAssignmentResponse

Example

// Unassign a single task
const result = await tasks.unassign(<taskId>);

// Or using instance method
const task = await tasks.getById(<taskId>);
const result = await task.unassign();

// Unassign multiple tasks
const result = await tasks.unassign([<taskId1>, <taskId2>, <taskId3>]);