post https://apiprod.fattlabs.com/invoice/schedule/
Sets up a recurring or one-time schedule to generate invoices automatically based on specified parameters. This endpoint provides flexibility for creating automated billing workflows.
Key Features
- Creates a schedule to generate invoices at specified intervals using recurrence rules.
- Supports optional autopay functionality by attaching a
payment_method_id
. - Automatically recalculates the
next_run_at
time after each generated invoice or payment. - Enables merchants to include metadata like
tax
,subtotal
, andlineItems
for enhanced invoice detail. - Allows merchants to control email notifications for generated invoices.
Usage Notes
Recurring Rules
The rule
parameter follows the iCalendar RRule specification. Examples include:
- Monthly Recurrence:
DTSTART=20231101T120000Z;FREQ=MONTHLY
- Weekly Recurrence Until a Specific Date:
DTSTART=20231101T120000Z;FREQ=WEEKLY;UNTIL=20231231T000000Z;INTERVAL=1
Autopay
- If
payment_method_id
is included, payments will be attempted automatically when invoices are generated. - If no
payment_method_id
is included, customers can manually enter payment details when paying the invoice.
Email Notifications
- By default,
email_notification
is set totrue
to send emails automatically when invoices are generated. - Set
email_notification=false
to disable automatic email notifications.
Pausing and Resuming
- Pause a schedule using
PUT /invoice/schedule/{id}
and setactive=false
. This will clear thenext_run_at
date. - To resume, set
active=true
and provide a futureDTSTART
.
Response Structure
Code | Response | Reason |
---|---|---|
201 | Schedule Created | The schedule was successfully created. |
400 | Bad Request | Invalid parameters or missing required fields. |
422 | Validation Error | DTSTART is in the past, or recurrence rules are incorrectly formatted. |
500 | Internal Server Error | Unexpected server error. |
Important Considerations
- Metadata and Emails: Populate
meta
fields such assubtotal
,tax
, andlineItems
to include these details in email notifications and invoices. - Future Start Dates:
DTSTART
must be a future date; past dates are invalid. - Automatic Recalculation: The
next_run_at
time is recalculated each time an invoice is generated or paid. - Audit Trail: Each generated invoice includes timestamps and payment details for reporting purposes.
- Invoice Lifecycle: If paused, the schedule will not generate invoices until resumed with a valid future
DTSTART
.