Skip to content

Admin Specs API

Server routes for spec document management (admin only).

POST /api/admin/specs/upload

Upload a spec document and trigger N8N processing.

Request Body

typescript
{
  file: File           // Spec PDF file
  brandName: string    // Brand name
  area: string         // Area type (e.g., 'guest-room', 'public')
  propertyName?: string // Optional property name
}

Response

json
{
  "specUploadId": "uuid",
  "documentId": "uuid",
  "status": "pending"
}

Flow

  1. Validate admin role
  2. Upload file to specs/{brand}/{upload_id}/{filename}
  3. Create pip_ai_documents row (kind='spec')
  4. Create pip_ai_spec_uploads row
  5. Create pip_ai_upload_jobs row
  6. Trigger N8N webhook asynchronously
  7. Return IDs and status

POST /api/admin/specs/callback

N8N callback after spec processing completes.

Headers

x-webhook-secret: <N8N_WEBHOOK_SECRET>

Request Body

typescript
{
  spec_upload_id: string
  status: 'completed' | 'failed'
  sections_count?: number
  error?: string
}

Flow

  1. Verify webhook secret
  2. Update pip_ai_spec_uploads.processing_status
  3. Update pip_ai_documents.processing_status
  4. Update pip_ai_upload_jobs.status

POST /api/admin/specs/retry

Retry a failed spec processing job.

Request Body

typescript
{
  specUploadId: string
}

Flow

  1. Validate admin role
  2. Reset processing status to pending
  3. Create new upload job
  4. Re-trigger N8N webhook

Source

server/api/admin/specs/

Built with VitePress