Skip to content

Function: createIssue()

ts
function createIssue(client, parameters): Promise<{
[key: string]: unknown;
  id: string;
  key: string;
  self: string;
  transition?: {
   [key: string]: unknown;
     errorCollection?: {
      [key: string]: unknown;
        errorMessages?: string[];
        errors?: Record<string, any>;
        status?: number;
     };
     status?: number;
     warningCollection?: {
      [key: string]: unknown;
        warnings?: string[];
     };
  };
  watchers?: {
   [key: string]: unknown;
     errorCollection?: {
      [key: string]: unknown;
        errorMessages?: string[];
        errors?: Record<string, any>;
        status?: number;
     };
     status?: number;
     warningCollection?: {
      [key: string]: unknown;
        warnings?: string[];
     };
  };
}>;

Defined in: src/cloud/api/issues.ts:93

Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask. A transition may be applied, to move the issue or subtask to a workflow step other than the default start step, and issue properties set.

The content of the issue or subtask is defined using update and fields. The fields that can be set in the issue or subtask are determined using the Get create issue metadata. These are the same fields that appear on the issue's create screen. Note that the description, environment, and any textarea type custom fields (multi-line text fields) take Atlassian Document Format content. Single line custom fields (textfield) accept a string and don't handle Atlassian Document Format content.

Creating a subtask differs from creating an issue as follows:

  • issueType must be set to a subtask issue type (use Get create issue metadata to find subtask issue types).
  • parent must contain the ID or key of the parent issue.

In a next-gen project any issue may be made a child providing that the parent and child are members of the same project.

Permissions required: Browse projects and Create issues project permissions for the project in which the issue or subtask is created.

Parameters

ParameterTypeDescription
clientClient-
parameters{ fields?: Record<string, any>; historyMetadata?: { [key: string]: unknown; activityDescription?: string; activityDescriptionKey?: string; actor?: { [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }; cause?: { [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }; description?: string; descriptionKey?: string; emailDescription?: string; emailDescriptionKey?: string; extraData?: Record<string, any>; generator?: { [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }; type?: string; }; properties?: object[]; transition?: { [key: string]: unknown; expand?: string; fields?: Record<string, any>; hasScreen?: boolean; id?: string; isAvailable?: boolean; isConditional?: boolean; isGlobal?: boolean; isInitial?: boolean; looped?: boolean; name?: string; to?: { [key: string]: unknown; description?: string; iconUrl?: string; id?: string; name?: string; scope?: { [key: string]: unknown; project?: { [key: string]: unknown; avatarUrls?: { [key: ...]: ...; 16x16?: ...; 24x24?: ...; 32x32?: ...; 48x48?: ...; }; id?: string; key?: string; name?: string; projectCategory?: { [key: ...]: ...; description?: ...; id?: ...; name?: ...; self?: ...; }; projectTypeKey?: | ... & ... | "software" | "service_desk" | "business" | "product_discovery" | "customer_service"; self?: string; simplified?: boolean; }; type?: string & object | "PROJECT" | "TEMPLATE"; }; self?: string; statusCategory?: { [key: string]: unknown; colorName?: string; id?: number; key?: string; name?: string; self?: string; }; untranslatedName?: string; }; }; update?: Record<string, any>; updateHistory?: boolean; }-
parameters.fields?Record<string, any>List of issue screen fields to update, specifying the sub-field to update and its value for each field. This field provides a straightforward option when setting a sub-field. When multiple sub-fields or other operations are required, use update. Fields included in here cannot be included in update.
parameters.historyMetadata?{ [key: string]: unknown; activityDescription?: string; activityDescriptionKey?: string; actor?: { [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }; cause?: { [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }; description?: string; descriptionKey?: string; emailDescription?: string; emailDescriptionKey?: string; extraData?: Record<string, any>; generator?: { [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }; type?: string; }-
parameters.historyMetadata.activityDescription?stringThe activity described in the history record.
parameters.historyMetadata.activityDescriptionKey?stringThe key of the activity described in the history record.
parameters.historyMetadata.actor?{ [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }-
parameters.historyMetadata.actor.avatarUrl?stringThe URL to an avatar for the user or system associated with a history record.
parameters.historyMetadata.actor.displayName?stringThe display name of the user or system associated with a history record.
parameters.historyMetadata.actor.displayNameKey?stringThe key of the display name of the user or system associated with a history record.
parameters.historyMetadata.actor.id?stringThe ID of the user or system associated with a history record.
parameters.historyMetadata.actor.type?stringThe type of the user or system associated with a history record.
parameters.historyMetadata.actor.url?stringThe URL of the user or system associated with a history record.
parameters.historyMetadata.cause?{ [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }-
parameters.historyMetadata.cause.avatarUrl?stringThe URL to an avatar for the user or system associated with a history record.
parameters.historyMetadata.cause.displayName?stringThe display name of the user or system associated with a history record.
parameters.historyMetadata.cause.displayNameKey?stringThe key of the display name of the user or system associated with a history record.
parameters.historyMetadata.cause.id?stringThe ID of the user or system associated with a history record.
parameters.historyMetadata.cause.type?stringThe type of the user or system associated with a history record.
parameters.historyMetadata.cause.url?stringThe URL of the user or system associated with a history record.
parameters.historyMetadata.description?stringThe description of the history record.
parameters.historyMetadata.descriptionKey?stringThe description key of the history record.
parameters.historyMetadata.emailDescription?stringThe description of the email address associated the history record.
parameters.historyMetadata.emailDescriptionKey?stringThe description key of the email address associated the history record.
parameters.historyMetadata.extraData?Record<string, any>Additional arbitrary information about the history record.
parameters.historyMetadata.generator?{ [key: string]: unknown; avatarUrl?: string; displayName?: string; displayNameKey?: string; id?: string; type?: string; url?: string; }-
parameters.historyMetadata.generator.avatarUrl?stringThe URL to an avatar for the user or system associated with a history record.
parameters.historyMetadata.generator.displayName?stringThe display name of the user or system associated with a history record.
parameters.historyMetadata.generator.displayNameKey?stringThe key of the display name of the user or system associated with a history record.
parameters.historyMetadata.generator.id?stringThe ID of the user or system associated with a history record.
parameters.historyMetadata.generator.type?stringThe type of the user or system associated with a history record.
parameters.historyMetadata.generator.url?stringThe URL of the user or system associated with a history record.
parameters.historyMetadata.type?stringThe type of the history record.
parameters.properties?object[]Details of issue properties to be add or update.
parameters.transition?{ [key: string]: unknown; expand?: string; fields?: Record<string, any>; hasScreen?: boolean; id?: string; isAvailable?: boolean; isConditional?: boolean; isGlobal?: boolean; isInitial?: boolean; looped?: boolean; name?: string; to?: { [key: string]: unknown; description?: string; iconUrl?: string; id?: string; name?: string; scope?: { [key: string]: unknown; project?: { [key: string]: unknown; avatarUrls?: { [key: ...]: ...; 16x16?: ...; 24x24?: ...; 32x32?: ...; 48x48?: ...; }; id?: string; key?: string; name?: string; projectCategory?: { [key: ...]: ...; description?: ...; id?: ...; name?: ...; self?: ...; }; projectTypeKey?: | ... & ... | "software" | "service_desk" | "business" | "product_discovery" | "customer_service"; self?: string; simplified?: boolean; }; type?: string & object | "PROJECT" | "TEMPLATE"; }; self?: string; statusCategory?: { [key: string]: unknown; colorName?: string; id?: number; key?: string; name?: string; self?: string; }; untranslatedName?: string; }; }-
parameters.transition.expand?stringExpand options that include additional transition details in the response.
parameters.transition.fields?Record<string, any>Details of the fields associated with the issue transition screen. Use this information to populate fields and update in a transition request.
parameters.transition.hasScreen?booleanWhether there is a screen associated with the issue transition.
parameters.transition.id?stringThe ID of the issue transition. Required when specifying a transition to undertake.
parameters.transition.isAvailable?booleanWhether the transition is available to be performed.
parameters.transition.isConditional?booleanWhether the issue has to meet criteria before the issue transition is applied.
parameters.transition.isGlobal?booleanWhether the issue transition is global, that is, the transition is applied to issues regardless of their status.
parameters.transition.isInitial?booleanWhether this is the initial issue transition for the workflow.
parameters.transition.looped?boolean-
parameters.transition.name?stringThe name of the issue transition.
parameters.transition.to?{ [key: string]: unknown; description?: string; iconUrl?: string; id?: string; name?: string; scope?: { [key: string]: unknown; project?: { [key: string]: unknown; avatarUrls?: { [key: ...]: ...; 16x16?: ...; 24x24?: ...; 32x32?: ...; 48x48?: ...; }; id?: string; key?: string; name?: string; projectCategory?: { [key: ...]: ...; description?: ...; id?: ...; name?: ...; self?: ...; }; projectTypeKey?: | ... & ... | "software" | "service_desk" | "business" | "product_discovery" | "customer_service"; self?: string; simplified?: boolean; }; type?: string & object | "PROJECT" | "TEMPLATE"; }; self?: string; statusCategory?: { [key: string]: unknown; colorName?: string; id?: number; key?: string; name?: string; self?: string; }; untranslatedName?: string; }-
parameters.transition.to.description?stringThe description of the status.
parameters.transition.to.iconUrl?stringThe URL of the icon used to represent the status.
parameters.transition.to.id?stringThe ID of the status.
parameters.transition.to.name?stringThe name of the status.
parameters.transition.to.scope?{ [key: string]: unknown; project?: { [key: string]: unknown; avatarUrls?: { [key: ...]: ...; 16x16?: ...; 24x24?: ...; 32x32?: ...; 48x48?: ...; }; id?: string; key?: string; name?: string; projectCategory?: { [key: ...]: ...; description?: ...; id?: ...; name?: ...; self?: ...; }; projectTypeKey?: | ... & ... | "software" | "service_desk" | "business" | "product_discovery" | "customer_service"; self?: string; simplified?: boolean; }; type?: string & object | "PROJECT" | "TEMPLATE"; }-
parameters.transition.to.scope.project?{ [key: string]: unknown; avatarUrls?: { [key: ...]: ...; 16x16?: ...; 24x24?: ...; 32x32?: ...; 48x48?: ...; }; id?: string; key?: string; name?: string; projectCategory?: { [key: ...]: ...; description?: ...; id?: ...; name?: ...; self?: ...; }; projectTypeKey?: | ... & ... | "software" | "service_desk" | "business" | "product_discovery" | "customer_service"; self?: string; simplified?: boolean; }-
parameters.transition.to.scope.project.avatarUrls?{ [key: ...]: ...; 16x16?: ...; 24x24?: ...; 32x32?: ...; 48x48?: ...; }-
parameters.transition.to.scope.project.avatarUrls.16x16?...The URL of the item's 16x16 pixel avatar.
parameters.transition.to.scope.project.avatarUrls.24x24?...The URL of the item's 24x24 pixel avatar.
parameters.transition.to.scope.project.avatarUrls.32x32?...The URL of the item's 32x32 pixel avatar.
parameters.transition.to.scope.project.avatarUrls.48x48?...The URL of the item's 48x48 pixel avatar.
parameters.transition.to.scope.project.id?stringThe ID of the project.
parameters.transition.to.scope.project.key?stringThe key of the project.
parameters.transition.to.scope.project.name?stringThe name of the project.
parameters.transition.to.scope.project.projectCategory?{ [key: ...]: ...; description?: ...; id?: ...; name?: ...; self?: ...; }-
parameters.transition.to.scope.project.projectCategory.description?...The name of the project category.
parameters.transition.to.scope.project.projectCategory.id?...The ID of the project category.
parameters.transition.to.scope.project.projectCategory.name?...The description of the project category.
parameters.transition.to.scope.project.projectCategory.self?...The URL of the project category.
parameters.transition.to.scope.project.projectTypeKey?| ... & ... | "software" | "service_desk" | "business" | "product_discovery" | "customer_service"The project type of the project.
parameters.transition.to.scope.project.self?stringThe URL of the project details.
parameters.transition.to.scope.project.simplified?booleanWhether or not the project is simplified.
parameters.transition.to.scope.type?string & object | "PROJECT" | "TEMPLATE"The type of scope.
parameters.transition.to.self?stringThe URL of the status.
parameters.transition.to.statusCategory?{ [key: string]: unknown; colorName?: string; id?: number; key?: string; name?: string; self?: string; }-
parameters.transition.to.statusCategory.colorName?stringThe name of the color used to represent the status category.
parameters.transition.to.statusCategory.id?numberThe ID of the status category.
parameters.transition.to.statusCategory.key?stringThe key of the status category.
parameters.transition.to.statusCategory.name?stringThe name of the status category.
parameters.transition.to.statusCategory.self?stringThe URL of the status category.
parameters.transition.to.untranslatedName?string-
parameters.update?Record<string, any>A Map containing the field field name and a list of operations to perform on the issue screen field. Note that fields included in here cannot be included in fields.
parameters.updateHistory?booleanWhether the project in which the issue is created is added to the user's Recently viewed project list, as shown under Projects in Jira. When provided, the issue type and request type are added to the user's history for a project. These values are then used to provide defaults on the issue create screen.

Returns

Promise<{ [key: string]: unknown; id: string; key: string; self: string; transition?: { [key: string]: unknown; errorCollection?: { [key: string]: unknown; errorMessages?: string[]; errors?: Record<string, any>; status?: number; }; status?: number; warningCollection?: { [key: string]: unknown; warnings?: string[]; }; }; watchers?: { [key: string]: unknown; errorCollection?: { [key: string]: unknown; errorMessages?: string[]; errors?: Record<string, any>; status?: number; }; status?: number; warningCollection?: { [key: string]: unknown; warnings?: string[]; }; }; }>