Defining Intents
Create custom intents with prompt templates and optional structured output schemas.
Create an intent
POST /dashboard/custom-domains/legal-ops/intents
Authorization: Bearer <dashboard_jwt>
Content-Type: application/json
{
"intentKey": "contract_review",
"displayName": "Contract Review",
"description": "Review a contract for key obligations, risks, and missing provisions",
"promptTemplate": "Review the following {{document_type}}.\n\nIdentify:\n1. Key obligations for each party\n2. Unusual or risky clauses\n3. Missing standard provisions\n4. Recommended amendments\n\nDocument:\n{{content}}"
}Prompt templates
Prompt templates use {{variable}} placeholders that are replaced at request time from the input object sent by your application.
Template:
Review this {{document_type}} for compliance with {{jurisdiction}} law.
Document:
{{content}}Request input:
{
"document_type": "SaaS subscription agreement",
"jurisdiction": "UK",
"content": "This Agreement is entered into between..."
}Any key in input can be used as a placeholder. Unknown placeholders are left as-is and visible in the output for debugging.
Calling a custom intent
Once created, the intent is immediately callable:
POST /v1/legal-ops/contract_review
Authorization: Bearer $LIYA_API_KEY
Content-Type: application/json
{
"input": {
"user_id": "usr_123",
"document_type": "SaaS subscription agreement",
"content": "This Agreement is entered into between..."
}
}Structured output schema (optional)
To enforce a JSON output structure, provide a JSON Schema in outputSchema:
{
"intentKey": "contract_review",
"promptTemplate": "...",
"outputSchema": {
"type": "object",
"properties": {
"obligations": { "type": "array", "items": { "type": "string" } },
"risk_clauses": { "type": "array", "items": { "type": "string" } },
"missing_provisions": { "type": "array", "items": { "type": "string" } },
"risk_level": { "type": "string", "enum": ["low", "medium", "high"] }
},
"required": ["risk_level"]
}
}When a schema is provided, the engine validates the AI output against it and returns it in data.output.structuredOutput.
Intent key rules
- Lowercase letters, numbers, and underscores:
^[a-z0-9_]+$ - Must be unique within the domain
- Used as the URL path segment:
/v1/{domainKey}/{intentKey}
Updating an intent
PATCH /dashboard/custom-domains/legal-ops/intents/contract_review
{
"promptTemplate": "Updated prompt...",
"description": "Updated description"
}Updates take effect immediately on the next API call.
Archiving and deleting an intent
Archive an intent to switch it off without losing it. In the Dashboard, open the intent and choose Archive intent. Anything that calls it, including agents and workflows, gets an error until you choose Restore intent. Nothing is deleted.
DELETE /v1/domains/{domainKey}/intents/{intentKey} does the same thing as archiving: it switches the intent off. An archived intent is never removed automatically, however long it stays archived, because you can always restore it.
An archived intent keeps its key. Creating a new intent with that key returns 409 INTENT_KEY_CONFLICT, and the message says the key belongs to an archived intent:
{
"success": false,
"error": {
"code": "INTENT_KEY_CONFLICT",
"message": "Intent key 'classify_dispute' belongs to an archived intent in domain 'dispute-desk'. Restore it, or delete it permanently to use the key again."
}
}Delete permanently
If you will not use an archived intent again, or you want its key back, delete it permanently. This removes the intent and its version history, and cannot be undone.
curl -s -X DELETE "https://api.liyaengine.ai/v1/domains/dispute-desk/intents/classify_dispute?permanent=true" \
-H "Authorization: Bearer $LIYA_API_KEY"It needs a full-access API key. In the Dashboard, an owner sees Delete permanently on an archived intent, and types the intent key to confirm. Agents and workflows that call a deleted intent keep failing, so check what uses it first.