---
title: "创建应用"
method: POST
path: "/apps"
tags: ["Application"]
---

# 创建应用

`POST /apps`

创建新的应用，应用编码(code)为可选参数，不提供则根据应用名称自动生成

## Request body

- ModelCreateApplicationRequest
  - `business_dept_id` integer, required — 业务部门ID
  - `business_group_id` integer, required — 业务组ID
  - `code` string — 应用编码(可选，不提供则根据名称自动生成)
  - `databases` integer[] — 关联数据库ID
  - `description` string — 应用介绍
  - `dev_owners` integer[] — 负责人信息
  - `domains` string[] — 关联资源
  - `health_api` string — 健康检查接口
  - `hosts` integer[] — 关联主机ID
  - `jenkins_envs` ModelCreateJenkinsEnvRequest[] — Jenkins环境配置(可选，如果不提供则创建默认的3套环境：prod, test, dev)
    - `app_id` integer — 应用ID(由控制器自动设置)
    - `env_name` string, required — 环境名称
    - `jenkins_server_id` integer — Jenkins服务器ID(关联account_auth表)
    - `job_name` string — Jenkins任务名称
  - `name` string, required — 应用名称
  - `ops_owners` integer[] — 运维负责人ID数组
  - `other_res` ModelOtherResources
    - `kafka` string[]
    - `other` string[]
    - `rabbitmq` string[]
    - `redis` string[]
    - `zookeeper` string[]
  - `programming_lang` string — 技术信息
  - `repo_url` string — 仓库地址
  - `start_command` string — 启动命令
  - `stop_command` string — 停止命令
  - `test_owners` integer[] — 测试负责人ID数组

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `business_dept_id` integer — 业务部门ID(关联sys_dept)
    - `business_group_id` integer — 基本信息
    - `code` string — 应用编码
    - `created_at` string
    - `databases` integer[] — 关联数据库(cmdb_sql表ID)
    - `description` string — 应用介绍
    - `dev_owners` integer[] — 负责人信息 (多个用户ID，关联sys_admin表)
    - `domains` string[] — 关联资源 (存储资源ID)
    - `health_api` string — 健康检查接口
    - `hosts` integer[] — 关联主机(cmdb_host表ID)
    - `id` integer
    - `jenkins_envs` ModelJenkinsEnv[] — 关联的Jenkins环境配置（级联删除）
      - `app_id` integer — 应用ID
      - `application` ModelApplication
        - `business_dept_id` integer — 业务部门ID(关联sys_dept)
        - `business_group_id` integer — 基本信息
        - `code` string — 应用编码
        - `created_at` string
        - `databases` integer[] — 关联数据库(cmdb_sql表ID)
        - `description` string — 应用介绍
        - `dev_owners` integer[] — 负责人信息 (多个用户ID，关联sys_admin表)
        - `domains` string[] — 关联资源 (存储资源ID)
        - `health_api` string — 健康检查接口
        - `hosts` integer[] — 关联主机(cmdb_host表ID)
        - `id` integer
        - `jenkins_envs` ModelJenkinsEnv[] — 关联的Jenkins环境配置（级联删除）
        - `name` string — 应用名称
        - `ops_owners` integer[] — 运维负责人
        - `other_res` ModelOtherResources
          - `kafka` string[]
          - `other` string[]
          - `rabbitmq` string[]
          - `redis` string[]
          - `zookeeper` string[]
        - `programming_lang` string — 技术信息
        - `repo_url` string — 仓库地址
        - `start_command` string — 启动命令
        - `status` integer — 状态
        - `stop_command` string — 停止命令
        - `test_owners` integer[] — 测试负责人
        - `updated_at` string
      - `created_at` string
      - `env_name` string — 环境名称
      - `id` integer
      - `jenkins_server_id` integer — Jenkins服务器ID(关联account_auth)
      - `job_name` string — Jenkins任务名称
      - `updated_at` string
    - `name` string — 应用名称
    - `ops_owners` integer[] — 运维负责人
    - `other_res` ModelOtherResources
      - `kafka` string[]
      - `other` string[]
      - `rabbitmq` string[]
      - `redis` string[]
      - `zookeeper` string[]
    - `programming_lang` string — 技术信息
    - `repo_url` string — 仓库地址
    - `start_command` string — 启动命令
    - `status` integer — 状态
    - `stop_command` string — 停止命令
    - `test_owners` integer[] — 测试负责人
    - `updated_at` string
  - `message` string — 提示信息

---

[API](https://skmtc.net/opsre/apis/devops.md) · [All operations](https://skmtc.net/opsre/apis/devops/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/opsre/devops/revisions/25cac8835c4c/schema)
