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

Open in Claude
Open in ChatGPT

Create

client.vals.create(ValCreateParams { name, privacy, description, orgId } body, RequestOptionsoptions?): Val { id, author, createdAt, 5 more }
post/v2/vals

Create a new val

ParametersExpand Collapse
body: ValCreateParams { name, privacy, description, orgId }
name: string
privacy: "public" | "unlisted" | "private"
Accepts one of the following:
"public"
"unlisted"
"private"
description?: string
orgId?: string

ID of the org to create the val in

formatuuid
ReturnsExpand Collapse
Val { id, author, createdAt, 5 more }

A Val

id: string

The id of the val

formatuuid
author: Author { id, type, username }
id: string
type: "user" | "org"
Accepts one of the following:
"user"
"org"
username: string | null
createdAt: string
description: string | null
imageUrl: string | null

The URL of this val's image

The URL of this resource on Val Town

formaturi

The URL of this resource on this API

formaturi
name: string
privacy: "public" | "unlisted" | "private"

This resource's privacy setting. Unlisted resources do not appear on profile pages or elsewhere, but you can link to them.

Accepts one of the following:
"public"
"unlisted"
"private"
import ValTown from "npm:@valtown/sdk";

const client = new ValTown();

const val = await client.vals.create({ name: 'myVal', privacy: 'public', description: 'My val' });

console.log(val.id);
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "author": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "type": "user",
    "username": "username"
  },
  "createdAt": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "imageUrl": "imageUrl",
  "links": {
    "html": "https://example.com",
    "self": "https://example.com"
  },
  "name": "name",
  "privacy": "public"
}
Returns Examples
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "author": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "type": "user",
    "username": "username"
  },
  "createdAt": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "imageUrl": "imageUrl",
  "links": {
    "html": "https://example.com",
    "self": "https://example.com"
  },
  "name": "name",
  "privacy": "public"
}