# Archive a script (/en/docs/api/native/automation/archiveScript)





Keep the name, versions and draft while archiving. The default list hides it and new target resolution and run requests reject the archived target.

`POST /automation/v1/scripts/{ns}/{name}/archive`

## Authentication [#authentication]

`Authorization: Bearer $PRAXIS_API_KEY`

## Request fields [#request-fields]

| Parameter | Type | Description |
| --- | --- | --- |
| path: ns | `string` | required; Namespace, folded to lowercase; matches [a-z0-9][a-z0-9._-]&#123;0,63&#125;. praxis is read-only. |
| path: name | `string` | required; Name, folded to lowercase; matches [a-z0-9][a-z0-9._-]&#123;0,63&#125;. |

### application/json [#applicationjson]

no additional fields.
object

## Examples [#examples]

[SDK installation and example environment](/en/docs/api/native/automation)

Set these environment variables to your own resources:

| Variable | Source |
| --- | --- |
| SCRIPT_NAME | [name returned by creating a script](/en/docs/api/native/automation/createScript) |

```bash
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/archive" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
```

```typescript
import { createAutomationClient } from '@deepraxis/sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.archive({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  },
  "body": {}
});
console.log(result);
```

## Response [#response]

### HTTP 200 [#http-200]

Success

`application/json`

| Field | Type | Description |
| --- | --- | --- |
| id | `string` | required; Definition id, prefixed scr_ for scripts and wf_ for workflows; calls normally use namespace and name. |
| kind | `"script"` / `"workflow"` | required; Orchestration kind. script is a TypeScript script that executes once; workflow is a YAML workflow made of steps that can wait for events, timers or child runs and can be suspended. |
| namespace | `string` | required; Namespace; references take the form namespace/name@version. |
| name | `string` | required; Name; with namespace it is unique within the tenant, and scripts and workflows share one namespace (duplicates return 409 NAME_TAKEN). |
| description | `string` | required; Free-text description, at most 1000 characters. |
| labels | `object` | required; User-defined string key and value tags for grouping and list filtering (labels[key]=value); keys must not start with praxis. |
| owner | `string` | required; Tenant that owns the definition, injected by the gateway; treat it as an opaque string. |
| latest_version | `null` / `object` | required; The published version the latest tag points to, as &#123;version, published_at&#125;; null if nothing is published. |
| latest_version (variant 2).version | `string` | required; Version number (semver) of the latest published version. |
| latest_version (variant 2).published_at | `string` | required; Time that version was published (RFC 3339 UTC). |
| dist_tags | `object` | required; Map from dist-tag to the exact version it points to, for example latest to 1.2.0; ns/name@tag resolves through it. |
| draft_changed | `boolean` | required; true when the draft content (digest) differs from the latest version, meaning there are unpublished changes. |
| latest_run | `null` / `object` | required; Summary of the most recent run of this definition, or null if it has never run. |
| latest_run (variant 2).id | `string` | required; Run id (run_ prefix); pass it to runs.retrieve. |
| latest_run (variant 2).number | `null` / `number` | required; Increasing sequence number of the run within its script or workflow. |
| latest_run (variant 2).status | `"running"` / `"completed"` / `"faulted"` / `"cancelled"` / `"pending"` / `"waiting"` / `"suspended"` | required; Run status. pending is created but not started; running is executing; waiting means a workflow is waiting on an event, timer or child run; suspended means a workflow was suspended; cancelled was cancelled; faulted failed; completed finished successfully. |
| latest_run (variant 2).created_at | `string` | required; Time the run was created (RFC 3339 UTC). |
| latest_run (variant 2).current_wait | `null` / `object` | required; The wait point currently open, or null when the run is not waiting. |
| latest_run (variant 2).current_wait (variant 2).id | `string` | required; Wait point id, prefixed wait_; use it as wait_id when completing an event wait. |
| latest_run (variant 2).current_wait (variant 2).run_id | `string` | required; Id (run_) of the run this wait belongs to. |
| latest_run (variant 2).current_wait (variant 2).kind | `"event"` / `"timer"` / `"child"` | required; Wait kind. event waits for an external event that can be submitted with runs.completeWait; timer waits until resume_at; child waits for a child run to finish. |
| latest_run (variant 2).current_wait (variant 2).state | `"cancelled"` / `"open"` / `"resolved"` / `"expired"` | required; Wait point state. open is still waiting; resolved was satisfied; expired passed its expires_at; cancelled was cancelled and can no longer be satisfied. |
| latest_run (variant 2).current_wait (variant 2).task | `null` / `object` | required; The workflow step &#123;reference, name&#125; that produced the wait; null when there is no such step. |
| latest_run (variant 2).current_wait (variant 2).task (variant 2).reference | `string` | required; JSON Pointer of the step, for example /do/2/wait_payment. |
| latest_run (variant 2).current_wait (variant 2).task (variant 2).name | `string` | required; Step name, the key in the workflow YAML. |
| latest_run (variant 2).current_wait (variant 2).resume_at | `null` / `string` | required; For kind=timer, the instant the run resumes (RFC 3339 UTC); null for other kinds. |
| latest_run (variant 2).current_wait (variant 2).event_type | `null` / `string` | required; For kind=event, the event type being awaited; null for other kinds. |
| latest_run (variant 2).current_wait (variant 2).child_run_id | `null` / `string` | required; For kind=child, the id of the child run being awaited; null for other kinds. |
| latest_run (variant 2).current_wait (variant 2).created_at | `string` | required; Time the wait point was created (RFC 3339 UTC). |
| latest_run (variant 2).current_wait (variant 2).expires_at | `null` / `string` | required; Time the wait point expires (RFC 3339 UTC), or null if it has no deadline. |
| latest_run (variant 2).current_wait (variant 2).resolved_at | `null` / `string` | required; Time the wait point was resolved (RFC 3339 UTC), or null if still open. |
| stats_7d | `object` | required; Run statistics for the last seven days, bucketed by the day each run ended and updated when runs finish. no additional fields. |
| stats_7d.runs | `number` | required; Number of runs that ended in the last seven days, in any terminal status. |
| stats_7d.failures | `number` | required; How many of those runs ended faulted. |
| archived_at | `null` / `string` | required; Archive time, or null while not archived. An archived name stays reserved and cannot be reused. |
| created_at | `string` | required; Creation time (RFC 3339 UTC). |
| updated_at | `string` | required; Time of the last update (RFC 3339 UTC). |

### Measured response [#measured-response]

HTTP 200

```json
{
  "id": "scr_00mv67lwvh08624c70ef824a0d8b14b0315c88452e",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "script",
  "namespace": "docs-samples",
  "name": "sample-scripts-1791867412840-b05e8a",
  "description": "Sample definition",
  "labels": {},
  "latest_version": {
    "version": "1.0.0",
    "published_at": "2026-10-13T04:57:22.398Z"
  },
  "dist_tags": {
    "latest": "1.0.0"
  },
  "draft_changed": false,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": "2026-10-13T04:57:27.639Z",
  "created_at": "2026-10-13T04:57:19.277Z",
  "updated_at": "2026-10-13T04:57:27.639Z"
}
```

## Errors [#errors]

| HTTP | Codes and description |
| --- | --- |
| 400 | INVALID_PARAMS: Invalid request parameters, path, cursor, or body format. |
| 403 | NAMESPACE_FORBIDDEN: The namespace is read-only, or the run token does not permit this call. |
| 404 | TARGET_NOT_FOUND: The target does not exist or has an incompatible type. |
| 412 | PRECONDITION_FAILED: The revision, source digest, or concurrent write precondition does not match. |
| default | RFC 9457 automation problem. 429 includes Retry-After. |

[Authentication and common errors](/en/docs/api/errors) · Retain the `X-Request-Id` response header for troubleshooting.
