📸 Screenshot to insert [/en/projects/codes]: the Codes tab of a project showing the project token, the data resources, and the list of Codes with the Run now button.
The three types
Job
Code that runs and finishes. Use it for ETL, a daily report, an import, a cleanup. It can be scheduled.
Service
An HTTP API with one or more endpoints. It stays up and answers calls — yours or another system’s.
Artifact
React screens using the iTeam design system. They consume your API and become a real interface inside the platform.
Data without credentials in the code
This is the part that changes how you write. A Code never carries a database address or a password: it asks for the resource and the server resolves it.Data Store (ClickHouse)
Data Store (ClickHouse)
Analytical and columnar — built for aggregation and volume. Use
datastore.query(sql).Every project gets its own database, isolated from the rest. A Code never sees another project’s Data Store.Database (Postgres)
Database (Postgres)
Relational, read and write, with
db.query(sql) and db.execute(sql). Also isolated per project.Agent resources (inherited)
Agent resources (inherited)
Add agents to the project and your Code can use their tools — MCPs, APIs, HTTP tools, and data sources — through
agent_tools().Secrets stay in the vault and are resolved server-side. Remove the agent from the project and the Code loses access immediately.The project token
Deploys happen over the API with a project token (pct_...). You’ll find it in the Codes tab, with actions to copy, rotate, and revoke.
Scheduling
A job can run on its own, at a fixed time, using cron notation:Agents calling your Code
A Code published with a contract (declared input and output) becomes a tool the project’s agents can call on their own.1
Declare the contract
Define what the Code takes and what it returns. That’s what the agent sees.
2
Publish
A published Code shows up as callable in the list.
3
The agent uses it
In a conversation, the agent decides to call your Code when the question calls for it — and uses the result in its answer.
Pick up where you left off
Code is versioned in the platform’s Git. Before touching an existing Code, run pull — so you continue instead of recreating.pull brings the entry file and the Code’s extra files. It’s the reliable way to get a faithful local copy.Good practices
Make the job idempotent
Delete the period before writing it. That way re-running the same day fixes instead of duplicating.
Aggregate at the source
GROUP BY in the query beats pulling thousands of rows into the Code.Fail with a clear message
An error output explaining what was missing beats a stack trace in the history.
Accept a date parameter
A job that only knows how to process “today” can’t backfill a missed day. Taking a date fixes that.
