Update a Field
Replaces a field definition with a full document. Every PUT must include type, label, and name (same rules as Create a Field), plus optional description, placeholder, options, validations, and parent_field_id.
Request
PUT /api/collections/{collection}/fields/{field} HTTP/1.1
Host: app.nomacms.com
Content-Type: application/json
project-id: <project-uuid>
Authorization: Bearer <api-token>
Accept: application/json| Path segment | Description |
|---|---|
{collection} | Collection slug |
{field} | Field uuid (not the numeric database id) |
Requires the admin ability on the token.
JSON body
Same validation as create: required type, label, name; optional description, placeholder, options, validations, parent_field_id. For type: "group", options.repeatable is required (boolean).
Uniqueness of name ignores the current field’s id (you can rename without colliding with yourself). Relation options are normalized the same way as on create when options is present.
Response (200)
JSON object with the same columns as Create a Field Response (201) (uuid, type, label, name, and so on).
Errors
| Status | When |
|---|---|
| 400 | Missing project-id or project cannot be resolved |
| 401 | Missing or invalid bearer token |
| 403 | Token does not have admin (or *) |
| 404 | Unknown collection (Collection not found.) or field uuid (Field not found.) |
| 422 | Validation failed |
| 429 | Rate limited |
Example
import { createClient } from "@nomacms/js-sdk"
const client = createClient({
projectId: process.env.NOMA_PROJECT_ID!,
apiKey: process.env.NOMA_API_KEY!,
})
const fieldUuid = "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
const updated = await client.fields.update("blog-posts", fieldUuid, {
type: "text",
label: "Subtitle",
name: "subtitle",
description: null,
placeholder: null,
options: {},
validations: {
required: { status: true, message: "Subtitle is required" },
},
parent_field_id: null,
})
console.log(updated)import axios from "axios"
async function main() {
const fieldUuid = "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
const { data } = await axios.put(
`https://app.nomacms.com/api/collections/blog-posts/fields/${fieldUuid}`,
{
type: "text",
label: "Subtitle",
name: "subtitle",
description: null,
placeholder: null,
options: {},
validations: {
required: { status: true, message: "Subtitle is required" },
},
parent_field_id: null,
},
{
headers: {
"Content-Type": "application/json",
"project-id": process.env.NOMA_PROJECT_ID!,
Authorization: `Bearer ${process.env.NOMA_API_KEY}`,
Accept: "application/json",
},
},
)
console.log(data)
}
void main()<?php
$uuid = 'aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee';
$payload = json_encode([
'type' => 'text',
'label' => 'Subtitle',
'name' => 'subtitle',
'description' => null,
'placeholder' => null,
'options' => new stdClass(),
'validations' => [
'required' => ['status' => true, 'message' => 'Subtitle is required'],
],
'parent_field_id' => null,
]);
$ch = curl_init('https://app.nomacms.com/api/collections/blog-posts/fields/' . rawurlencode($uuid));
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Content-Length: ' . strlen($payload),
'project-id: ' . getenv('NOMA_PROJECT_ID'),
'Authorization: Bearer ' . getenv('NOMA_API_KEY'),
'Accept: application/json',
],
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);FIELD_UUID="aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
curl -sS -X PUT "https://app.nomacms.com/api/collections/blog-posts/fields/$FIELD_UUID" \
-H "Content-Type: application/json" \
-H "project-id: $NOMA_PROJECT_ID" \
-H "Authorization: Bearer $NOMA_API_KEY" \
-H "Accept: application/json" \
-d '{"type":"text","label":"Subtitle","name":"subtitle","description":null,"placeholder":null,"options":{},"validations":{"required":{"status":true,"message":"Subtitle is required"}},"parent_field_id":null}'package main
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)
func main() {
body := map[string]any{
"type": "text",
"label": "Subtitle",
"name": "subtitle",
"description": nil,
"placeholder": nil,
"options": map[string]any{},
"validations": map[string]any{"required": map[string]any{"status": true, "message": "Subtitle is required"}},
"parent_field_id": nil,
}
raw, _ := json.Marshal(body)
req, err := http.NewRequest(
"PUT",
"https://app.nomacms.com/api/collections/blog-posts/fields/aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee",
bytes.NewReader(raw),
)
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("project-id", os.Getenv("NOMA_PROJECT_ID"))
req.Header.Set("Authorization", "Bearer "+os.Getenv("NOMA_API_KEY"))
req.Header.Set("Accept", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
_, _ = io.Copy(os.Stdout, res.Body)
}require "net/http"
require "json"
require "uri"
uuid = "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
uri = URI("https://app.nomacms.com/api/collections/blog-posts/fields/#{uuid}")
req = Net::HTTP::Put.new(uri)
req["Content-Type"] = "application/json"
req["project-id"] = ENV.fetch("NOMA_PROJECT_ID")
req["Authorization"] = "Bearer #{ENV.fetch('NOMA_API_KEY')}"
req["Accept"] = "application/json"
req.body = JSON.generate({
"type" => "text",
"label" => "Subtitle",
"name" => "subtitle",
"description" => nil,
"placeholder" => nil,
"options" => {},
"validations" => { "required" => { "status" => true, "message" => "Subtitle is required" } },
"parent_field_id" => nil
})
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
puts http.request(req).body
endimport json
import os
import urllib.request
uuid = "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
payload = {
"type": "text",
"label": "Subtitle",
"name": "subtitle",
"description": None,
"placeholder": None,
"options": {},
"validations": {"required": {"status": True, "message": "Subtitle is required"}},
"parent_field_id": None,
}
data = json.dumps(payload).encode()
req = urllib.request.Request(
f"https://app.nomacms.com/api/collections/blog-posts/fields/{uuid}",
data=data,
headers={
"Content-Type": "application/json",
"project-id": os.environ["NOMA_PROJECT_ID"],
"Authorization": f"Bearer {os.environ['NOMA_API_KEY']}",
"Accept": "application/json",
},
method="PUT",
)
with urllib.request.urlopen(req) as res:
print(res.read().decode())Related
- Authentication - Abilities (
admin) - Create a Field - Validation rules and group/relation behavior
- Delete a Field - Remove a field
- JavaScript SDK -
fields.update