# Routines

A **routine** binds an [agent](/concepts/agents) to a trigger: **cron** (schedule), **webhook** (HTTP), or **API** (explicit). When a trigger fires, Ren starts a [session](/concepts/sessions).

## Create a routine

```ts
const { data: routine } = await client.pod.routine.create({
  path: { podId },
  body: {
    projectId,
    projectAgentId,
    name: "Nightly digest",
    prompt: "Summarise yesterday's sessions.",
  },
})
```

`projectAgentId` is the id returned when you
[link an agent into a project](/concepts/agents#link-an-agent-into-a-project).

## Attach a cron trigger

```ts
await client.pod.routine.cronTrigger.create({
  path: { podId, id: routine.id },
  body: { schedule: "0 9 * * *", timezone: "UTC" },
})
```

The equivalent namespaces exist for webhook and API triggers:
`client.pod.routine.webhookTrigger.*` and
`client.pod.routine.apiTrigger.*`.

## Pause and resume

```ts
await client.pod.routine.pause({ path: { podId, id: routine.id } })
await client.pod.routine.resume({ path: { podId, id: routine.id } })
```

## Related

- **[Sessions](/concepts/sessions)** — what a fired routine produces.
- **[Schedule a routine](/guides/scheduling-a-routine)** — end-to-end
  walkthrough.
- **API reference:** [Routines](/api-reference#tag/routine)