jira-spaces
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJira 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/apiConfluence Cloud使用与Jira Cloud相同的基础URL,但API路径不同:
https://your-domain.atlassian.net/wiki/rest/apiAuthentication
认证方式
Same as Jira - Basic Auth with email:token.
与Jira相同 - 使用邮箱:token的Basic Auth认证。
Key Endpoints
核心端点
| Endpoint | Method | Description |
|---|---|---|
| GET | List all spaces |
| POST | Create a new space |
| GET | Get space details |
| DELETE | Delete a space |
| GET | List space content |
| 端点 | 方法 | 描述 |
|---|---|---|
| GET | 列出所有空间 |
| POST | 创建新空间 |
| GET | 获取空间详情 |
| DELETE | 删除空间 |
| GET | 列出空间内容 |
Space Types
空间类型
| Type | Description | Use Case |
|---|---|---|
| Site-wide space | Company wikis, shared docs |
| User's personal space | Individual notes, drafts |
| 类型 | 描述 | 适用场景 |
|---|---|---|
| 站点级空间 | 公司维基、共享文档 |
| 用户个人空间 | 个人笔记、草稿 |
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:
- - Project-specific
PROJ - - Team-specific
TEAM - - Documentation
DOC - - Knowledge base
KB
空间标识必须:
- 在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
错误处理
| Status | Meaning | Resolution |
|---|---|---|
| 400 | Invalid space key | Check key format (uppercase, no special chars) |
| 401 | Unauthorized | Check API token and email |
| 403 | Forbidden | User lacks space admin permissions |
| 404 | Space not found | Verify space key exists |
| 409 | Conflict | Space key already exists |
| 状态码 | 含义 | 解决方法 |
|---|---|---|
| 400 | 无效的空间标识 | 检查标识格式(大写,无特殊字符) |
| 401 | 未授权 | 检查API token和邮箱 |
| 403 | 禁止访问 | 用户缺少空间管理员权限 |
| 404 | 空间不存在 | 验证空间标识是否存在 |
| 409 | 冲突 | 空间标识已存在 |
Scripts
脚本
| Script | Description |
|---|---|
| Create a new Confluence space |
| Delete a space (with confirmation) |
| List all accessible spaces |
| 脚本 | 描述 |
|---|---|
| 创建新的Confluence空间 |
| 删除空间(需确认) |
| 列出所有可访问的空间 |
Usage Examples
使用示例
bash
undefinedbash
undefinedList 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
undefinednode run.js delete-space DOCS --confirm
undefinedRelated Skills
相关技能
- - Jira project management
jira-projects - - Issue creation for documentation tasks
jira-issues
- - Jira项目管理
jira-projects - - 为文档任务创建议题
jira-issues