Delete a Field
Soft-deletes a field on a collection. The field row remains in the database with a deleted timestamp; it no longer appears in Get a Collection or editor schemas.
Deleting a field can affect stored content for that field on existing entries. Confirm exports or migrations before deleting in production.
Request
DELETE /api/collections/{collection}/fields/{field} HTTP/1.1
Host: app.nomacms.com
project-id: <project-uuid>
Authorization: Bearer <api-token>| Path segment | Description |
|---|---|
{collection} | Collection slug |
{field} | Field uuid |
No request body is required.
Requires the admin ability on the token.
Response (204)
No response body.
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.) |
| 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!,
})
await client.fields.delete("blog-posts", "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee")import axios from "axios"
async function main() {
const fieldUuid = "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
const res = await axios.delete(
`https://app.nomacms.com/api/collections/blog-posts/fields/${fieldUuid}`,
{
headers: {
"project-id": process.env.NOMA_PROJECT_ID!,
Authorization: `Bearer ${process.env.NOMA_API_KEY}`,
},
},
)
console.log(res.status)
}
void main()<?php
$uuid = 'aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee';
$ch = curl_init('https://app.nomacms.com/api/collections/blog-posts/fields/' . rawurlencode($uuid));
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'project-id: ' . getenv('NOMA_PROJECT_ID'),
'Authorization: Bearer ' . getenv('NOMA_API_KEY'),
],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE);FIELD_UUID="aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
curl -sS -o /dev/null -w "%{http_code}\n" -X DELETE \
"https://app.nomacms.com/api/collections/blog-posts/fields/$FIELD_UUID" \
-H "project-id: $NOMA_PROJECT_ID" \
-H "Authorization: Bearer $NOMA_API_KEY"package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest(
"DELETE",
"https://app.nomacms.com/api/collections/blog-posts/fields/aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee",
nil,
)
if err != nil {
panic(err)
}
req.Header.Set("project-id", os.Getenv("NOMA_PROJECT_ID"))
req.Header.Set("Authorization", "Bearer "+os.Getenv("NOMA_API_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
fmt.Println(res.StatusCode)
}require "net/http"
require "uri"
uuid = "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
uri = URI("https://app.nomacms.com/api/collections/blog-posts/fields/#{uuid}")
req = Net::HTTP::Delete.new(uri)
req["project-id"] = ENV.fetch("NOMA_PROJECT_ID")
req["Authorization"] = "Bearer #{ENV.fetch('NOMA_API_KEY')}"
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
res = http.request(req)
puts res.code
endimport os
import urllib.request
uuid = "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"
req = urllib.request.Request(
f"https://app.nomacms.com/api/collections/blog-posts/fields/{uuid}",
headers={
"project-id": os.environ["NOMA_PROJECT_ID"],
"Authorization": f"Bearer {os.environ['NOMA_API_KEY']}",
},
method="DELETE",
)
with urllib.request.urlopen(req) as res:
print(res.status)Related
- Authentication - Abilities (
admin) - Create a Field - Add a replacement field if needed
- JavaScript SDK -
fields.delete