Files
twenty/packages/twenty-apps/internal/self-hosting
Charles BochetandGitHub c0cc0689d6 Add Client Api generation (#17961)
## Add API client generation to SDK dev mode and refactor orchestrator
into step-based pipeline

### Why

The SDK dev mode lacked typed API client generation, forcing developers
to work without auto-generated GraphQL types when building applications.
Additionally, the orchestrator was a monolithic class that mixed watcher
management, token handling, and sync logic — making it difficult to
extend with new steps like client generation.

### How

- **Refactored the orchestrator** into a step-based pipeline with
dedicated classes: `CheckServer`, `EnsureValidTokens`,
`ResolveApplication`, `BuildManifest`, `UploadFiles`,
`GenerateApiClient`, `SyncApplication`, and `StartWatchers`. Each step
has typed input/output/status, managed by a new `OrchestratorState`
class.
- **Added `GenerateApiClientOrchestratorStep`** that detects
object/field schema changes and regenerates a typed GraphQL client (via
`@genql/cli`) into `node_modules/twenty-sdk/generated` for seamless
imports.
- **Replaced `checkApplicationExist`** with `findOneApplication` on both
server resolver and SDK API service, returning the entity data instead
of a boolean.
- **Added application token pair mutations**
(`generateApplicationToken`, `renewApplicationToken`) to the API
service, with the server now returning `ApplicationTokenPairDTO`
containing both access and refresh tokens.
- **Restructured the dev UI** into `dev/ui/components/` with dedicated
panel, section, and event log components.
- **Simplified `AppDevCommand`** from ~180 lines of watcher management
down to ~40 lines that delegate entirely to the orchestrator.
2026-02-17 18:45:52 +01:00
..
2026-01-27 20:50:19 +00:00
2025-11-21 14:10:51 +01:00
2025-11-21 14:10:51 +01:00
2025-11-21 14:10:51 +01:00
2025-11-21 14:10:51 +01:00
2026-01-27 20:50:19 +00:00
2026-01-27 20:50:19 +00:00

Self Hosting

Used to manage billing and telemetry of self-hosted instances

Requirements

  • twenty-cli npm install -g twenty-cli
  • an apiKey. Go to https://twenty.com/settings/api-webhooks to generate one

Install to your Twenty workspace

twenty auth login
twenty app sync

Environment Variables

This application requires the following environment variables to be set:

  • TWENTY_API_URL: The Twenty instance API URL where selfHostingUser records will be created
  • TWENTY_API_KEY: API key for authentication (generate at /settings/api-webhooks)

Features

Telemetry Webhook

Receives user signup telemetry events from self-hosted Twenty instances and creates/updates selfHostingUser records.

Endpoint: POST /webhook/telemetry

Payload Structure:

{
  "action": "user_signup",
  "timestamp": "2025-11-21T...",
  "version": "1",
  "payload": {
    "userId": "uuid",
    "workspaceId": "uuid",
    "payload": {
      "events": [
        {
          "userEmail": "user@example.com",
          "userId": "uuid",
          "userFirstName": "John",
          "userLastName": "Doe",
          "locale": "en",
          "serverUrl": "https://self-hosted.example.com"
        }
      ]
    }
  }
}

Response:

{
  "success": true,
  "message": "Self hosting user created/updated: uuid"
}