platform-sandbox-configure

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sandbox Lifecycle Management

沙箱生命周期管理

Manage Salesforce sandbox environments through Connect REST API — list inventory, activate or discard completed refreshes, create and refresh sandboxes, and permanently delete sandboxes.
通过Connect REST API管理Salesforce沙箱环境——列出沙箱清单、激活或放弃已完成的刷新、创建和刷新沙箱,以及永久删除沙箱。

When This Skill Owns the Task

此技能负责的任务场景

Use
platform-sandbox-configure
when the work involves:
  • Listing or retrieving all sandboxes (GET /sandbox/reports)
  • Getting details or status of a specific sandbox by name or by ID (07E prefix)
  • Activating a sandbox after a refresh completes (applying the refresh)
  • Discarding a completed refresh (keeping existing sandbox data unchanged)
  • Permanently deleting a sandbox to free up licenses
  • Verifying activation or deletion completed
  • Creating a new sandbox (Developer, Developer Pro, Partial Copy, or Full)
  • Refreshing an existing sandbox with latest production data
Delegate elsewhere when the user is:
  • Cloning a sandbox → Tooling API (
    SandboxInfo
    sObject)

当工作涉及以下内容时,使用
platform-sandbox-configure
  • 列出或检索所有沙箱(GET /sandbox/reports)
  • 通过名称或ID(以07E开头)获取特定沙箱的详细信息或状态
  • 在刷新完成后激活沙箱(应用刷新操作)
  • 放弃已完成的刷新(保持现有沙箱数据不变)
  • 永久删除沙箱以释放许可证
  • 验证激活或删除操作是否完成
  • 创建新沙箱(Developer、Developer Pro、Partial Copy或Full类型)
  • 使用最新生产数据刷新现有沙箱
当用户执行以下操作时,需将任务委托给其他工具:
  • 克隆沙箱 → 使用Tooling API(
    SandboxInfo
    sObject)

Help (Interactive Menu)

帮助(交互式菜单)

When the user types
sandbox -help
or
sandbox help
, respond with ONLY a text message showing the numbered operation list below. Do NOT call any API or tool — just display this menu and wait for the user to reply with a number.
The agent MUST respond with this exact markdown (not in a code block — render it directly as a bullet list):
Sandbox Lifecycle Management
1. Inventory & Details
  • a. List all sandboxes — Names, types, statuses, IDs
  • b. Get details (by name) — Status, license, config
  • c. Get details (by ID) — Provide a 07E ID directly
2. Create & Refresh
  • a. Create a new sandbox — Dev, Dev Pro, Partial, Full
  • b. Refresh a sandbox — Latest production data
3. Activate, Discard & Delete
  • a. Activate a sandbox — Apply a completed refresh
  • b. Discard a refresh — Reject, keep existing data
  • c. Delete a sandbox — Permanent removal
4. Verify & Monitor
  • a. Verify activation status — Check if activate completed
  • b. Verify deletion status — Check if delete completed
Reply with a code (e.g. "3a") or describe what you need.
After the user replies, ask for the required input:
SelectionFollow-up question
1aNo input needed — proceed immediately
1b"What's the sandbox name?"
1c"What's the sandbox ID? (starts with 07E)"
2a"What name for the new sandbox, and what license type? (Developer, Developer_Pro, Partial_Copy, Full)"
2b"Which sandbox do you want to refresh? Optionally, provide a new name and/or description."
3a"Which sandbox? Provide a name or 07E ID."
3b"Which sandbox? Provide a name or 07E ID."
3c"Which sandbox? Provide a name or 07E ID."
4a"Which sandbox did you activate? Provide a name or 07E ID."
4b"Which sandbox did you delete? Provide a name or 07E ID."
Execute the corresponding operation from the Operations section below.

当用户输入
sandbox -help
sandbox help
时,仅回复一条显示以下编号操作列表的文本消息。请勿调用任何API或工具——仅显示此菜单并等待用户回复编号。
Agent必须回复以下精确的markdown格式(不要放在代码块中——直接渲染为项目符号列表):
沙箱生命周期管理
1. 清单与详细信息
  • a. 列出所有沙箱——名称、类型、状态、ID
  • b. 通过名称获取详细信息——状态、许可证、配置
  • c. 通过ID获取详细信息——直接提供以07E开头的ID
2. 创建与刷新
  • a. 创建新沙箱——Dev、Dev Pro、Partial、Full类型
  • b. 刷新沙箱——获取最新生产数据
3. 激活、放弃与删除
  • a. 激活沙箱——应用已完成的刷新
  • b. 放弃刷新——拒绝刷新,保留现有数据
  • c. 删除沙箱——永久移除
4. 验证与监控
  • a. 验证激活状态——检查激活是否完成
  • b. 验证删除状态——检查删除是否完成
回复代码(例如“3a”)或描述你的需求。
用户回复后,询问所需输入:
选择项跟进问题
1a无需输入——立即执行
1b"沙箱名称是什么?"
1c"沙箱ID是什么?(以07E开头)"
2a"新沙箱的名称是什么,以及许可证类型是什么?(Developer、Developer_Pro、Partial_Copy、Full)"
2b"你想要刷新哪个沙箱?可选提供新名称和/或描述。"
3a"哪个沙箱?提供名称或07E开头的ID。"
3b"哪个沙箱?提供名称或07E开头的ID。"
3c"哪个沙箱?提供名称或07E开头的ID。"
4a"你激活了哪个沙箱?提供名称或07E开头的ID。"
4b"你删除了哪个沙箱?提供名称或07E开头的ID。"
执行下方操作部分对应的操作。

API Base

API基础

CRITICAL: For sandbox operations in this skill, use the Connect REST API. Two discovery paths exist:
  • By name: Call
    GET /sandbox/reports
    to list all sandboxes and find the matching one by
    sandboxName
    .
  • By ID (07E prefix): Call
    GET /sandbox/sandboxes/{sandboxId}
    directly — do NOT call
    /sandbox/reports
    .
Both paths return sandbox records with
sandboxId
(prefix
07E
) which is required for all lifecycle mutation operations.
bash
undefined
关键提示: 此技能中的沙箱操作,请使用Connect REST API。有两种查找路径:
  • 通过名称: 调用
    GET /sandbox/reports
    列出所有沙箱,通过
    sandboxName
    找到匹配项。
  • 通过ID(以07E开头): 直接调用
    GET /sandbox/sandboxes/{sandboxId}
    ——请勿调用
    /sandbox/reports
两种路径都会返回包含
sandboxId
(以07E开头)的沙箱记录,这是所有生命周期变更操作必需的参数。
bash
undefined

List all sandboxes (Connect REST API)

列出所有沙箱(Connect REST API)

sf api request rest "/services/data/v66.0/sandbox/reports" --method GET
sf api request rest "/services/data/v66.0/sandbox/reports" --method GET

Response format:

响应格式:

{

{

"count": 3,

"count": 3,

"sandboxes": [

"sandboxes": [

{

{

"sandbox": {

"sandbox": {

"sandboxId": "07E...", # Required for all operations

"sandboxId": "07E...", # 所有操作必需

"sandboxName": "mybox", # Top-level field — use this for name lookup

"sandboxName": "mybox", # 顶层字段——用于名称查找

"license": "Developer",

"license": "Developer",

"isPendingActivation": false,

"isPendingActivation": false,

"canActivate": true,

"canActivate": true,

"canDelete": true,

"canDelete": true,

...

...

}

}

}

}

]

]

}

}


**IMPORTANT:** Do NOT use Tooling API (`SandboxInfo` or `SandboxProcess`) for sandbox discovery. The mutation endpoints (activate/discard/delete) require the `sandboxId` (07E prefix) from the Connect REST API response, NOT the `SandboxInfo.Id` (0GQ prefix) or `SandboxProcess.Id` (0GR prefix).

**NEVER use SOQL / `run_soql_query` / `sf data query` for sandbox lifecycle reads — status, inventory, details, license, or pending-activation state (e.g. a "get details / status / license / pending-activation for sandbox X" request).** This data lives ONLY in the Connect REST API response (`GET /sandbox/reports` for name lookup, `GET /sandbox/sandboxes/{07E-id}` for ID lookup); there is no SObject that returns it correctly. (`sf data query --use-tooling-api` on `SandboxInfo` remains valid for the Create and Refresh flows in Operations 7 and 8, which look up the `SandboxInfo` record to mutate it — that is not a lifecycle read.) If a name lookup returns an empty inventory (`count: 0`), the sandbox does not exist — report an honest `not_found`; do NOT retry the lookup via SOQL and do NOT fabricate details.

**Report the API result exactly as it comes back — never invent an error or a cause.** A `count: 0` response is a *successful* result meaning the sandbox is absent: record it directly as `not_found` with the endpoint and empty inventory as evidence. Do NOT reinterpret an empty list as an API failure. If the Connect REST API genuinely returns an error, capture that error body verbatim as the outcome — but do NOT speculate about *why* (e.g. "this must be a scratch org", "sandbox endpoints aren't supported here"). This endpoint does not report the org's edition or type, so any such explanation is a fabrication and must not appear in the output.

**Discovery Patterns:**

**When user provides a sandbox NAME:**
1. Call `GET /sandbox/reports` to get the full list
2. Iterate through `sandboxes[]` array
3. Check `sandbox.sandboxName` (top-level field) to find the matching sandbox
4. Extract `sandbox.sandboxId` from that record
5. Use the `sandboxId` in subsequent mutation operations

**When user provides a sandboxId (07E prefix) directly:**
1. Call `GET /sandbox/sandboxes/{sandboxId}` to verify it exists and check current status
2. Use the same `sandboxId` directly in the mutation endpoint — do NOT call `/sandbox/reports`

Required permission: `ManageSandboxes`

---

**重要提示:** 请勿使用Tooling API(`SandboxInfo`或`SandboxProcess`)进行沙箱查找。变更端点(激活/放弃/删除)需要来自Connect REST API响应的`sandboxId`(以07E开头),而非`SandboxInfo.Id`(以0GQ开头)或`SandboxProcess.Id`(以0GR开头)。

**请勿使用SOQL / `run_soql_query` / `sf data query`进行沙箱生命周期读取操作——包括状态、清单、详细信息、许可证或待激活状态(例如“获取沙箱X的详细信息/状态/许可证/待激活状态”请求)。** 这些数据仅存在于Connect REST API响应中(通过名称查找用`GET /sandbox/reports`,通过ID查找用`GET /sandbox/sandboxes/{07E-id}`);没有能正确返回这些数据的SObject。(在操作7和8的创建与刷新流程中,使用`sf data query --use-tooling-api`查询`SandboxInfo`记录是有效的,因为这是用于变更记录的查找——不属于生命周期读取操作。)如果名称查找返回空清单(`count: 0`),则表示沙箱不存在——如实报告`not_found`;请勿通过SOQL重试查找,也不要编造详细信息。

**如实报告API结果——切勿虚构错误或原因。** `count: 0`的响应是成功结果,意味着沙箱不存在:直接记录为`not_found`,并附上端点和空清单作为证据。请勿将空列表解读为API失败。如果Connect REST API确实返回错误,请逐字捕获错误体作为结果——但不要推测原因(例如“这一定是临时环境”、“此处不支持沙箱端点”)。此端点不会报告组织的版本或类型,因此任何此类解释都是虚构的,不得出现在输出中。

**查找模式:**

**当用户提供沙箱名称时:**
1. 调用`GET /sandbox/reports`获取完整列表
2. 遍历`sandboxes[]`数组
3. 检查`sandbox.sandboxName`(顶层字段)以找到匹配的沙箱
4. 从该记录中提取`sandbox.sandboxId`
5. 在后续变更操作中使用该`sandboxId`

**当用户直接提供sandboxId(以07E开头)时:**
1. 调用`GET /sandbox/sandboxes/{sandboxId}`验证其存在并检查当前状态
2. 直接在变更端点中使用相同的`sandboxId`——请勿调用`/sandbox/reports`

所需权限:`ManageSandboxes`

---

Operations

操作

1. List Sandbox Inventory

1. 列出沙箱清单

Endpoint:
GET /services/data/v66.0/sandbox/reports
Returns a list of all sandboxes with their IDs, names, statuses, and license types.
bash
sf api request rest "/services/data/v66.0/sandbox/reports" --method GET
Response format:
json
{
  "count": 3,
  "sandboxes": [
    {
      "sandbox": {
        "sandboxId": "07E...",
        "sandboxName": "DevBox1",
        "license": "Developer",
        "isPendingActivation": false,
        "canActivate": true,
        "canDelete": true,
        "canDiscard": false
      }
    }
  ]
}
Use when: User asks "show me all sandboxes", "how many sandboxes do I have", "what's the status of my sandboxes"
Key response fields:
  • sandbox.sandboxId
    (07E prefix) — Required for all mutation operations
  • sandbox.sandboxName
    — The sandbox name (top-level field)
  • sandbox.license
    — Developer, Developer Pro, Partial Copy, Full
  • sandbox.isPendingActivation
    — true if refresh is pending activation
  • sandbox.canActivate
    /
    canDelete
    /
    canDiscard
    — Permission flags

端点:
GET /services/data/v66.0/sandbox/reports
返回所有沙箱的列表,包含它们的ID、名称、状态和许可证类型。
bash
sf api request rest "/services/data/v66.0/sandbox/reports" --method GET
响应格式:
json
{
  "count": 3,
  "sandboxes": [
    {
      "sandbox": {
        "sandboxId": "07E...",
        "sandboxName": "DevBox1",
        "license": "Developer",
        "isPendingActivation": false,
        "canActivate": true,
        "canDelete": true,
        "canDiscard": false
      }
    }
  ]
}
适用场景: 用户询问“显示所有沙箱”、“我有多少个沙箱”、“我的沙箱状态是什么”
关键响应字段:
  • sandbox.sandboxId
    (以07E开头)——所有变更操作必需
  • sandbox.sandboxName
    ——沙箱名称(顶层字段)
  • sandbox.license
    ——Developer、Developer Pro、Partial Copy、Full
  • sandbox.isPendingActivation
    ——如果刷新待激活则为true
  • sandbox.canActivate
    /
    canDelete
    /
    canDiscard
    ——权限标志

2. Get Sandbox Details

2. 获取沙箱详细信息

Endpoint:
GET /services/data/v66.0/sandbox/sandboxes/{sandboxId}
Returns detailed info for a specific sandbox.
Use when: User asks about a specific sandbox's status, configuration, or metadata.
Key response fields:
  • status
    — Active, Pending Activation, Activating, Completed, etc.
  • isPendingActivation
    — true if a refresh completed and awaits user decision
  • sandboxType
    — Developer, DeveloperPro, PartialCopy, Full
  • sourceId
    — ID of the source org

端点:
GET /services/data/v66.0/sandbox/sandboxes/{sandboxId}
返回特定沙箱的详细信息。
适用场景: 用户询问特定沙箱的状态、配置或元数据。
关键响应字段:
  • status
    ——Active、Pending Activation、Activating、Completed等
  • isPendingActivation
    ——如果刷新已完成并等待用户决策则为true
  • sandboxType
    ——Developer、DeveloperPro、PartialCopy、Full
  • sourceId
    ——源组织的ID

3. Activate Sandbox (Apply Refresh)

3. 激活沙箱(应用刷新)

Endpoint:
PATCH /services/data/v66.0/sandbox/activate/{sandboxId}
CRITICAL DOMAIN RULE: This operation ONLY applies to sandboxes with a completed refresh in "Pending Activation" state. It applies the refreshed data to the sandbox. It does NOT "bring an inactive sandbox online" or "start" a sandbox.
Pre-conditions:
  • Sandbox must be in
    Pending Activation
    status
  • A refresh must have completed successfully
  • User must have
    ManageSandboxes
    permission
Before calling PATCH /activate:
  • Confirmed sandbox is in
    Pending Activation
    status via GET
    /sandbox/sandboxes/{id}
    (
    isPendingActivation: true
    )
  • Confirmed a refresh has completed successfully
Use when: User says "activate it", "apply the refresh", "use the latest data"
After activation: The sandbox runs with the newly refreshed production data.

端点:
PATCH /services/data/v66.0/sandbox/activate/{sandboxId}
关键领域规则: 此操作仅适用于处于“Pending Activation”状态且已完成刷新的沙箱。它会将刷新后的数据应用到沙箱。它不会“启动非活跃沙箱”或“启动”沙箱。
前置条件:
  • 沙箱必须处于
    Pending Activation
    状态
  • 刷新必须已成功完成
  • 用户必须拥有
    ManageSandboxes
    权限
调用PATCH /activate之前:
  • 通过GET
    /sandbox/sandboxes/{id}
    确认沙箱处于
    Pending Activation
    状态(
    isPendingActivation: true
  • 确认刷新已成功完成
适用场景: 用户说“激活它”、“应用刷新”、“使用最新数据”
激活后: 沙箱将使用新刷新的生产数据运行。

4. Verify Activation

4. 验证激活状态

Endpoint:
GET /services/data/v66.0/sandbox/sandboxes/{sandboxId}
Poll this endpoint after activation to confirm status changed to
Active
. This is a verification step, not a standalone user action.
Use when: Agent needs to confirm activation completed (called automatically after activate).

端点:
GET /services/data/v66.0/sandbox/sandboxes/{sandboxId}
激活后轮询此端点,确认状态已变为
Active
。这是一个验证步骤,不是独立的用户操作。
适用场景: Agent需要确认激活已完成(激活后自动调用)。

5. Discard Sandbox (Reject Refresh)

5. 放弃沙箱(拒绝刷新)

Endpoint:
DELETE /services/data/v66.0/sandbox/discardsandbox/{sandboxId}
CRITICAL DOMAIN RULE: This operation ONLY applies to sandboxes with a completed refresh in "Pending Activation" state. It rejects the refresh — the existing sandbox continues running with its current data unchanged. It does NOT:
  • Free up licenses
  • Soft-delete or hide the sandbox
  • Reset the sandbox to match production
Pre-conditions:
  • Sandbox must be in
    Pending Activation
    status
  • A refresh must have completed
Before calling DELETE /discardsandbox:
  • Confirmed sandbox is in
    Pending Activation
    status via GET
    /sandbox/sandboxes/{id}
    (
    isPendingActivation: true
    )
  • Confirmed this is a discard (reject refresh), NOT a delete (permanent removal)
Use when: User says "discard the refresh", "keep existing data", "don't apply the refresh", "reject the refresh"
WARNING: Discard is not reversible. The user will need to trigger a new refresh if they want fresh production data later.

端点:
DELETE /services/data/v66.0/sandbox/discardsandbox/{sandboxId}
关键领域规则: 此操作仅适用于处于“Pending Activation”状态且已完成刷新的沙箱。它会拒绝刷新——现有沙箱将继续使用当前数据运行,不会改变。它不会:
  • 释放许可证
  • 软删除或隐藏沙箱
  • 将沙箱重置为与生产环境匹配
前置条件:
  • 沙箱必须处于
    Pending Activation
    状态
  • 刷新必须已完成
调用DELETE /discardsandbox之前:
  • 通过GET
    /sandbox/sandboxes/{id}
    确认沙箱处于
    Pending Activation
    状态(
    isPendingActivation: true
  • 确认这是放弃操作(拒绝刷新),而非删除操作(永久移除)
适用场景: 用户说“放弃刷新”、“保留现有数据”、“不要应用刷新”、“拒绝刷新”
警告: 放弃操作不可逆转。如果用户之后想要获取新的生产数据,需要触发新的刷新。

6. Delete Sandbox (Permanent)

6. 删除沙箱(永久)

Endpoint:
DELETE /services/data/v66.0/sandbox/deletesandbox/{sandboxId}
Permanently removes a sandbox and frees the license.
Pre-conditions:
  • Sandbox must exist
  • User must have
    ManageSandboxes
    permission
Before calling DELETE /deletesandbox:
  • Surfaced sandbox details (name, license, status) with user and received explicit delete approval
Use when: User says "delete this sandbox", "remove it permanently", "free up the license"
WARNING: This is irreversible. Always confirm with the user before executing. Surface the sandbox name, license, and status as a safety check.

端点:
DELETE /services/data/v66.0/sandbox/deletesandbox/{sandboxId}
永久移除沙箱并释放许可证。
前置条件:
  • 沙箱必须存在
  • 用户必须拥有
    ManageSandboxes
    权限
调用DELETE /deletesandbox之前:
  • 向用户展示沙箱详细信息(名称、许可证、状态)并获得明确的删除批准
适用场景: 用户说“删除这个沙箱”、“永久移除它”、“释放许可证”
警告: 此操作不可逆转。执行前务必与用户确认。展示沙箱名称、许可证和状态作为安全检查。

7. Create a New Sandbox

7. 创建新沙箱

Creates a new sandbox from scratch. Two approaches are supported — pick based on the user's preference; default to Approach A unless the user asks for a definition file or a repeatable DX blueprint.
从头创建新沙箱。支持两种方法——根据用户偏好选择;除非用户要求使用定义文件或可重复的DX蓝图,否则默认使用方法A。

Approach A — Tooling API record (direct)

方法A —— Tooling API记录(直接方式)

API: Tooling API —
SandboxInfo
sObject
Required inputs:
  • SandboxName
    — Name for the new sandbox (alphanumeric, max 10 chars)
  • LicenseType
    — One of:
    Developer
    ,
    Developer_Pro
    ,
    Partial_Copy
    ,
    Full
Optional inputs:
  • Description
    — Description of the sandbox purpose
  • Features
    true
    to upgrade sandbox data storage to 400 MB (WARNING: once enabled, cannot be decreased)
  • ApexClassId
    — ID of an Apex class that implements
    SandboxPostCopy
    interface (runs after creation completes)
  • ActivationUserGroupId
    — ID of a Group that determines which users can access the sandbox
bash
undefined
API: Tooling API ——
SandboxInfo
sObject
必需输入:
  • SandboxName
    ——新沙箱的名称(字母数字,最多10个字符)
  • LicenseType
    ——以下类型之一:
    Developer
    Developer_Pro
    Partial_Copy
    Full
可选输入:
  • Description
    ——沙箱用途的描述
  • Features
    ——设为
    true
    可将沙箱数据存储升级至400 MB(警告:一旦启用,无法降低)
  • ApexClassId
    ——实现
    SandboxPostCopy
    接口的Apex类ID(创建完成后运行)
  • ActivationUserGroupId
    ——决定哪些用户可访问沙箱的Group ID
bash
undefined

Create a Developer sandbox

创建Developer沙箱

sf data create record --sobject SandboxInfo --use-tooling-api --values "SandboxName='mybox' LicenseType='Developer'"
undefined
sf data create record --sobject SandboxInfo --use-tooling-api --values "SandboxName='mybox' LicenseType='Developer'"
undefined

Approach B — Sandbox definition file (Salesforce CLI)

方法B —— 沙箱定义文件(Salesforce CLI)

The DX-native path: write a JSON definition file (a reusable blueprint), then create the sandbox from it with
sf org create sandbox
. Prefer this when the user wants a checked-in, repeatable config or name-based Apex/group references (no ID lookups).
json
// config/dev-sandbox-def.json
{
  "sandboxName": "mybox",
  "licenseType": "Developer"
}
bash
sf org create sandbox --definition-file config/dev-sandbox-def.json --alias mybox --target-org prod
Definition file fields:
FieldRequiredNotes
sandboxName
YesAlphanumeric, max 10 chars
licenseType
Yes
Developer
,
Developer_Pro
,
Partial
,
Full
note:
Partial
, not
Partial_Copy
in the definition file
description
NoPurpose of the sandbox (≤1000 chars)
apexClassName
/
apexClassId
NoApex class implementing
SandboxPostCopy
; the definition file adds the Name variant so no ID lookup is needed
activationUserGroupName
/
activationUserGroupId
NoPublic group controlling sandbox access; Name variant avoids an ID lookup
features
No
"['SandboxStorage']"
to upgrade data storage (Developer → 400 MB, Dev Pro → 2 GB); not for Partial/Full
templateId
Partial (required), Full (optional)Sandbox template (15-char ID beginning
1ps
) selecting which objects to copy
historyDays
/
copyChatter
/
copyArchivedActivities
NoFull sandboxes only
Pre-conditions:
  • Available license of the requested type must exist in the org
  • Sandbox name must be unique and not already in use
  • User must have
    ManageSandboxes
    permission
After creation: A
SandboxProcess
record is created with Status =
Processing
. The sandbox copy begins immediately.

DX原生方式:编写JSON定义文件(可重用蓝图),然后使用
sf org create sandbox
从该文件创建沙箱。当用户需要可签入、可重复的配置或基于名称的Apex/Group引用(无需ID查找)时,优先使用此方法。
json
// config/dev-sandbox-def.json
{
  "sandboxName": "mybox",
  "licenseType": "Developer"
}
bash
sf org create sandbox --definition-file config/dev-sandbox-def.json --alias mybox --target-org prod
定义文件字段:
字段是否必需说明
sandboxName
字母数字,最多10个字符
licenseType
Developer
Developer_Pro
Partial
Full
——注意:定义文件中使用
Partial
而非
Partial_Copy
description
沙箱用途(≤1000字符)
apexClassName
/
apexClassId
实现
SandboxPostCopy
的Apex类;定义文件支持名称变体,无需ID查找
activationUserGroupName
/
activationUserGroupId
控制沙箱访问的公开群组;名称变体避免ID查找
features
"['SandboxStorage']"
用于升级数据存储(Developer→400 MB,Dev Pro→2 GB);不适用于Partial/Full类型
templateId
Partial类型必需,Full类型可选沙箱模板(15字符ID,以1ps开头),选择要复制的对象
historyDays
/
copyChatter
/
copyArchivedActivities
仅适用于Full类型沙箱
前置条件:
  • 组织中必须有可用的请求类型许可证
  • 沙箱名称必须唯一且未被使用
  • 用户必须拥有
    ManageSandboxes
    权限
创建后: 将创建一个
SandboxProcess
记录,状态为
Processing
。沙箱复制将立即开始。

8. Refresh an Existing Sandbox

8. 刷新现有沙箱

Refreshes a sandbox with the latest production data. Two approaches are supported — pick based on the user's preference; default to Approach A unless the user asks for a definition file.
使用最新生产数据刷新沙箱。支持两种方法——根据用户偏好选择;除非用户要求使用定义文件,否则默认使用方法A。

Approach A — Tooling API record (direct)

方法A —— Tooling API记录(直接方式)

API: Tooling API —
SandboxInfo
sObject (PATCH)
Refreshes by updating the existing
SandboxInfo
record.
Required inputs:
  • Sandbox name — to look up the
    SandboxInfo
    record ID (0GQ prefix)
Optional inputs:
  • SandboxName
    — New name for the refreshed sandbox (if user wants to rename it; alphanumeric, max 10 chars)
  • Description
    — New or updated description for the sandbox
  • AutoActivate
    true
    to auto-activate when refresh completes (default: false)
  • Features
    true
    to upgrade sandbox data storage to 400 MB (WARNING: once enabled, cannot be decreased)
  • ApexClassId
    — ID of an Apex class that implements
    SandboxPostCopy
    interface (runs after refresh completes)
  • ActivationUserGroupId
    — ID of a Group that determines which users can access the sandbox
Ask the user: "Which sandbox do you want to refresh? Optionally, provide a new name and/or description if you'd like to change them."
Steps:
bash
undefined
API: Tooling API ——
SandboxInfo
sObject(PATCH)
通过更新现有
SandboxInfo
记录来触发刷新。
必需输入:
  • 沙箱名称——用于查找
    SandboxInfo
    记录ID(以0GQ开头)
可选输入:
  • SandboxName
    ——刷新后沙箱的新名称(如果用户想要重命名;字母数字,最多10个字符)
  • Description
    ——沙箱的新描述或更新描述
  • AutoActivate
    ——设为
    true
    可在刷新完成后自动激活(默认:false)
  • Features
    ——设为
    true
    可将沙箱数据存储升级至400 MB(警告:一旦启用,无法降低)
  • ApexClassId
    ——实现
    SandboxPostCopy
    接口的Apex类ID(刷新完成后运行)
  • ActivationUserGroupId
    ——决定哪些用户可访问沙箱的Group ID
询问用户: "你想要刷新哪个沙箱?可选提供新名称和/或描述(如果需要修改)。"
步骤:
bash
undefined

1. Look up the SandboxInfo record Id by name

1. 通过名称查找SandboxInfo记录Id

sf data query --query "SELECT Id, SandboxName, LicenseType, Description FROM SandboxInfo WHERE SandboxName = '<name>'" --use-tooling-api --json
sf data query --query "SELECT Id, SandboxName, LicenseType, Description FROM SandboxInfo WHERE SandboxName = '<name>'" --use-tooling-api --json

2. Update the record to trigger refresh (PATCH the SandboxInfo record)

2. 更新记录以触发刷新(PATCH SandboxInfo记录)

Include SandboxName and Description only if the user provided new values

仅当用户提供新值时才包含SandboxName和Description

sf data update record --sobject SandboxInfo --use-tooling-api --record-id <0GQ-id> --values "AutoActivate=true SandboxName='<newName>' Description='<description>'"

**Note:** Only include `SandboxName` in `--values` if the user wants to rename. Only include `Description` if the user provides one. Always include `AutoActivate`.
sf data update record --sobject SandboxInfo --use-tooling-api --record-id <0GQ-id> --values "AutoActivate=true SandboxName='<newName>' Description='<description>'"

**注意:** 仅当用户想要重命名时才在`--values`中包含`SandboxName`。仅当用户提供描述时才包含`Description`。必须始终包含`AutoActivate`。

Approach B — Sandbox definition file (Salesforce CLI)

方法B —— 沙箱定义文件(Salesforce CLI)

Refresh from the same JSON definition-file blueprint used for create (see Operation 7 for the full field table), using
sf org refresh sandbox
. Use the existing sandbox's name; the definition file supplies any changed settings (e.g.,
autoActivate
,
apexClassName
).
json
// config/dev-sandbox-def.json
{
  "sandboxName": "mybox",
  "licenseType": "Developer",
  "autoActivate": true
}
bash
sf org refresh sandbox --name mybox --definition-file config/dev-sandbox-def.json --target-org prod
Pre-conditions:
  • Sandbox must exist and be in a refreshable state
  • Refresh interval must have elapsed (Developer = 1 day, Dev Pro = 1 day, Partial = 5 days, Full = 29 days)
  • User must have
    ManageSandboxes
    permission
After refresh: A new
SandboxProcess
record is created with Status =
Processing
. If
AutoActivate=true
, the sandbox activates automatically when done. Otherwise it enters
Pending Activation
state.

使用创建沙箱时所用的相同JSON定义文件蓝图(见操作7的完整字段表),通过
sf org refresh sandbox
进行刷新。使用现有沙箱的名称;定义文件提供任何更改的设置(例如
autoActivate
apexClassName
)。
json
// config/dev-sandbox-def.json
{
  "sandboxName": "mybox",
  "licenseType": "Developer",
  "autoActivate": true
}
bash
sf org refresh sandbox --name mybox --definition-file config/dev-sandbox-def.json --target-org prod
前置条件:
  • 沙箱必须存在且处于可刷新状态
  • 刷新间隔已过(Developer=1天,Dev Pro=1天,Partial=5天,Full=29天)
  • 用户必须拥有
    ManageSandboxes
    权限
刷新后: 将创建一个新的
SandboxProcess
记录,状态为
Processing
。如果
AutoActivate=true
,沙箱将在完成后自动激活。否则将进入
Pending Activation
状态。

Decision Guide for Agents

Agent决策指南

When user provides a sandbox NAME (lookup required)

当用户提供沙箱名称(需要查找)

User says...OperationKey check
"Show all my sandboxes"GET /sandbox/reports
"What's the status of X?"GET /sandbox/reports, filter by sandboxName
"Activate sandbox sbxtest"1. GET /sandbox/reports to find sandboxId by name<br>2. PATCH /sandbox/activate/{sandboxId}Must be isPendingActivation: true
"Discard the refresh on sbxtest"1. GET /sandbox/reports to find sandboxId by name<br>2. DELETE /sandbox/discardsandbox/{sandboxId}Must be isPendingActivation: true
"Delete sandbox sbxtest"1. GET /sandbox/reports to find sandboxId by name<br>2. DELETE /sandbox/deletesandbox/{sandboxId}Confirm with user first
用户说...操作关键检查
"显示我的所有沙箱"GET /sandbox/reports
"X的状态是什么?"GET /sandbox/reports,按sandboxName筛选
"激活沙箱sbxtest"1. GET /sandbox/reports通过名称查找sandboxId<br>2. PATCH /sandbox/activate/{sandboxId}必须满足isPendingActivation: true
"放弃sbxtest的刷新"1. GET /sandbox/reports通过名称查找sandboxId<br>2. DELETE /sandbox/discardsandbox/{sandboxId}必须满足isPendingActivation: true
"删除沙箱sbxtest"1. GET /sandbox/reports通过名称查找sandboxId<br>2. DELETE /sandbox/deletesandbox/{sandboxId}先与用户确认

When user provides a sandboxId (07E prefix) directly

当用户直接提供sandboxId(以07E开头)

User says...OperationKey check
"Get details for 07E..."GET /sandbox/sandboxes/{sandboxId}
"Activate sandbox 07E..."1. GET /sandbox/sandboxes/{sandboxId} to verify status<br>2. PATCH /sandbox/activate/{sandboxId}Must be isPendingActivation: true
"Discard refresh on 07E..."1. GET /sandbox/sandboxes/{sandboxId} to verify status<br>2. DELETE /sandbox/discardsandbox/{sandboxId}Must be isPendingActivation: true
"Delete sandbox 07E..."1. GET /sandbox/sandboxes/{sandboxId} to verify existence<br>2. DELETE /sandbox/deletesandbox/{sandboxId}Confirm with user first

用户说...操作关键检查
"获取07E...的详细信息"GET /sandbox/sandboxes/{sandboxId}
"激活沙箱07E..."1. GET /sandbox/sandboxes/{sandboxId}验证状态<br>2. PATCH /sandbox/activate/{sandboxId}必须满足isPendingActivation: true
"放弃07E...的刷新"1. GET /sandbox/sandboxes/{sandboxId}验证状态<br>2. DELETE /sandbox/discardsandbox/{sandboxId}必须满足isPendingActivation: true
"删除沙箱07E..."1. GET /sandbox/sandboxes/{sandboxId}验证是否存在<br>2. DELETE /sandbox/deletesandbox/{sandboxId}先与用户确认

Common Mistakes to Avoid

需避免的常见错误

MistakeCorrect understanding
Using activate to "start" any sandboxActivate ONLY applies completed refreshes
Using discard to "hide" or "soft-delete"Discard ONLY rejects a pending refresh
Activating without checking status firstAlways verify isPendingActivation = true
Activating without user confirmationAlways confirm with the user before applying a refresh — this replaces existing sandbox data
Discarding without user confirmationAlways confirm with the user before discarding — this is irreversible and the refresh data is lost
Deleting without user confirmationAlways show sandbox info and ask for explicit confirmation
错误正确理解
使用activate操作“启动”任意沙箱Activate仅适用于已完成的刷新
使用discard操作“隐藏”或“软删除”沙箱Discard仅用于拒绝待处理的刷新
未先检查状态就执行激活操作始终验证isPendingActivation = true
未获得用户确认就执行激活操作应用刷新前务必与用户确认——这会替换现有沙箱数据
未获得用户确认就执行放弃操作放弃前务必与用户确认——此操作不可逆转,刷新数据将丢失
未获得用户确认就执行删除操作始终展示沙箱信息并请求明确确认