---
title: "Save a file in a tool's draft"
method: PUT
path: "/v1/code/{id}/draft"
tags: ["code"]
---

# Save a file in a tool's draft

`PUT /v1/code/{id}/draft`

## Request

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

Save one file of your team's draft of the code of a tool your team built.

- Business accounts only, with tools:build. Every member sees the draft with code.get.
- One draft per tool, shared by the team. Each save changes one file, and the last save of a file wins.
- content null deletes the file. A file saved back to its text in the draft's base version leaves the draft, and a draft with no change left is deleted.
- Only files under src/, test/ and explore/ change, and an entrypoint can't be deleted. A public tool's draft stays your team's until it's published.

## Path parameters

- `id` string, required

## Request body

- object
  - `path` string, required: a path under src/, test/ or explore/ of letters, digits, '.', '_', '-' and '/', ending in .js, .mjs, .ts or .json
  - `content` string, nullable, required: The file's new text, or null to delete the file

## Response `200`

The tool's draft after the save

- CodeSavedDraft
  - `draft` CodeDraftSummary, 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

## Other responses

- `400`: invalid_request
- `401`: unauthorized, reauthentication_required
- `403`: business_account_required, forbidden
- `404`: not_found
- `413`: request_too_large
- `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)
