---
title: "PUT /v2/vals/{val_id}/files"
method: PUT
path: "/v2/vals/{val_id}/files"
tags: ["vals"]
---

# PUT /v2/vals/{val_id}/files

`PUT /v2/vals/{val_id}/files`

Update a file's content

## Path parameters

- `val_id` string, uuid, required

## Query parameters

- `branch_id` string, uuid
- `path` string, required

## Request body

- object
  - `content` string — File and val content. An empty string will create an empty file. When creating a directory, the content should be null or undefined.
  - `type` 'file' | 'interval' | 'http' | 'email' | 'script'
  - `parent_path` string, nullable — Path to the directory you'd like to move this file to (e.g. 'folder1/folder2')
  - `name` string

## Response `200`

A File or Directory's Metadata

- FileRevisionMetadataV2 — A File or Directory's Metadata
  - `name` string, required
  - `id` string, uuid, required — The id of the resource
  - `path` string, required
  - `version` integer, required
  - `updatedAt` string, date-time, required
  - `type` 'directory' | 'file' | 'interval' | 'http' | 'email' | 'script', required
  - `links` object, required
    - `self` string, uri, required — The URL of this resource on this API
    - `html` string, uri, required — The URL of this resource on Val Town
    - `module` string, uri, required — The URL of this resource's source code as a module
    - `endpoint` string, uri — This resource's web endpoint, where it serves a website or API
    - `email` string, email — This resource's email address for receiving emails (for email-type vals)

## Other responses

- `201` — A File or Directory's Metadata

## Changes

- **2026-04-20** `8f22304950dd` — 1 breaking
  - request body became required
- **2026-03-18** `7ca4c991c6cc` — 3 breaking
  - the `anyOf[subschema #1]/type` request property type changed from `string` to no type
  - the `type` response's property type changed from `string` to no type for status `200`
  - the `type` response's property type changed from `string` to no type for status `201`
- **2026-03-11** `dc1b3c9e3b2a` — 1 breaking, 4 warning, 1 info
  - the request's body type changed from `object` to no type
  - removed the request property `content`
  - removed the request property `name`
  - removed the request property `parent_path`
  - …2 more
- **2026-02-27** `fb890bfd4bf7` — 1 warning
  - changed the pattern of the request property `name` from `^[a-zA-Z0-9\-_.]+$` to `^[a-zA-Z0-9\$\[\]\(\)\-_.]+$`
- **2026-02-03** `05f618f5e1bc` — 2 info
  - added the optional property `links/email` to the response with the `200` status
  - added the optional property `links/email` to the response with the `201` status

[Full history](https://skmtc.dev/val-town/apis/val-town-api/changes/v2/vals/:val_id/files/put.md)

---

[API](https://skmtc.dev/val-town/apis/val-town-api.md) · [All operations](https://skmtc.dev/val-town/apis/val-town-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/val-town/val-town-api/revisions/4d8b6d2e6db3/schema)
