{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/recurly/json-schema/recurly-dunning-campaign-schema.json",
  "title": "DunningCampaign",
  "description": "Settings for a dunning campaign.",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/recurly-recover-openapi.yml#/components/schemas/DunningCampaign",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "object": {
      "type": "string",
      "title": "Object type"
    },
    "code": {
      "type": "string",
      "description": "Campaign code."
    },
    "name": {
      "type": "string",
      "description": "Campaign name."
    },
    "description": {
      "type": "string",
      "description": "Campaign description."
    },
    "default_campaign": {
      "type": "boolean",
      "description": "Whether or not this is the default campaign for accounts or plans without an assigned dunning campaign."
    },
    "dunning_cycles": {
      "type": "array",
      "description": "Dunning Cycle settings.",
      "items": {
        "$ref": "#/$defs/DunningCycle"
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the current campaign was created in Recurly."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the current campaign was updated in Recurly."
    },
    "deleted_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the current campaign was deleted in Recurly."
    }
  },
  "$defs": {
    "DunningCycle": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "The type of invoice this cycle applies to.",
          "enum": [
            "automatic",
            "manual",
            "trial"
          ]
        },
        "applies_to_manual_trial": {
          "type": "boolean",
          "description": "Whether the dunning settings will be applied to manual trials. Only applies to trial cycles."
        },
        "first_communication_interval": {
          "type": "integer",
          "description": "The number of days after a transaction failure before the first dunning email is sent."
        },
        "send_immediately_on_hard_decline": {
          "type": "boolean",
          "description": "Whether or not to send an extra email immediately to customers whose initial payment attempt fails with either a hard decline or invalid billing info."
        },
        "intervals": {
          "type": "array",
          "description": "Dunning intervals.",
          "items": {
            "$ref": "#/$defs/DunningInterval"
          }
        },
        "expire_subscription": {
          "type": "boolean",
          "description": "Whether the subscription(s) should be cancelled at the end of the dunning cycle."
        },
        "fail_invoice": {
          "type": "boolean",
          "description": "Whether the invoice should be failed at the end of the dunning cycle."
        },
        "total_dunning_days": {
          "type": "integer",
          "description": "The number of days between the first dunning email being sent and the end of the dunning cycle."
        },
        "total_recycling_days": {
          "type": "integer",
          "description": "The number of days between a transaction failure and the end of the dunning cycle."
        },
        "version": {
          "type": "integer",
          "description": "Current campaign version."
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the current settings were created in Recurly."
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the current settings were updated in Recurly."
        }
      }
    },
    "DunningInterval": {
      "type": "object",
      "properties": {
        "days": {
          "type": "integer",
          "description": "Number of days before sending the next email."
        },
        "email_template": {
          "type": "string",
          "description": "Email template being used."
        },
        "email_template_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "The id of the custom email template assigned to this interval, from `GET /dunning_campaigns/email_templates`. `null` means the system default template for this interval. Accepted on write; round-tripped on read."
        }
      }
    }
  }
}