> ## Documentation Index
> Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Server-side TypeScript that runs inside Twenty — triggered by HTTP routes, cron schedules, database events, AI tools, or workflow actions.

A Twenty app's **logic layer** is the code that *runs* — server-side TypeScript handlers reacting to HTTP requests, cron schedules, and record changes; AI skills and agents that live inside the workspace; and OAuth connections that let your functions act on a user's behalf in third-party services.

```text theme={null}
            ┌─ HTTP route      ──┐
            │  Cron schedule     │
            │  Database event    │      ┌────────────────────┐
  triggers ─┤  AI tool call      ├─────▶│ Logic function     │
            │  Workflow action   │      │ (your handler)     │
            │  Manual exec       │      └────────────────────┘
            └────────────────────┘                │
                                                  ▼
                                  ┌────────────────────────────┐
                                  │ Twenty API (records)       │
                                  │ Third-party API            │
                                  │   (via Connection token)   │
                                  └────────────────────────────┘
```

## In this section

<CardGroup cols={2}>
  <Card title="Logic Functions" icon="bolt" href="/developers/extend/apps/logic/logic-functions">
    The core building block — trigger types, payloads, and the typed API client.
  </Card>

  <Card title="Skills & Agents" icon="robot" href="/developers/extend/apps/logic/skills-and-agents">
    Reusable AI agent instructions and assistants with custom system prompts.
  </Card>

  <Card title="Workflows" icon="diagram-project" href="/developers/extend/apps/logic/workflows">
    Ready-made workflows installed with your app: triggers, steps, and how they run.
  </Card>

  <Card title="Connections" icon="plug" href="/developers/extend/apps/logic/connections">
    OAuth credentials your app holds for third-party services — Linear, GitHub, Slack, and more.
  </Card>

  <Card title="Messaging Channels" icon="messages" href="/developers/extend/apps/logic/messaging-channels">
    Bring conversations from any provider into Twenty's Message and Message Thread records — threading and de-duplication included.
  </Card>

  <Card title="Key-Value Store" icon="database" href="/developers/extend/apps/logic/key-value-store">
    Persist state between logic function runs — caches, cursors, and cross-workspace claims.
  </Card>

  <Card title="Background Jobs" icon="layer-group" href="/developers/extend/apps/logic/background-jobs">
    Enqueue a logic function run on the workers to get past the per-run timeout.
  </Card>

  <Card title="Charging Credits" icon="coins" href="/developers/extend/apps/logic/credits">
    Declare what your app bills for and charge workspace credits for it.
  </Card>
</CardGroup>

## Trigger types at a glance

A logic function picks one or more triggers — every entry below is a separate field on `defineLogicFunction()`:

| Trigger | When it runs | Setting |
| - | - | - |
| **HTTP route** | A request hits your `/s/<path>` endpoint | `httpRouteTriggerSettings` |
| **Cron** | A CRON expression matches | `cronTriggerSettings` |
| **Database event** | A workspace record is created, updated, or deleted | `databaseEventTriggerSettings` |
| **AI tool** | A Twenty AI feature decides to call your function | `toolTriggerSettings` |
| **Workflow action** | A workflow step invokes your function | `workflowActionTriggerSettings` |

Functions run sandboxed in isolated Node.js processes and access the workspace through a typed API client scoped to the role declared on [`defineApplication()`](/developers/extend/apps/config/application).

<Note>
  **Install-time hooks** — code that runs before or after the install — share this runtime but use their own define functions and live under [Config → Install Hooks](/developers/extend/apps/config/install-hooks).

  The [**health check**](/developers/extend/apps/logic/logic-functions#health-check) shares it too. It declares no trigger: Twenty calls it on demand when the app's settings page opens.
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.