Skip to main content

Admin Items API Endpoints

The Items API provides endpoints for managing directory listings including creation, updates, review workflows (approve/reject), audit history, bulk operations, and statistics. Items progress through a lifecycle of draft, pending, approved, and rejected statuses. All endpoints require admin authentication.

Base Path

/api/admin/items

Route Summary

MethodPathAuthDescription
GET/api/admin/itemsAdminGet paginated items list
POST/api/admin/itemsAdminCreate a new item
GET/api/admin/items/statsAdminGet item statistics
POST/api/admin/items/bulkAdminBulk approve, reject, or delete
GET/api/admin/items/{id}AdminGet item by ID
PUT/api/admin/items/{id}AdminUpdate item
DELETE/api/admin/items/{id}AdminDelete item permanently
POST/api/admin/items/{id}/reviewAdminApprove or reject an item
GET/api/admin/items/{id}/historyAdminGet item audit history

List Items

GET /api/admin/items

Returns a paginated list of items with search, filtering by status/category/tags, and sorting.

Query Parameters:

ParameterTypeDefaultDescription
pageinteger1Page number (minimum: 1)
limitinteger10Results per page (1--100)
searchstring--Search items by name or description
statusstring--Filter: draft, pending, approved, rejected
categoriesstring--Comma-separated category slugs
tagsstring--Comma-separated tag slugs
sortBystringupdated_atSort field: name, updated_at, status, submitted_at
sortOrderstringdescSort direction: asc or desc

Response (200):

{
"success": true,
"items": [
{
"id": "item_123abc",
"name": "Awesome Productivity Tool",
"slug": "awesome-productivity-tool",
"description": "A powerful tool to boost your productivity",
"source_url": "https://example.com/tool",
"category": ["productivity", "business"],
"tags": ["saas", "productivity"],
"featured": true,
"icon_url": "https://example.com/icon.png",
"status": "approved",
"created_at": "2024-01-20T10:30:00.000Z",
"updated_at": "2024-01-20T14:45:00.000Z"
}
],
"total": 156,
"page": 1,
"limit": 10,
"totalPages": 16
}

Create Item

POST /api/admin/items

Creates a new item with duplicate checks on both ID and slug. Triggers CRM sync (if enabled) and location indexing (if enabled).

Request Body:

FieldTypeRequiredDescription
idstringYesUnique item identifier
namestringYesItem name
slugstringYesURL-friendly slug (must be unique)
descriptionstringYesItem description
source_urlstringYesSource URL of the item
categorystring[]NoArray of category slugs
tagsstring[]NoArray of tag slugs
brandstringNoBrand name (used for CRM company sync)
featuredbooleanNoFeatured flag (default: false)
icon_urlstringNoIcon URL
statusstringNoInitial status (default: draft)
locationobjectNoLocation data for geo-indexing

Response (201):

{
"success": true,
"item": {
"id": "item_123abc",
"name": "Awesome Productivity Tool",
"slug": "awesome-productivity-tool",
"status": "draft",
"created_at": "2024-01-20T10:30:00.000Z"
},
"message": "Item created successfully"
}

Get Item Statistics

GET /api/admin/items/stats

Returns counts by status. Supports optional filters to scope the statistics.

Query Parameters:

ParameterTypeDescription
searchstringFilter stats by search term
categoriesstringComma-separated category slugs
tagsstringComma-separated tag slugs

Response (200):

{
"success": true,
"data": {
"total": 1247,
"draft": 45,
"pending": 23,
"approved": 1156,
"rejected": 23
}
}

Bulk Actions

POST /api/admin/items/bulk

Performs bulk approve, reject, or delete on up to 100 items. Each item is processed individually; partial failures do not abort the entire operation. Sends email notifications to submitters on approve/reject.

Request Body:

FieldTypeRequiredDescription
actionstringYesapprove, reject, or delete
idsstring[]YesItem IDs to process (1--100, no duplicates)
reasonstringYes (for reject)Rejection reason (minimum 10 characters)

Response (200):

{
"success": true,
"message": "Bulk approve completed: 3 approved, 0 failed",
"results": [
{ "id": "item_1", "success": true },
{ "id": "item_2", "success": true },
{ "id": "item_3", "success": false, "error": "Item not found" }
],
"summary": { "total": 3, "successful": 2, "failed": 1 }
}

Get / Update / Delete Item

Get Item

GET /api/admin/items/{id}

Returns complete item details including metadata, categories, tags, review notes, and engagement metrics.

Update Item

PUT /api/admin/items/{id}

Partial update -- only provided fields are modified. Triggers CRM sync when brand is provided and location re-indexing when location data changes.

Request Body (all fields optional):

{
"name": "Updated Tool Name",
"slug": "updated-tool-name",
"description": "Updated description",
"source_url": "https://example.com/updated",
"category": ["productivity", "automation"],
"tags": ["saas", "ai"],
"brand": "Acme Corp",
"featured": true,
"icon_url": "https://example.com/new-icon.png",
"status": "approved"
}

Delete Item

DELETE /api/admin/items/{id}

Permanently deletes an item and removes it from the location index (if enabled). This action cannot be undone.

Response (200):

{ "success": true, "message": "Item deleted successfully" }

Review Item

POST /api/admin/items/{id}/review

Approves or rejects an item. Records the review decision with optional notes. Sends an email notification to the original submitter (if the submitter is a registered user).

Request Body:

FieldTypeRequiredDescription
statusstringYesapproved or rejected
review_notesstringNoExplanation of the review decision

Response (200):

{
"success": true,
"data": {
"id": "item_123abc",
"status": "approved",
"review_notes": "Great tool, approved for listing.",
"reviewed_at": "2024-01-20T16:45:00.000Z"
},
"message": "Item approved successfully"
}

Get Item Audit History

GET /api/admin/items/{id}/history

Returns the complete audit trail for an item, including creation, updates, status changes, reviews, deletions, and restorations.

Query Parameters:

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger20Results per page (max 100)
actionstring--Comma-separated filter: created, updated, status_changed, reviewed, deleted, restored

Response (200):

{
"success": true,
"data": {
"logs": [
{
"id": "log_abc123",
"itemId": "awesome-tool",
"action": "reviewed",
"previousStatus": "pending",
"newStatus": "approved",
"performedByName": "Admin User",
"notes": "Approved for listing",
"createdAt": "2024-01-20T16:45:00.000Z"
}
],
"total": 12,
"page": 1,
"limit": 20,
"totalPages": 1
}
}

Validation Rules

FieldRule
idRequired; must be unique across all items
nameRequired for creation
slugRequired; must be unique across all items
descriptionRequired for creation
source_urlRequired for creation; valid URL format
statusMust be draft, pending, approved, or rejected
reasonRequired for bulk reject; minimum 10 characters
idsBulk: 1--100 non-empty unique strings
actionHistory filter: valid audit action types only

Error Codes

StatusMeaning
400Validation error, invalid parameters, missing fields
401Authentication required
403Admin privileges required
404Item not found
409Duplicate item ID or slug
500Internal server error