Sure, here's an example of how to include retry attempts using the NextCron API:

To add retry attempts to your job, you can include the "attempts" option in your job configuration. The value of "attempts" should be an integer representing the number of retry attempts you want to allow for the job.

Here's an example payload that includes a job configuration with 3 retry attempts:

import axios from 'axios';'', {
  "topic": "create-todo",
  "target": "",
  "method": "POST",
  "data": {
    "title": "foo",
    "body": "bar",
    "userId": 1
  "options": {
    "attempts": 3
}, {
  headers: {
    'X-NextCron-Token': "<insert_your_api_token>"

In this example, the job topic is "import-post", the target is "http://localhost:3000/api/v1/hello", and the HTTP method is "POST". The "attempts" option is set to 3, which means that the job will be retried up to 3 times if it fails.

You can customize the retry logic further by including a "backoff" option, which determines the delay between each retry attempt. By default, the delay increases exponentially with each attempt, but you can customize this behavior by including a "backoff" option with your desired configuration.

If a job exceeds the maximum number of retry attempts and still fails, it will be marked as failed and you will be notified via email, as long as you have configured email notifications in your account settings.

We hope this helps you get started with adding retry attempts to your NextCron jobs. If you have any questions or need further assistance, please don't hesitate to contact us at [email protected].

Last updated