Skip to content

Preview the next occurrences of a candidate schedule

POST
/v1/recurring-invoices/preview-next-runs
curl --request POST \
--url https://api.emite.cr/v1/recurring-invoices/preview-next-runs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "schedule": { "frequency": "daily", "interval": 1, "startDate": "2026-06-01", "endDate": "2027-06-01", "dayOfMonth": 15, "endOfMonthRule": "last_day_when_missing", "weekday": 1, "maxOccurrences": 12, "autoSubmit": true }, "count": 6, "from": "2026-06-01" }'

Computes the next N occurrence dates for a schedule config WITHOUT persisting anything. Powers the "next emissions" widget in the create/edit form. Returns { runs: string[] } where each entry is a YYYY-MM-DD date.

Media typeapplication/json
object
schedule
required

The cadence to preview, in the shape of a schedule body. Nothing is saved.

object
frequency
required

How often an invoice is created, every interval units:

  • daily: counted in days from startDate.
  • weekly: on weekday.
  • monthly: on dayOfMonth.
  • yearly: in the month of startDate, on dayOfMonth.
string
Allowed values: daily weekly monthly yearly
Example
monthly
interval

Every how many frequency units an invoice is created: 2 with monthly means every other month. An integer, 1 or more; 1 when omitted.

number
default: 1 >= 1
Example
1
startDate
required

Anchor of the cadence, a calendar date (YYYY-MM-DD) in Costa Rica time: occurrences are counted from it. The first run is the first occurrence on or after both this date and today.

string
Example
2026-06-01
endDate

Last date an occurrence may fall on (YYYY-MM-DD, inclusive). The schedule becomes completed once its next occurrence would come after it, and one whose first occurrence already does is created completed.

string
Example
2027-06-01
dayOfMonth

Day of the month for monthly and yearly schedules; defaults to the day of startDate. For a month without that day see endOfMonthRule. Ignored for daily and weekly.

number
>= 1 <= 31
Example
15
endOfMonthRule

How monthly and yearly schedules pick the day:

  • last_day_when_missing (default): dayOfMonth, or the last day of a month that does not have it (31 becomes 30, or 28/29 in February).
  • last_day_always: always the last day of the month, whatever dayOfMonth says.

Ignored for daily and weekly.

string
Allowed values: last_day_when_missing last_day_always
Example
last_day_when_missing
weekday

Day of the week for weekly schedules, 0 Sunday to 6 Saturday; defaults to the weekday of startDate. The first occurrence is the first such day on or after startDate. Ignored for the other frequencies.

number
<= 6
Example
1
maxOccurrences

Maximum number of occurrences: the schedule becomes completed after that many. An occurrence that failed for good also counts.

number
>= 1
Example
12
autoSubmit

true (default): each invoice is signed and sent to Hacienda as soon as it is created, which needs a caller holding invoices:sign and invoices:submit (403 RECURRING_AUTO_SUBMIT_REQUIRES_SUBMIT_SCOPE). false: each invoice is left as a draft for someone to review and send.

boolean
default: true
Example
true
count

How many dates to return.

number
default: 6 >= 1 <= 36
Example
6
from

First date to consider (YYYY-MM-DD); defaults to the later of startDate and today in Costa Rica. The preview lists the dates of the cadence only: it does not stop at endDate or maxOccurrences.

string
Example
2026-06-01
Media typeapplication/json
object
runs
required

The next occurrence dates of the cadence (YYYY-MM-DD), oldest first, as many as count asks.

Array<string>
Example
{
"runs": [
"2026-11-01",
"2026-12-01",
"2027-01-01"
]
}

Missing or invalid JWT / API key