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

# Cron Node SDK

> Use @pxxlapp/pxxl to manage scheduled HTTP cron jobs from Node.js.

Install the official SDK:

```bash theme={null}
npm install @pxxlapp/pxxl
```

```ts theme={null}
import { PxxlClient, isPlanGateError } from '@pxxlapp/pxxl';

const pxxl = new PxxlClient({ apiKey: process.env.PXXL_API_KEY! });
```

Use `scope=cron`, `scope=cronjobs`, or `scope=all`. Read methods work with `permission=read`; mutations and manual triggers require `permission=read_write`.

## Create a Job

```ts theme={null}
const job = await pxxl.createCronJob({
  name: 'cache warmer',
  schedule: '*/5 * * * *',
  url: 'https://example.com/api/warm-cache',
  method: 'POST',
  timeoutSeconds: 10,
  headers: {
    'User-Agent': 'Pxxl-Cron/1.0',
  },
});

console.log(job.id);
```

## List and Inspect

```ts theme={null}
const { cronJobs } = await pxxl.listCronJobs();
const job = await pxxl.getCronJob(cronJobs[0].id);
const runs = await pxxl.listCronJobRuns(job.id, { page: 1, limit: 20 });
```

## Control Jobs

```ts theme={null}
await pxxl.stopCronJob(job.id);
await pxxl.startCronJob(job.id);
await pxxl.triggerCronJob(job.id);
await pxxl.deleteCronJob(job.id);
```

## Validate Inputs

```ts theme={null}
await pxxl.validateCronSchedule('*/5 * * * *');
await pxxl.validateCronURL('https://example.com/job');
```

Pxxl accepts 5-field cron expressions, public `http` or `https` URLs, and `GET`, `POST`, `PUT`, `PATCH`, or `DELETE`. Private and reserved IP targets are blocked before a job is saved.

## Plan Limit Errors

If your account exceeds the cron job limit, the SDK throws `PxxlAPIError` with structured details:

```ts theme={null}
try {
  await pxxl.createCronJob({
    name: 'extra job',
    schedule: '*/5 * * * *',
    url: 'https://example.com/job',
  });
} catch (error) {
  if (isPlanGateError(error)) {
    console.log(error.code, error.limit, error.current, error.requiredPlan);
  }
}
```


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