jira-spaces

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Jira Spaces Skill

Jira Spaces 技能

Manage Confluence spaces through the Confluence Cloud REST API. Spaces are the top-level containers for organizing project documentation, wikis, and knowledge bases.
通过Confluence Cloud REST API管理Confluence空间。空间是组织项目文档、维基和知识库的顶级容器。

When to Use

适用场景

  • Setting up documentation structure for a new project
  • Creating spaces for different teams or initiatives
  • Listing available spaces to find documentation
  • Archiving or deleting obsolete spaces
  • 为新项目搭建文档结构
  • 为不同团队或项目创建空间
  • 列出可用空间以查找文档
  • 归档或删除已废弃的空间

Prerequisites

前置条件

  • Confluence Cloud instance (same Atlassian account as Jira)
  • API token with Confluence access
  • Environment variables configured in
    .env
  • Confluence Cloud实例(与Jira使用同一Atlassian账号)
  • 拥有Confluence访问权限的API token
  • .env
    中配置好环境变量

API Reference

API参考

Base URL

基础URL

Confluence Cloud uses the same base URL as Jira Cloud but different API path:
https://your-domain.atlassian.net/wiki/rest/api
Confluence Cloud使用与Jira Cloud相同的基础URL,但API路径不同:
https://your-domain.atlassian.net/wiki/rest/api

Authentication

认证方式

Same as Jira - Basic Auth with email:token.
与Jira相同 - 使用邮箱:token的Basic Auth认证。

Key Endpoints

核心端点

EndpointMethodDescription
/space
GETList all spaces
/space
POSTCreate a new space
/space/{spaceKey}
GETGet space details
/space/{spaceKey}
DELETEDelete a space
/space/{spaceKey}/content
GETList space content
端点方法描述
/space
GET列出所有空间
/space
POST创建新空间
/space/{spaceKey}
GET获取空间详情
/space/{spaceKey}
DELETE删除空间
/space/{spaceKey}/content
GET列出空间内容

Space Types

空间类型

TypeDescriptionUse Case
global
Site-wide spaceCompany wikis, shared docs
personal
User's personal spaceIndividual notes, drafts
类型描述适用场景
global
站点级空间公司维基、共享文档
personal
用户个人空间个人笔记、草稿

Creating a Space

创建空间

Request

请求示例

typescript
const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space`, {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    key: 'PROJ',           // Unique space key (uppercase)
    name: 'Project Docs',   // Display name
    type: 'global',         // 'global' or 'personal'
    description: {
      plain: {
        value: 'Documentation for the project',
        representation: 'plain'
      }
    }
  })
});
typescript
const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space`, {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    key: 'PROJ',           // 唯一空间标识(大写)
    name: 'Project Docs',   // 显示名称
    type: 'global',         // 'global' 或 'personal'
    description: {
      plain: {
        value: 'Documentation for the project',
        representation: 'plain'
      }
    }
  })
});

Response

响应示例

json
{
  "id": 12345,
  "key": "PROJ",
  "name": "Project Docs",
  "type": "global",
  "status": "current",
  "_links": {
    "webui": "/spaces/PROJ",
    "self": "https://your-domain.atlassian.net/wiki/rest/api/space/PROJ"
  }
}
json
{
  "id": 12345,
  "key": "PROJ",
  "name": "Project Docs",
  "type": "global",
  "status": "current",
  "_links": {
    "webui": "/spaces/PROJ",
    "self": "https://your-domain.atlassian.net/wiki/rest/api/space/PROJ"
  }
}

Listing Spaces

列出空间

Request

请求示例

typescript
const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space?limit=25&type=global`, {
  headers: {
    'Authorization': `Basic ${auth}`,
    'Accept': 'application/json'
  }
});
typescript
const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space?limit=25&type=global`, {
  headers: {
    'Authorization': `Basic ${auth}`,
    'Accept': 'application/json'
  }
});

Response

响应示例

json
{
  "results": [
    {
      "id": 12345,
      "key": "PROJ",
      "name": "Project Docs",
      "type": "global",
      "status": "current"
    }
  ],
  "start": 0,
  "limit": 25,
  "size": 1,
  "_links": {}
}
json
{
  "results": [
    {
      "id": 12345,
      "key": "PROJ",
      "name": "Project Docs",
      "type": "global",
      "status": "current"
    }
  ],
  "start": 0,
  "limit": 25,
  "size": 1,
  "_links": {}
}

Deleting a Space

删除空间

WARNING: Deleting a space removes all pages and content permanently!
警告:删除空间会永久移除所有页面和内容!

Request

请求示例

typescript
const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space/PROJ`, {
  method: 'DELETE',
  headers: {
    'Authorization': `Basic ${auth}`
  }
});
Returns 202 Accepted (deletion is async) or 204 No Content.
typescript
const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space/PROJ`, {
  method: 'DELETE',
  headers: {
    'Authorization': `Basic ${auth}`
  }
});
返回202 Accepted(删除为异步操作)或204 No Content。

Space Keys

空间标识规则

Space keys must:
  • Be unique across the Confluence instance
  • Use only uppercase letters and numbers
  • Be 1-255 characters
  • Not start with a number
Conventions:
  • PROJ
    - Project-specific
  • TEAM
    - Team-specific
  • DOC
    - Documentation
  • KB
    - Knowledge base
空间标识必须:
  • 在Confluence实例中唯一
  • 仅使用大写字母和数字
  • 长度为1-255个字符
  • 不能以数字开头
命名惯例:
  • PROJ
    - 项目专属
  • TEAM
    - 团队专属
  • DOC
    - 文档类
  • KB
    - 知识库

Common Patterns

常见使用模式

Create Project Documentation Space

创建项目文档空间

typescript
// Create space with home page
await createSpace({
  key: 'TUSTLE',
  name: 'Tustle Project Documentation',
  description: 'Technical documentation and guides for Tustle MVP'
});

// Add standard pages
await createPage('TUSTLE', 'Getting Started', 'Overview and setup instructions...');
await createPage('TUSTLE', 'Architecture', 'System architecture documentation...');
await createPage('TUSTLE', 'API Reference', 'API endpoint documentation...');
typescript
// 创建带首页的空间
await createSpace({
  key: 'TUSTLE',
  name: 'Tustle Project Documentation',
  description: 'Technical documentation and guides for Tustle MVP'
});

// 添加标准页面
await createPage('TUSTLE', 'Getting Started', 'Overview and setup instructions...');
await createPage('TUSTLE', 'Architecture', 'System architecture documentation...');
await createPage('TUSTLE', 'API Reference', 'API endpoint documentation...');

List Team Spaces

列出团队空间

typescript
const spaces = await listSpaces({ type: 'global', limit: 50 });
const teamSpaces = spaces.filter(s => s.name.includes('Team'));
typescript
const spaces = await listSpaces({ type: 'global', limit: 50 });
const teamSpaces = spaces.filter(s => s.name.includes('Team'));

Error Handling

错误处理

StatusMeaningResolution
400Invalid space keyCheck key format (uppercase, no special chars)
401UnauthorizedCheck API token and email
403ForbiddenUser lacks space admin permissions
404Space not foundVerify space key exists
409ConflictSpace key already exists
状态码含义解决方法
400无效的空间标识检查标识格式(大写,无特殊字符)
401未授权检查API token和邮箱
403禁止访问用户缺少空间管理员权限
404空间不存在验证空间标识是否存在
409冲突空间标识已存在

Scripts

脚本

ScriptDescription
create-space
Create a new Confluence space
delete-space
Delete a space (with confirmation)
list-spaces
List all accessible spaces
脚本描述
create-space
创建新的Confluence空间
delete-space
删除空间(需确认)
list-spaces
列出所有可访问的空间

Usage Examples

使用示例

bash
undefined
bash
undefined

List all spaces

列出所有空间

node run.js list-spaces
node run.js list-spaces

Create a new space

创建新空间

node run.js create-space DOCS "Documentation Space"
node run.js create-space DOCS "Documentation Space"

Delete a space (interactive confirmation)

删除空间(交互式确认)

node run.js delete-space DOCS
node run.js delete-space DOCS

Force delete without confirmation

强制删除无需确认

node run.js delete-space DOCS --confirm
undefined
node run.js delete-space DOCS --confirm
undefined

Related Skills

相关技能

  • jira-projects
    - Jira project management
  • jira-issues
    - Issue creation for documentation tasks
  • jira-projects
    - Jira项目管理
  • jira-issues
    - 为文档任务创建议题