Delete an Asset
Deletes an asset from the project.
The HTTP path is DELETE /api/files/{identifier}.
By default the database row is soft-deleted; storage files are removed in both default and force flows. Use force to permanently remove the row from the database.
Request
DELETE /api/files/{identifier} HTTP/1.1
Host: app.nomacms.com
project-id: <project-uuid>
Authorization: Bearer <api-token>
Accept: application/jsonRequires the delete ability on the token.
Path parameters
| Param | Description |
|---|---|
identifier | Asset UUID or internal numeric id (same rules as Get an Asset). |
Query parameters
| Param | Description |
|---|---|
force | If truthy (1, true), performs a permanent delete on the asset record. If omitted or false, the row is soft-deleted. |
Response (200)
JSON object:
| Field | Type | Description |
|---|---|---|
success | boolean | Always true on success |
message | string | Human-readable status (Asset deleted successfully, or Asset permanently deleted when force is used) |
Errors
| Status | When |
|---|---|
| 400 | Missing project-id or project cannot be resolved (see Authentication) |
| 401 | Missing or invalid bearer token |
| 403 | Token does not have delete (or *) |
| 404 | Asset not found (Asset not found), or no project with that UUID |
| 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.assets.delete(assetUuid)
// Permanent row removal (when applicable)
// await client.assets.delete(assetUuid, true)import axios from "axios"
async function main() {
const assetUuid = process.env.ASSET_UUID!
const url = `https://app.nomacms.com/api/files/${encodeURIComponent(assetUuid)}`
const headers = {
"project-id": process.env.NOMA_PROJECT_ID!,
Authorization: `Bearer ${process.env.NOMA_API_KEY}`,
Accept: "application/json",
}
const { data } = await axios.delete(url, { headers })
console.log(data)
// Permanent delete — use instead of default for the same asset when needed
// const { data } = await axios.delete(url, { params: { force: 1 }, headers })
}
void main()<?php
$uuid = getenv('ASSET_UUID');
$url = 'https://app.nomacms.com/api/files/' . rawurlencode($uuid);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'project-id: ' . getenv('NOMA_PROJECT_ID'),
'Authorization: Bearer ' . getenv('NOMA_API_KEY'),
'Accept: application/json',
],
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);curl -sS -X DELETE \
-H "project-id: $NOMA_PROJECT_ID" \
-H "Authorization: Bearer $NOMA_API_KEY" \
-H "Accept: application/json" \
"https://app.nomacms.com/api/files/$ASSET_UUID"package main
import (
"io"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest("DELETE", "https://app.nomacms.com/api/files/"+os.Getenv("ASSET_UUID"), 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"))
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 "uri"
uuid = ENV.fetch("ASSET_UUID")
uri = URI("https://app.nomacms.com/api/files/#{URI.encode_www_form_component(uuid)}")
req = Net::HTTP::Delete.new(uri)
req["project-id"] = ENV.fetch("NOMA_PROJECT_ID")
req["Authorization"] = "Bearer #{ENV.fetch('NOMA_API_KEY')}"
req["Accept"] = "application/json"
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
puts http.request(req).body
endimport os
import urllib.parse
import urllib.request
uuid = os.environ["ASSET_UUID"]
url = "https://app.nomacms.com/api/files/" + urllib.parse.quote(uuid, safe="")
req = urllib.request.Request(
url,
method="DELETE",
headers={
"project-id": os.environ["NOMA_PROJECT_ID"],
"Authorization": f"Bearer {os.environ['NOMA_API_KEY']}",
"Accept": "application/json",
},
)
with urllib.request.urlopen(req) as res:
print(res.read().decode())Related
- Authentication - Headers and abilities
- Get an Asset - Resolve
identifier - JavaScript SDK -
assets.delete