Delete and restore

Move a record to the trash, and bring records back.

On this page

Delete a record#

DELETE/records/{recordId}

This moves the record to the trash. It is hidden from lists and search, and its links are kept so it can be restored.

cURL
curl --fail-with-body -X DELETE "$JEMERO_URL/records/$RECORD_ID" \
  -H "Authorization: Bearer $JEMERO_API_KEY"
Node.js
const response = await fetch(
  `${process.env.JEMERO_URL}/records/${process.env.RECORD_ID}`,
  {
    method: 'DELETE',
    headers: { Authorization: `Bearer ${process.env.JEMERO_API_KEY}` },
  },
);
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
console.log(response.status);
Python
import os
import requests

response = requests.delete(
    f"{os.environ['JEMERO_URL']}/records/{os.environ['RECORD_ID']}",
    headers={"Authorization": f"Bearer {os.environ['JEMERO_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
print(response.status_code)

The answer is 204 No Content. Deleting a record that is already in the trash answers 404.

See the trash#

List records with deleted=true. The most recently deleted come first unless you sort.

Restore records#

POST/objects/{objectSlug}/records/restore

Send either ids or all, never both.

Body propertyMeaning
ids1–1,000 record IDs.
allEvery record in the trash that matches { "filters": [...], "search": "..." }. Both are optional, so "all": {} means the whole trash of this object. filters here is a plain list of conditions, without and/or groups.
cURL
curl --fail-with-body "$JEMERO_URL/objects/people/records/restore" \
  -H "Authorization: Bearer $JEMERO_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{ \"ids\": [\"$RECORD_ID\"] }"
Node.js
const response = await fetch(
  `${process.env.JEMERO_URL}/objects/people/records/restore`,
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.JEMERO_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ ids: [process.env.RECORD_ID] }),
  },
);
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
console.log(await response.json());
Python
import os
import requests

response = requests.post(
    f"{os.environ['JEMERO_URL']}/objects/people/records/restore",
    headers={"Authorization": f"Bearer {os.environ['JEMERO_API_KEY']}"},
    json={"ids": [os.environ["RECORD_ID"]]},
    timeout=30,
)
response.raise_for_status()
print(response.json())
Response 200
{ "restored": 1, "failed": [] }

A record can't come back if another record has since taken one of its unique values. It stays in the trash and appears in failed with its id and a message. The others are restored, so check failed even when the status is 200.

IDs that aren't in the trash, or that your role can't delete, are skipped and not counted.

Errors#

StatusCause
400Both or neither of ids and all, or the selection matches more than 1,000 records.
403Delete only: your role can't delete this record.
404The record or object doesn't exist, or your role can't view the record.