Skip to content

Add Custom Level



POST /api/v1/incidents/level/add

Overview

Creates a custom Incident level for the current workspace.

Before Calling and Usage Steps

The Key must have incidents.incidentsLevelManage, and only applies to the workspace that the current Key belongs to. This module shares the underlying levels and default level configuration with the Issue level API; changes may affect both Incident and Issue level selection; it does not create an independent copy only within this module. When global levels are enabled in the backend, the actually effective level selection may be determined with priority by the global configuration, while the workspace management list still lists only default and workspace custom entries and does not include backend global levels. Administrators should confirm the effective scope before making changes, and should not treat every item in the management list as an available level.

A workspace can have at most 10 undeleted custom levels; duplicates are checked by name; the four default levels are not included. Creation returns an issl_ level UUID, which is referenced by parameters such as the Incident level. There is no idempotency key; after a timeout or 500, query by name first instead of creating the level again. Only the level configuration is created; existing Incidents are not modified and Incident notifications are not triggered.

Request Headers

Parameter Name Type Required Description
DF-API-KEY string Y OpenAPI authentication credential for the workspace.
Example: <DF-API-KEY>
How to obtain or fill in: Obtain an OpenAPI Key with this operation permission from API Key management in the target workspace.

Body Request Parameters

Parameter Name Type Required Description
name string Y Required on creation, may be omitted on modification; active custom levels in the same workspace cannot have duplicate names. The declaration allows up to 256 characters, the database allows 128; 1 to 128 characters is recommended; non-empty is not currently enforced.
Allowed null: False
Maximum length: 256
Example: P3-轻微
How to obtain or fill in: Define an easily recognizable name based on business severity.
description string Optional string; on creation, omitting it means an empty string, on modification, omitting it keeps the existing value, an empty string clears it, and null is not accepted; the database limit is 1024 characters, and callers should enforce limits.
Allowed null: False
Example: 局部功能受影响
How to obtain or fill in: The business owner fills in the criteria for determining the level.
extend json On creation, only an object or null is accepted, and omitting it defaults to {}; arrays, strings, and similar values are first rejected with 406 by declaration validation. Although declared on the modification route, objects or null that pass validation are still ignored by the controller, so the old extend is not changed and cannot be cleared with {}.
Allowed null: True
Example: {}
How to obtain or fill in: Fill in the JSON business extension to be saved on creation.
color string Y Required on creation, may be omitted on modification; declared only as a string with no color format validation, the database limit is 128 characters, and a valid hexadecimal color is recommended.
Allowed null: False
Example: #3F94DC
How to obtain or fill in: Fill in according to the customer UI color scheme; #RRGGBB is recommended.

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/incidents/level/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"P3-轻微","color":"#3F94DC","description":"局部功能受影响"}'

Response

HTTP 200, application/json. The example below shows the main fields that can be read directly.

Field Type Description
content.id integer or null Database row ID; use uuid for business identification; may be null in a snapshot taken before submission.
content.uuid string UUID of this resource.
content.status integer Database status, 0 for active / 3 for deleted; different from the Incident business status incidentsStatus.
content.creator string Creating principal; for an API Key this is generally wsak_ plus the resource UUID.
content.updator string Principal of the latest update; may be empty if never updated.
content.createAt integer Creation time in Unix seconds.
content.updateAt integer Last update time in Unix seconds.
content.deleteAt integer Deletion time in Unix seconds; -1 if not deleted.
content.workspaceUUID string Workspace that the level belongs to.
content.name string Name of the custom level.
content.color string Display value of the color, usually #RRGGBB; the server does not guarantee color format validation.
content.description string Description of the level.
content.extend JSON or null Extension saved on creation, omitted as {}, an explicit null can be saved; the modification entry currently ignores this field.
content.extend.自定义字段 JSON Dynamic business extension saved by the caller, not an additional control parameter.
content.isManage boolean false for levels created in this workspace; backend global levels are not modified by this module.
content.declaration object Public declaration of the current workspace.
{
  "code": 200,
  "content": {
    "id": 123,
    "uuid": "issl_example",
    "status": 0,
    "creator": "wsak_example",
    "updator": "",
    "createAt": 1785427200,
    "updateAt": -1,
    "deleteAt": -1,
    "workspaceUUID": "wksp_example",
    "name": "P3-轻微",
    "color": "#3F94DC",
    "description": "局部功能受影响",
    "extend": {},
    "isManage": false,
    "declaration": {}
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Response

For authentication, rate limiting, and common request errors, see Common Error Definitions.

HTTP Status errorCode Trigger Condition Message or Response Description Handling Method
406 ft.ParameterValidationFailed A request field is missing, or a field value violates the declared validation conditions Parameter parsing failed Check the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError The request JSON syntax is invalid Request JSON format error Fix the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The JSON top level is not an object Some json file format errors Submit an object.
406 ft.IssueLevelCountLimit The workspace already has 10 undeleted custom levels Space custom levels have exceeded the maximum number of 10 allowed for the space First confirm which levels need to be retained, plan the migration of references, and then delete unneeded items.
406 ft.IssueLevelNameExists An active custom level in the same workspace already uses this name Level name already exists Query existing levels first; if the configuration needs to change, modify the original uuid.
500 ft.InternalServerError Database, configuration/identity format, or an unhandled system exception Internal error For reads, retry with backoff; for writes, read back the configuration/level list first to verify whether it was saved, and then decide whether to retry.

Feedback

Is this page helpful?