---
title: "Restore an earlier version of a tool"
method: POST
path: "/v1/code/{id}/versions/{number}/restore"
tags: ["code"]
---

# Restore an earlier version of a tool

`POST /v1/code/{id}/versions/{number}/restore`

## Request

- Base URL: `https://api.pomerado.ai`
- URL: `https://api.pomerado.ai/v1/code/{id}/versions/{number}/restore`
- Auth: HTTP bearer

Make an earlier version of a tool your team built live again, as the tool's newest version.

- Business accounts only, with tools:build. The version's code, inputs and outputs go live at once, for free. Restoring the live version, or the version it restored, changes nothing.
- A version can be restored when code.get lists it as restorable: not one published before Pomerado kept a record of each version, or one taken down.
- A public tool restores only a version Pomerado checked that keeps every input its callers send; it may make a required input optional. Only an Owner or Admin signed in to the Dashboard restores a version Pomerado didn't check, never an API key or an agent.

## Path parameters

- `id` string, required
- `number` string, required

## Response `200`

The tool's code, with the restored version live

- CodeBundle
  - `integration` CodeIntegration, required
    - `id` string, required: an integration ID: int_ and 32 lowercase hex digits
    - `name` string, required
    - `site_url` string, nullable, required: The website's https origin, or null for an offline tool
    - `visibility` 'public' | 'private', required: public: published on Pomerado for every account to find and use. private: only your team sees, uses and edits it
    - `tools` CodeTool[], required: The tools your team created in it
      - `id` string, required: a tool ID: tool_ and 32 lowercase hex digits
      - `name` string, required
      - `effect` 'read' | 'write', required
      - `live_version` object, required: The version callers run now
        - `number` integer, required: The version's number: 1 for the tool's first code, one more for each later version
        - `published_at` string, required: a string to be decoded into a Date
        - `change` 'build' | 'repair' | 'change' | 'update' | 'edit' | 'restore', required: What made this version: build (Pomerado built the tool), repair (Pomerado repaired it after a run failed), change (someone asked for a change), update (Pomerado updated it), edit (a team member edited its code) or restore (a team member restored an earlier version as this one)
        - `requested_by` CodeMember, required
          - `user_id` string, required: The member's user ID
          - `name` string, nullable, required: The member's name, or null when they gave none
          - `email` string, required: The member's sign-in email
        - `restored_from` integer, required: an integer
        - `restorable` boolean, required: Whether code.restore can make this version live again: false for a version published before Pomerado kept a record of each version, and for one taken down
        - `unverified` boolean, required: True until a run verifies it: published without redoing a write already done
      - `draft_changed_files` integer, required: How many files your team's draft of the tool changes; 0 when it has none
      - `login_required` boolean, required: Whether the tool signs in to its website
      - `browser_version` boolean, required: Whether the live version has a browser version, which code.run runs with implementation browser; false only for a read whose HTTP version alone worked
      - `http_version` boolean, required: Whether the live version has an HTTP version, which code.run runs with implementation http
  - `tool` CodeTool, required
    - `id` string, required: a tool ID: tool_ and 32 lowercase hex digits
    - `name` string, required
    - `effect` 'read' | 'write', required
    - `live_version` object, required: The version callers run now
      - `number` integer, required: The version's number: 1 for the tool's first code, one more for each later version
      - `published_at` string, required: a string to be decoded into a Date
      - `change` 'build' | 'repair' | 'change' | 'update' | 'edit' | 'restore', required: What made this version: build (Pomerado built the tool), repair (Pomerado repaired it after a run failed), change (someone asked for a change), update (Pomerado updated it), edit (a team member edited its code) or restore (a team member restored an earlier version as this one)
      - `requested_by` CodeMember, required
        - `user_id` string, required: The member's user ID
        - `name` string, nullable, required: The member's name, or null when they gave none
        - `email` string, required: The member's sign-in email
      - `restored_from` integer, required: an integer
      - `restorable` boolean, required: Whether code.restore can make this version live again: false for a version published before Pomerado kept a record of each version, and for one taken down
      - `unverified` boolean, required: True until a run verifies it: published without redoing a write already done
    - `draft_changed_files` integer, required: How many files your team's draft of the tool changes; 0 when it has none
    - `login_required` boolean, required: Whether the tool signs in to its website
    - `browser_version` boolean, required: Whether the live version has a browser version, which code.run runs with implementation browser; false only for a read whose HTTP version alone worked
    - `http_version` boolean, required: Whether the live version has an HTTP version, which code.run runs with implementation http
  - `versions` CodeVersion[], required: The tool's versions, newest first, at most 100
    - `number` integer, required: The version's number: 1 for the tool's first code, one more for each later version
    - `published_at` string, required: a string to be decoded into a Date
    - `change` 'build' | 'repair' | 'change' | 'update' | 'edit' | 'restore', required: What made this version: build (Pomerado built the tool), repair (Pomerado repaired it after a run failed), change (someone asked for a change), update (Pomerado updated it), edit (a team member edited its code) or restore (a team member restored an earlier version as this one)
    - `requested_by` CodeMember, required
      - `user_id` string, required: The member's user ID
      - `name` string, nullable, required: The member's name, or null when they gave none
      - `email` string, required: The member's sign-in email
    - `restored_from` integer, required: an integer
    - `restorable` boolean, required: Whether code.restore can make this version live again: false for a version published before Pomerado kept a record of each version, and for one taken down
    - `unverified` boolean, required: True until a run verifies it: published without redoing a write already done
  - `files` CodeFile[], required: The live version's files, by path
    - `path` string, required: The file's path, such as src/tool.mjs
    - `source` 'team' | 'pomerado', required: team: written for your tool by its build. pomerado: added by Pomerado to run it, such as operation.mjs and the sign-in recipe auth-fill.json
    - `bytes` integer, required: The file's size in bytes
    - `content` string, required: The file's text
  - `input_schema` object, required: What the live version's input takes, as JSON Schema
  - `draft` CodeDraft, required
    - `base_version` integer, required: The version the draft started from: the live one when its first file was saved
    - `digest` string, required: The SHA-256 of the whole file set the draft makes, in hex
    - `changed` string[], required: The paths of the files the draft changes from its base version, sorted
    - `updated_at` string, required: a string to be decoded into a Date
    - `updated_by` CodeMember, required
      - `user_id` string, required: The member's user ID
      - `name` string, nullable, required: The member's name, or null when they gave none
      - `email` string, required: The member's sign-in email
    - `passed_at` string, required: a string to be decoded into a Date
    - `files` CodeDraftFile[], required: The changed files, by path
      - `path` string, required: The file's path, such as src/tool.mjs
      - `content` string, nullable, required: The file's text in the draft, or null when the draft deletes it
    - `base_files` CodeBaseFile[], nullable, required: Your team's files whose text in the base version isn't the live version's, by path: empty while the base version is live, and null when, with the live files and the changed ones, they'd take more than 4 MiB of the answer's JSON
      - `path` string, required: The file's path, such as src/tool.mjs
      - `content` string, nullable, required: The file's text in the base version, or null when the base version doesn't have it
    - `input_schema` object, required: What the draft's input takes, as JSON Schema: as the latest run of the draft that passed read it, or its base version's until one passes
  - `repair` CodeRepair, required
    - `status` 'repairing', required: repairing: Pomerado is repairing the tool after a run of it failed
    - `deadline_at` string, required: a string to be decoded into a Date

## Other responses

- `400`: invalid_request
- `401`: unauthorized, reauthentication_required
- `403`: business_account_required, forbidden
- `404`: not_found
- `409`: version_not_restorable, restore_changes_inputs, restore_unchecked
- `500`: internal_error
- `503`: temporarily_unavailable

---

[API](https://skmtc.dev/pomerado/apis/pomerado-api.md) · [All operations](https://skmtc.dev/pomerado/apis/pomerado-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pomerado/apis/pomerado-api/revisions/48dac2a3143e?raw)
