Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.wellapp.ai/llms.txt

Use this file to discover all available pages before exploring further.

ExtractPrompt stores named, versioned AI extraction prompt templates that drive the document-extraction pipeline when ingesting invoices and documents. Each record is scoped to a type (e.g. the extraction category), carries the raw prompt text, a monotone version counter, an is_active flag, and an is_default flag marking the system-wide fallback. Records are either workspace-scoped (a workspace-level customisation) or global (no workspace FK, is_default = true). The entity is owned exclusively by the extraction pipeline and seed layer; no user-facing PATCH endpoint exists.
NamingValue
ObjectExtractPrompt
Resource type (JSON:API type)extract_prompt
Collection / records rootβ€” (not a records root)
REST base/v1/extract-prompts
Entity classExtractPrompt
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

OperationMethod & pathStatus
ListGET /v1/extract-prompts🟑 Planned
RetrieveGET /v1/extract-prompts/{id}🟑 Planned
CreatePOST /v1/extract-prompts🟑 Planned
UpdatePATCH /v1/extract-prompts/{id}🟑 Planned
DeleteDELETE /v1/extract-prompts/{id}🟑 Planned

Data model

Attributes

FieldTypeRequiredConstraintsAllowed valuesDescription
idstring (UUID) β€” πŸ”’ systemβœ… YesPK; gen_random_uuid() default; immutable after creationAny valid UUID v4Public stable identifier for the prompt record. Exposed as id in JSON:API; backed by the pk UUID column.
typestringβœ… Yesvarchar(100); NOT NULL; single-column index; composite indexes (type, is_active) and (type, version)Free-form string β€” conventionally an extraction category slug such as invoice, receipt, bank_statementCategorisation key grouping prompt versions under a logical extraction pipeline stage. Used by the extraction service to look up the current active prompt for a given category.
prompttextβœ… YesPostgreSQL TEXT; NOT NULL; no length capAny non-null string (typically a multi-line AI system or user prompt)The raw LLM prompt text sent to the extraction model. May contain field-extraction instructions, output-format directives, or chain-of-thought scaffolding.
versionintegerβœ… YesNOT NULL; DEFAULT 1; composite index (type, version); increments on each prompt revisionPositive integer β‰₯ 1Monotone version counter within a type. Allows the pipeline to track prompt iterations and roll back to a prior version by is_active flag manipulation.
is_activebooleanβœ… YesNOT NULL; DEFAULT false; composite index (type, is_active)true | falseIndicates whether this is the currently active prompt for its type. The extraction service queries type + is_active = true to select the live prompt. Only one record per (type, workspace) combination should be active at a time β€” enforced by application logic, not a DB constraint.
is_defaultbooleanβœ… YesNOT NULL; DEFAULT falsetrue | falseMarks the system-wide default prompt for its type. Default prompts have no workspace FK (workspace = null). Workspace-scoped prompts shadow the default when is_active = true.
created_attimestamptz β€” πŸ”’ systemβœ… YesNOT NULL; set once via onCreate hook; never updatedISO 8601 timestampWall-clock UTC timestamp of row creation. Set automatically by MikroORM’s onCreate lifecycle hook.
updated_attimestamptz β€” πŸ”’ systemβšͺ NoNULLABLE; set on first write via onCreate, refreshed on every subsequent write via onUpdateISO 8601 timestamp or nullWall-clock UTC timestamp of the last update. NULL until the first update after creation.

Relationships

NameTypeRequiredDescription
workspaceto-one (ManyToOne)βšͺ No β€” nullableOptional FK to the workspaces table (workspace_pk int). When NULL the prompt is a global default accessible to all workspaces. When set, the prompt is a workspace-level customisation that overrides the global default for that workspace’s extraction pipeline. FK constraint: ON UPDATE CASCADE, ON DELETE SET NULL.

System-computed

  • id (pk): generated by gen_random_uuid() at INSERT time; immutable.
  • version: defaults to 1; incremented by the extraction pipeline or seed layer on prompt revision β€” not auto-incremented by the DB.
  • is_active: defaults to false; toggled by the pipeline when promoting a new prompt version.
  • is_default: defaults to false; set by the seed layer for system-wide baseline prompts.
  • created_at: set by MikroORM onCreate hook; never subsequently mutated.
  • updated_at: set by MikroORM onCreate hook on first persist; refreshed on every subsequent onUpdate event.
  • workspace FK: set null automatically by the DB (ON DELETE SET NULL) when the parent workspace is deleted.

Example

{
  "data": {
    "type": "extract_prompt",
    "id": "a3e1c7f2-84b0-4d2e-9c51-0f3b2d7e1a88",
    "attributes": {
      "type": "invoice",
      "prompt": "Extract the following fields from the invoice: issue_date, due_date, grand_total, tax_total, vendor_name, invoice_number. Return structured JSON only.",
      "version": 3,
      "is_active": true,
      "is_default": false,
      "created_at": "2025-09-21T17:50:44.000Z",
      "updated_at": "2025-10-14T09:12:03.000Z"
    },
    "relationships": {
      "workspace": {
        "data": { "type": "workspace", "id": "9f3b2d7e-1a88-4d2e-9c51-0f3b2d7e1a88" }
      }
    }
  }
}
Source: /Users/maximechampoux/platform/apps/api/src/database/entities/ExtractPrompt.ts Β· domain: ingestion Β· tier: Infrastructure