Skip to content

Create



POST /api/v1/service_manage/add

Overview

Create a Service List configuration.

Before Calling and Usage Steps

The API Key must have the service management permission (trace.serviceManage). First fill in the complete TOML configuration, including [Team] and [Related]. The service name can be obtained from existing tracing data, or you can pre-create the Service List entry. After success, save content.uuid and call Service List Details to check the service type, color, and associations. If the name already exists, check the existing configuration first, then decide whether to use the modify API instead.

Request Headers

Parameter 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 the API Key management of the target Workspace.

Body Request Parameters

Parameter Type Required Description
serviceCatelog string Y Service List TOML configuration text. See the request example for a complete JSON-escaped example. Maximum weighted length 65535; ASCII characters and half-width katakana count as 1, other characters as 2.
$maxCustomLength: 65535
Allowed null: False
Example: "[Team]\nservice = \"checkout\"\ntype = \"web\"\nteam = \"team-commerce\"\ncolour = \"#40C9C9\"\n\n[[Team.oncall]]\nname = \"值班邮箱\"\ntype = \"email\"\nemails = [\"xxx@guance.com\"]\n\n[[Repos]]\nname = \"业务仓库\"\nlink = \"https://example.invalid/repos/checkout\"\nprovider = \"Git\"\n\n[[Docs]]\nname = \"操作手册\"\nlink = \"https://example.invalid/help/checkout\"\nprovider = \"Wiki\"\n\n[Related]\nAppId = \"\"\nTags = [\"team:commerce\"]\nDashboardUUIDs = []\n"
How to obtain or fill in: Pass originStr=1 to Service List Details to get the original text, or construct the complete TOML according to the field table below and send it as a JSON string.

Additional Parameter Notes

serviceCatelog is a JSON string containing TOML text. All paths below refer to the parsed TOML content. When modifying, submit the complete configuration; omitting the original Repos, Docs, or Related associations causes the corresponding configuration or tags to be replaced or removed.

TOML Field Type How to Fill In and Value Source
Team TOML table Must be provided when calling; contains the basic service information.
Team.service string Required by the business and must be non-empty. Copy the service field from tracing records in Application Performance Monitoring, or enter the service name for which you want to pre-create a Service List entry. It is recommended to keep it within the database field length of 256 characters.
Team.type string Can be omitted. Takes app, framework, cache, message_queue, custom, db, web, or aws_lambda. On creation, other values trigger inference from existing tracing data, falling back to custom when there is no match; on modification, other values are converted directly to custom.
Team.colour string Can be omitted. Valid colors are #C43243, #DE5565, #D77D3D, #FDA82D, #FFD33B, #8934A4, #C75BC9, #F19AF2, #993C7E, #6454CB, #AC8AF0, #6C7AEB, #196AAB, #2EB2EE, #40C9C9, #1A9A82, #417C51, #49B566, #A7D650, #3F94DC. An empty value or another color results in a color generated from the service name within the allowed range.
Team.team string Team name; you can copy the name from the Team List. A non-existent name creates a team; it is recommended to explicitly enter an existing team name.
Team.oncall array<table> Array of contact methods; can be omitted as an empty array. TOML can use multiple [[Team.oncall]] tables.
Team.oncall[].name string Display name of the contact method, for example, the on-call email.
Team.oncall[].type string Fill in email, mobile, or slack for each item.
Team.oncall[].emails array<string> When type=email, fill in an array of email addresses, for example ["xxx@guance.com"].
Team.oncall[].mobiles array<string> When type=mobile, fill in an array of phone number strings.
Team.oncall[].slack string When type=slack, fill in the Slack channel address or an existing configured value.
Repos array<table> Array of code repositories; can be omitted as empty. Each item consists of name, link, and provider.
Repos[].name string Display name of the repository.
Repos[].link string Fill in the actual repository URL.
Repos[].provider string Display name of the repository provider.
Docs array<table> Array of related operational documents; can be omitted as empty. Each item consists of name, link, and provider.
Docs[].name string Display name of the document.
Docs[].link string Fill in the URL of the operational guide accessible to customers.
Docs[].provider string Display name of the content provider.
Related TOML table Must be provided when calling. Keep the empty [Related] table even when there are no associations.
Related.AppId string Real User Monitoring (RUM) application ID; keep the case as AppId. Obtain it from the configuration of the RUM application or the recorded app_id; it can be omitted or left empty.
Related.DashboardUUIDs array<string> Obtain content.data[].uuid from the Built-in Views List; use only active built-in views in this Workspace. Fill in [] when there is no binding.
Related.Tags array<string> Array of scene tag names. You can copy Related.Tags returned by the details API; an empty array clears tag associations. Each name is at most 128 characters.

Complete configuration example

[Team]
service = "checkout"
type = "web"
team = "team-commerce"
colour = "#40C9C9"

[[Team.oncall]]
name = "值班邮箱"
type = "email"
emails = ["xxx@guance.com"]

[[Repos]]
name = "业务仓库"
link = "https://example.invalid/repos/checkout"
provider = "Git"

[[Docs]]
name = "操作手册"
link = "https://example.invalid/help/checkout"
provider = "Wiki"

[Related]
AppId = ""
Tags = ["team:commerce"]
DashboardUUIDs = []

Team validation may create and commit the team first; if validation subsequently fails, that team may remain. After a request times out or fails, query the current service and team first, confirm the status, and then decide whether to retry.

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/service_manage/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"serviceCatelog":"[Team]\nservice = \"checkout\"\ntype = \"web\"\nteam = \"team-commerce\"\ncolour = \"#40C9C9\"\n\n[[Team.oncall]]\nname = \"值班邮箱\"\ntype = \"email\"\nemails = [\"xxx@guance.com\"]\n\n[[Repos]]\nname = \"业务仓库\"\nlink = \"https://example.invalid/repos/checkout\"\nprovider = \"Git\"\n\n[[Docs]]\nname = \"操作手册\"\nlink = \"https://example.invalid/help/checkout\"\nprovider = \"Wiki\"\n\n[Related]\nAppId = \"\"\nTags = [\"team:commerce\"]\nDashboardUUIDs = []\n"}'

Response

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

Field Type Description
content.uuid string Service List UUID.
content.service string Saved service name.
content.type string Saved service category.
content.declaration object or null Workspace common declaration.
{
  "code": 200,
  "content": {
    "uuid": "sman_example",
    "service": "checkout",
    "type": "web",
    "declaration": {}
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

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

HTTP Status errorCode Trigger Condition Message or Response Description Resolution
406 ft.ParameterValidationFailed A request field is missing, or a field value violates the declared validation condition 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 error Organize the request body as a JSON object.
400 ft.SetFormatError serviceCatelog cannot be parsed as TOML Service List toml format parsing failed Fix the TOML syntax and ensure that newlines and double quotes inside the JSON are correctly escaped.
400 ft.MissingCustomParameters Team exists but the service field is missing Service field missing Provide the service string in [Team].
400 ft.ErrorFieldType The service type, color, team name, array, or contact type in the TOML does not meet the requirements {} field type error Fix the incorrect field according to the TOML field table; use email, mobile, or slack for the contact type.
406 ft.MissParamService Team.service is an empty string Missing required parameter, service name Fill in the actual service name.
400 ft.ServiceNameRepeat An active Service List entry with a matching name already exists in the same Workspace Service name already exists Query the list first; when creating a duplicate, use that UUID to modify instead, and when modifying to a duplicate name, use another name.
400 ft.InvalidInnerDashboardUUID Related.DashboardUUIDs contains a UUID that does not exist in the Workspace, has been deleted, or is not a built-in view Invalid dashboard UUID: {} Select a valid UUID from the Built-in Views List again, or pass an empty array when not associating any.
400 ft.TagScopeMismatch An existing tag with the same name in Related.Tags is incompatible with the scene scope For example, team:commerce: ['monitor'] -> scene Select a tag in the scene or general scope, or use another name.
406 ft.ExceedMaxCharacterLimit A tag name in Related.Tags exceeds 128 characters {} exceeds the maximum character length limit Shorten the tag name.
500 ft.InternalServerError Valid TOML lacks the Team or Related table, or an unhandled structural exception occurs during saving Internal error Submit a complete configuration containing [Team] and [Related]; after a failure, check the current state of the team and service, then decide whether to retry.

Feedback

Is this page helpful?