Skip to content
  • Auto
  • Light
  • Dark
Get Started

Create

Create
post/v2/vals/{val_id}/files

Create a new file, project val or directory

Path Parameters
val_idstring
formatuuid
Query Parameters
pathstring

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

branch_idstring
optional

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

formatuuid
Body Parameters
bodyunion
optional
One of the following 2 object variants:
Hide ParametersShow Parameters
UnionMember0object
Hide ParametersShow Parameters
typeenum
"directory"
Hide ParametersShow Parameters
"directory"
contentunknown
optional
UnionMember1object
Hide ParametersShow Parameters
contentstring

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
typeenum
"file" OR "interval" OR "http" OR 2 more
Hide ParametersShow Parameters
"file"
"interval"
"http"
"email"
"script"
Returns
idstring

The id of the resource

formatuuid
namestring
pathstring
typeenum
"directory" OR "file" OR "interval" OR 3 more
Hide ParametersShow Parameters
"directory"
"file"
"interval"
"http"
"email"
"script"
updatedAtstring
formatdate-time
versionnumber
minimum0
curl https://api.val.town/v2/vals/$VAL_ID/files \
    -H 'Content-Type: application/json' \
    -d '{
      "type": "directory"
    }'
200 Example
{
  "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
}