Frappe Syntax Whitelisted logo

Frappe Syntax Whitelisted

Organization
Impertio-Studio
frappe-syntax-whitelisted

Use when creating Frappe Whitelisted Methods (Python API endpoints) for v14/v15/v16. Covers @frappe.whitelist() decorator, frappe.call/frm.call invocations, permission checks, error handling, response formats, and client-server communication. Keywords: whitelisted, API endpoint, frappe.call, frm.call, REST API, @frappe.whitelist, allow_guest, API endpoint example, frappe.whitelist syntax, how to expose function.

Overview

PublisherImpertio-Studio
RepositoryFrappe_Claude_Skill_Package
Skill namefrappe-syntax-whitelisted
Stars
180
Forks
53
Bundled files
12
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 12 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Impertio-Studio on GitHub. Read the source before you install it.

Installation

Install the Frappe Syntax Whitelisted AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package.git /tmp/Frappe_Claude_Skill_Package
mkdir -p .claude/skills
cp -r /tmp/Frappe_Claude_Skill_Package/skills/source/syntax/frappe-syntax-whitelisted .claude/skills/frappe-syntax-whitelisted
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Frappe Syntax Whitelisted in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Frappe Syntax Whitelisted on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Frappe Syntax Whitelisted is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Frappe Syntax: Whitelisted Methods

Whitelisted methods expose Python functions as HTTP API endpoints via /api/method/.

Quick Reference

python
import frappe
from frappe import _

# Authenticated endpoint (default)
@frappe.whitelist()
def get_customer_summary(customer):
    frappe.has_permission("Customer", "read", throw=True)
    return frappe.get_doc("Customer", customer).as_dict()

# Public endpoint — ALWAYS validate input thoroughly
@frappe.whitelist(allow_guest=True, methods=["POST"])
def submit_contact(name, email, message):
    if not name or not email:
        frappe.throw(_("Name and email required"), frappe.ValidationError)
    return {"success": True}

# Controller method — called via frm.call('method_name')
class SalesOrder(Document):
    @frappe.whitelist()
    def calculate_taxes(self, include_shipping=False):
        return {"tax": self.grand_total * 0.21}

Endpoint URL: /api/method/myapp.module.function_name


Decorator Signature [v14+]

python
@frappe.whitelist(
    allow_guest=False,   # True = accessible without login
    xss_safe=False,      # True = do NOT escape HTML in response
    methods=None,        # ["GET"], ["POST"], or ["GET","POST"] — default: all
    force_types=None     # True = require type annotations [v15+]
)
ParameterDefaultEffect
allow_guestFalseTrue = Guest role can call; ALWAYS add extra input validation
xss_safeFalseTrue = HTML not escaped; NEVER use without sanitized output
methodsNone (all)Restrict allowed HTTP verbs
force_typesNoneTrue = all params MUST have type annotations [v15+]

Full details: decorator-options.md


Decision Tree

What kind of endpoint?
|
+-- Standalone API (utility, integration, dashboard)?
|   --> @frappe.whitelist() on a module-level function
|   --> Call via: frappe.call('myapp.api.function')
|   --> URL: /api/method/myapp.api.function
|
+-- Document-specific action?
|   --> @frappe.whitelist() on a Document class method
|   --> Call via: frm.call('method_name')
|   --> URL: /api/method/run_doc_method (internal)
|
+-- Server Script (no-code)?
    --> Use Server Script DocType instead (no decorator needed)

Who may call the API?
|
+-- Anyone (including guests)?
|   --> allow_guest=True + thorough input validation + rate limiting
|
+-- Logged-in users only?
    +-- Specific role? --> frappe.only_for("RoleName")
    +-- DocType-level? --> frappe.has_permission(doctype, ptype, throw=True)
    +-- Document-level? --> frappe.has_permission(doctype, ptype, doc, throw=True)

Which HTTP methods?
|
+-- Read only? --> methods=["GET"]
+-- Write only? --> methods=["POST"]
+-- Both? --> methods=["GET","POST"] or default

Permission Patterns

ALWAYS check permissions inside every whitelisted method. The @frappe.whitelist() decorator only verifies the user is logged in — it does NOT check DocType or document-level permissions.

python
# DocType-level permission (throw=True raises PermissionError automatically)
@frappe.whitelist()
def get_orders():
    frappe.has_permission("Sales Order", "read", throw=True)
    return frappe.get_all("Sales Order", limit=20)

# Document-level permission
@frappe.whitelist()
def get_order(name):
    frappe.has_permission("Sales Order", "read", name, throw=True)
    return frappe.get_doc("Sales Order", name).as_dict()

# Role-based restriction
@frappe.whitelist()
def admin_action():
    frappe.only_for("System Manager")  # throws if user lacks role
    return {"secret": "data"}

Full patterns: permission-patterns.md


Parameter Handling

Parameters arrive as strings from HTTP requests. ALWAYS convert explicitly.

python
@frappe.whitelist()
def calculate(amount, quantity, items=None):
    amount = float(amount)          # ALWAYS cast numeric params
    quantity = int(quantity)
    if isinstance(items, str):      # ALWAYS parse JSON strings
        items = frappe.parse_json(items)
    return amount * quantity

Access all request parameters via frappe.form_dict:

python
@frappe.whitelist()
def dynamic_handler():
    all_params = frappe.form_dict
    customer = frappe.form_dict.get("customer")

Type Annotations [v15+]

Frappe v15+ validates type annotations automatically at request time via Pydantic:

python
@frappe.whitelist()
def get_orders(customer: str, limit: int = 10, active: bool = True) -> dict:
    # Frappe auto-validates: limit MUST be convertible to int
    return {"orders": frappe.get_all("Sales Order", limit=limit)}

force_types and require_type_annotated_api_methods [v15+]

  • @frappe.whitelist(force_types=True) — EVERY parameter MUST have a type annotation
  • App-level enforcement via hooks.py: require_type_annotated_api_methods = 1
  • Missing annotations raise FrappeTypeError

Full details: parameter-handling.md


Client Calls

frappe.call(): Standalone APIs

javascript
// Promise-based (ALWAYS prefer this)
frappe.call({
    method: 'myapp.api.get_summary',
    args: { customer: 'CUST-001' },
    freeze: true,
    freeze_message: __('Loading...')
}).then(r => {
    console.log(r.message);  // return value is in r.message
}).catch(err => {
    frappe.show_alert({ message: __('Error'), indicator: 'red' });
});

frm.call(): Controller Methods

javascript
frm.call('calculate_taxes', { include_shipping: true })
    .then(r => frm.set_value('tax_amount', r.message.tax_amount));

REST API (External Clients)

bash
# Token auth (ALWAYS use for external integrations)
curl -H "Authorization: token api_key:api_secret" \
     -H "Content-Type: application/json" \
     -X POST https://site.com/api/method/myapp.api.create_order \
     -d '{"customer": "CUST-001"}'

Full patterns: client-calls.md


Error Handling

python
@frappe.whitelist()
def process_order(order_id):
    if not order_id:
        frappe.throw(_("Order ID required"), frappe.ValidationError)

    if not frappe.has_permission("Sales Order", "write", order_id):
        frappe.throw(_("Not permitted"), frappe.PermissionError)

    try:
        result = heavy_operation(order_id)
        return {"success": True, "data": result}
    except Exception:
        frappe.log_error(frappe.get_traceback(), "process_order")
        frappe.throw(_("Operation failed. Contact support."))
ExceptionHTTP CodeWhen to Use
frappe.ValidationError417Input validation failure
frappe.PermissionError403Access denied
frappe.DoesNotExistError404Document not found
frappe.DuplicateEntryError409Duplicate record
frappe.AuthenticationError401Not logged in

Full patterns: error-handling.md


Response Patterns

python
# Return value auto-wraps as {"message": <return_value>}
@frappe.whitelist()
def get_data():
    return {"key": "value"}   # Client receives: {"message": {"key": "value"}}

# Custom HTTP status
@frappe.whitelist()
def create_item(data):
    doc = frappe.get_doc(data).insert()
    frappe.local.response["http_status_code"] = 201
    return {"name": doc.name}

# File download
@frappe.whitelist()
def download_report(name):
    content = generate_pdf(name)
    frappe.response.filename = f"{name}.pdf"
    frappe.response.filecontent = content
    frappe.response.type = "download"

Full patterns: response-patterns.md


Rate Limiting [v14+]

python
from frappe.rate_limiter import rate_limit

@frappe.whitelist(allow_guest=True)
@rate_limit(limit=5, seconds=60)  # 5 requests per 60 seconds per IP
def public_endpoint():
    return {"status": "ok"}

rate_limit signature:

python
rate_limit(key=None, limit=5, seconds=86400, methods="ALL", ip_based=True)

ALWAYS apply @rate_limit on allow_guest=True endpoints to prevent abuse.


Version Differences

Featurev14v15+v16+
@frappe.whitelist()YesYesYes
allow_guest, xss_safe, methodsYesYesYes
Type annotation validationNoYes (auto via Pydantic)Yes
force_types parameterNoYesYes
require_type_annotated_api_methods hookNoYesYes
@rate_limit() decoratorYesYesYes
FrappeTypeError for missing annotationsNoYesYes

Critical Rules

  1. NEVER skip permission checks@frappe.whitelist() only confirms login, not authorization
  2. NEVER use user input in raw SQL — ALWAYS use parameterized queries or ORM
  3. NEVER leak stack traces — log with frappe.log_error(), show generic messages
  4. ALWAYS validate input types — parameters arrive as strings from HTTP
  5. ALWAYS apply @rate_limit on guest endpoints — prevents abuse
  6. NEVER use ignore_permissions=True without a preceding role check
  7. ALWAYS use JSON.stringify() for complex JS args — arrays and objects

Full anti-patterns: anti-patterns.md


Security Checklist

For EVERY whitelisted method, verify:

  • Permission check present (frappe.has_permission() or frappe.only_for())
  • Input validated (types, ranges, formats)
  • SQL queries parameterized (NEVER string interpolation)
  • Error messages contain no internal details
  • allow_guest=True only with explicit reason + rate limiting
  • ignore_permissions=True only with preceding role check
  • HTTP methods restricted where possible
  • Response contains only necessary fields (no sensitive data leaks)

Reference Files

FileContent
decorator-options.mdAll @frappe.whitelist() parameters and force_types
parameter-handling.mdRequest parameters, type coercion, frappe.form_dict
response-patterns.mdReturn types, file downloads, streaming, HTTP status
client-calls.mdfrappe.call(), frm.call(), REST API, fetch patterns
permission-patterns.mdPermission checks, role guards, custom logic
error-handling.mdException types, frappe.throw(), logging
examples.mdComplete working API examples
anti-patterns.mdSecurity mistakes and performance pitfalls
hooks.mdDeclaring whitelisted methods in hooks.py
syntax.mdCore decorator syntax and registration mechanics

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Frappe Syntax Whitelisted AI skill do?

Use when creating Frappe Whitelisted Methods (Python API endpoints) for v14/v15/v16. Covers @frappe.whitelist() decorator, frappe.call/frm.call invocations, permission checks, error handling, response formats, and client-server communication. Keywords: whitelisted, API endpoint, frappe.call, frm.call, REST API, @frappe.whitelist, allow_guest, API endpoint example, frappe.whitelist syntax, how to expose function.

Why use Frappe Syntax Whitelisted on TypingMind?

Because you install it once and use it with any model. Frappe Syntax Whitelisted is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Frappe Syntax Whitelisted in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package/tree/main/skills/source/syntax/frappe-syntax-whitelisted. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Frappe Syntax Whitelisted?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Frappe Syntax Whitelisted?

As many as you like. As long as a model supports skills, you can use Frappe Syntax Whitelisted with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Frappe Syntax Whitelisted AI skill free?

Yes. It is published on GitHub by Impertio-Studio under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇