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

# Node.js

> Create and manage background jobs with the Rapidcron SDK

## Get your API key

To authenticate with the Rapidcron API, you need an API key. You can view and manage your API keys [here](https://rapidcron.com/app/keys).

## Install the SDK

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install rapidcron --save
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add rapidcron
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add rapidcron
    ```
  </Tab>

  <Tab title="bun">
    ```bash theme={null}
    bun add rapidcron
    ```
  </Tab>
</Tabs>

## Create a job

Start by creating a new instance of the SDK with your API key:

```ts theme={null}
import Rapidcron from "rapidcron";

const rapidcron = new Rapidcron("API_KEY");
```

And then define a task depending on whether it's a delayed or recurring task:

<Tabs>
  <Tab title="Delayed (One-off)">
    ```ts theme={null}
    await rapidcron.tasks.create({
        type: "delayed",
        nextRunAt: new Date(Date.now() + 1000 * 60 * 60), // 1 hour from now
        request: {
            method: "POST",
            url: "https://example.com",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify({
                hello: "world"
            })
        }
    });
    ```
  </Tab>

  <Tab title="Recurring">
    Recurring tasks use [cron expressions](/learn/cron-expressions) to define the schedule.

    ```ts theme={null}
    await rapidcron.tasks.create({
        type: "recurring",
        recurrencePattern: "* * * * *", // Every minute
        request: {
            method: "POST",
            url: "https://example.com",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify({
                hello: "world"
            })
        }
    });
    ```
  </Tab>
</Tabs>
