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

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

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

Create a new file, project val or directory

## Path parameters

- `val_id` string, uuid, required

## Query parameters

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

## Request body

- union
  - object
    - `type` 'directory', required
    - `content` unknown
  - object
    - `content` string, required — 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', required

## Response `201`

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

- `409` — Default Response

---

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