# How to Export Skills as ZIP Archives from TencentDB Agent Memory

> Easily export Skills as ZIP archives from TencentDB Agent Memory using the exportSkill method. This guide shows you how to retrieve skill metadata and resources efficiently.

- Repository: [Tencent Cloud/TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory)
- Tags: how-to-guide
- Published: 2026-08-28

---

**You can export Skills as ZIP archives from TencentDB Agent Memory by calling the `exportSkill` method on the `SkillClient` class, which sends a POST request to the `/v3/skill/export` endpoint and returns a base64-encoded ZIP payload containing the skill's metadata and resource files.**

The TencentDB-Agent-Memory repository provides a TypeScript SDK that wraps the skill export functionality, allowing developers to programmatically download complete skill bundles. This capability enables you to backup agent configurations, migrate skills between environments, or version-control your AI agent logic by exporting the [`SKILL.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/SKILL.md) file and associated resources as a compressed archive.

## How the Skill Export Endpoint Works

The underlying HTTP API exposes a single endpoint for skill exports:

- **Endpoint**: `POST /v3/skill/export`
- **Request Body**: JSON containing `skill_id` and optional `version` and `format` parameters
- **Response**: JSON containing `zip_base64` (base64-encoded ZIP file), `filename`, `name`, and `version` metadata

According to the source code in [`sdk/memory-core/typescript/src/v3/skill-types.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/skill-types.ts) (lines 35-53), the request and response structures are defined as `SkillExportRequest` and `SkillExportData` interfaces. The `format` parameter currently supports only `"zip"`, which is the default behavior when omitted.

## Exporting Skills Using the TypeScript SDK

The recommended approach uses the **`SkillClient`** class implemented in [`sdk/memory-core/typescript/src/v3/skill-client.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/skill-client.ts) (lines 44-53). This class handles authentication, request formatting, and base64 decoding automatically.

### Step-by-Step Implementation

1. **Initialize the client** with your endpoint, API key, and service identifiers
2. **Construct the export request** with the target `skill_id` and optional version
3. **Call `exportSkill`** to retrieve the base64-encoded data
4. **Decode and save** the binary ZIP buffer to your local filesystem

```typescript
import { SkillClient } from "./sdk/memory-core/typescript/src/v3/skill-client.js";
import * as fs from "node:fs/promises";

async function exportSkillToZip() {
  // ① Initialise the client with authentication and context
  const skills = new SkillClient({
    endpoint: "https://memory.tencentyun.com",
    apiKey: "sk-xxxxxxxxxxxxxxxxxxxx",
    serviceId: "mem-abc123",
    teamId: "team-01",
    agentId: "agent-coder",
    userId: "user-01",
  });

  // ② Prepare the export request
  const exportReq = {
    skill_id: "skl-0a1b2c3d",
    version: 3,              // optional – omit for head version
    format: "zip" as const,  // defaults to "zip" if omitted
  };

  // ③ Execute the export
  const exportData = await skills.exportSkill(exportReq);

  // ④ Decode base64 to binary buffer
  const zipBuffer = Buffer.from(exportData.zip_base64, "base64");

  // ⑤ Write to disk using the server-provided filename
  const outPath = `./${exportData.filename}`;
  await fs.writeFile(outPath, zipBuffer);
  console.log(`Skill exported to ${outPath}`);
}

exportSkillToZip().catch(console.error);

```

The **`exportSkill`** method merges your request parameters with the client defaults, constructs the HTTP POST to `/v3/skill/export`, and returns a `SkillExportData` object containing the encoded archive.

## Alternative: Direct HTTP Export with cURL

For environments where you cannot use the TypeScript SDK, you can call the REST API directly. The server returns JSON containing the base64-encoded ZIP, which you must decode manually.

```bash
ENDPOINT="https://memory.tencentyun.com"
API_KEY="sk-xxxxxxxxxxxxxxxxxxxx"
SERVICE_ID="mem-abc123"
SKILL_ID="skl-0a1b2c3d"

curl -X POST "$ENDPOINT/v3/skill/export" \
  -H "Authorization: Bearer $API_KEY" \
  -H "X-TDai-Service-Id: $SERVICE_ID" \
  -H "Content-Type: application/json" \
  -d '{
        "skill_id": "'"$SKILL_ID"'",
        "format": "zip"
      }' \
  -o export-response.json

# Extract and decode the ZIP file

ZIP_BASE64=$(jq -r .zip_base64 export-response.json)
echo "$ZIP_BASE64" | base64 -d > "${SKILL_ID}.zip"

```

This approach requires the **`jq`** utility to parse the JSON response and extract the `zip_base64` field before decoding it to binary.

## Understanding the Exported ZIP Contents

The resulting `.zip` archive contains the complete skill definition required to recreate or迁移 the skill:

- **[`SKILL.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/SKILL.md)**: The primary markdown file containing the skill's instructions, parameters, and logic
- **Resource files**: Any associated assets, templates, or configuration files attached to the skill
- **Metadata**: Version information and unique identifiers preserved in the archive structure

The base64 encoding ensures binary-safe transmission over JSON-based HTTP APIs, while the `filename` field in the response (e.g., `my-skill-v3.zip`) provides a human-readable name for the output file.

## Summary

- **Use `SkillClient.exportSkill()`** from [`sdk/memory-core/typescript/src/v3/skill-client.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/skill-client.ts) to programmatically export skills via the TypeScript SDK
- **Call `POST /v3/skill/export`** directly with authentication headers when SDK integration is not available
- **Pass the `skill_id`** and optional `version` parameter to target specific skill revisions
- **Decode `zip_base64`** using `Buffer.from(data, "base64")` in Node.js or `base64 -d` in shell environments
- **Reference `SkillExportRequest` and `SkillExportData`** in [`sdk/memory-core/typescript/src/v3/skill-types.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/skill-types.ts) for type definitions and schema validation

## Frequently Asked Questions

### What authentication is required to export skills?

You must provide a valid **API key** via the `Authorization: Bearer` header and a **service ID** via the `X-TDai-Service-Id` header. When using the TypeScript SDK, pass these credentials during `SkillClient` initialization along with optional team, agent, and user identifiers for audit logging.

### Can I export a specific version of a skill?

Yes. Include the optional **`version`** field (integer) in your `SkillExportRequest`. If omitted, the endpoint returns the head (latest) version of the skill. The version number is also returned in the `SkillExportData` response to confirm which revision you received.

### What files are included in the exported ZIP archive?

The ZIP contains the **[`SKILL.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/SKILL.md)** file (the core skill definition) plus any associated resource files such as templates, configuration JSON, or assets uploaded with the skill. The archive preserves the directory structure required to re-import the skill into another TencentDB Agent Memory instance.

### How do I handle the base64-encoded ZIP response?

The `zip_base64` field contains a base64 string representation of the binary ZIP file. In Node.js, convert it to a Buffer using `Buffer.from(zipBase64, "base64")` before writing to disk with `fs.writeFile()`. In shell environments, pipe the string through `base64 -d` to decode the binary content.