Skip to content
  • Auto
  • Light
  • Dark
Get Started
View as Markdown
Copy Markdown

Open in Claude
Open in ChatGPT

Update

client.vals.files.update(stringvalID, FileUpdateParams { path_, branch_id, content, 3 more } params, RequestOptionsoptions?): FileUpdateResponse { id, links, name, 4 more }
put/v2/vals/{val_id}/files

Update a file's content

ParametersExpand Collapse
valID: string
params: FileUpdateParams { path_, branch_id, content, 3 more }
path_: string

Query param: Path to a file or directory (e.g. 'dir/subdir/file.ts'). Pass in an empty string to represent the root directory.

branch_id?: string

Query param: The specified branch of the resource. Defaults to main if not provided.

formatuuid
content?: string

Body param: File and val content. An empty string will create an empty file. When creating a directory, the content should be null or undefined.

minLength0
maxLength80000
name?: string

Body param:

minLength1
maxLength48
parent_path?: string | null

Body param: Path to the directory you'd like to move this file to (e.g. 'folder1/folder2')

type?: "file" | "interval" | "http" | 2 more

Body param:

Accepts one of the following:
"file"
"interval"
"http"
"email"
"script"
ReturnsExpand Collapse
FileUpdateResponse { id, links, name, 4 more }

A File or Directory's Metadata

id: string

The id of the resource

formatuuid

The URL of this resource on Val Town

formaturi

The URL of this resource's source code as a module

formaturi

The URL of this resource on this API

formaturi

This resource's web endpoint, where it serves a website or API

formaturi
name: string
path: string
type: "directory" | "file" | "interval" | 3 more
Accepts one of the following:
"directory"
"file"
"interval"
"http"
"email"
"script"
updatedAt: string
version: number
import ValTown from "npm:@valtown/sdk";

const client = new ValTown();

const file = await client.vals.files.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: 'path' });

console.log(file.id);
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "links": {
    "html": "https://example.com",
    "module": "https://example.com",
    "self": "https://example.com",
    "endpoint": "https://example.com"
  },
  "name": "name",
  "path": "path",
  "type": "directory",
  "updatedAt": "2019-12-27T18:11:19.117Z",
  "version": 0
}
Returns Examples
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "links": {
    "html": "https://example.com",
    "module": "https://example.com",
    "self": "https://example.com",
    "endpoint": "https://example.com"
  },
  "name": "name",
  "path": "path",
  "type": "directory",
  "updatedAt": "2019-12-27T18:11:19.117Z",
  "version": 0
}