Skip to content
  • Auto
  • Light
  • Dark
Get Started

Create

Create
client.vals.files.create(stringvalId, FileCreateParamsparams, RequestOptionsoptions?): idstringlinksLinksnamestringpathstringtypeunionupdatedAtstringversionnumberFileCreateResponse
post/v2/vals/{val_id}/files

Create a new file, project val or directory

Parameters
valIdstring
formatuuid
FileCreateParamsalias
Hide ParametersShow Parameters
FileCreateParamsBase
Variant0 extends FileCreateParamsBase
Variant1 extends FileCreateParamsBase
Returns
FileCreateResponse

A File or Directory's Metadata

Hide ParametersShow Parameters
idstring

The id of the resource

formatuuid
namestring
pathstring
typeunion
"directory" | "file" | "interval" | 3 more
Hide ParametersShow Parameters
"directory"
"file"
"interval"
"http"
"email"
"script"
updatedAtstring
formatdate-time
versionnumber
minimum0
import ValTown from '@valtown/sdk';

const client = new ValTown();

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

console.log(file.id);
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
}