REST API

Subscriptions API

Recurring document and subscription API for invoice and purchase-order templates, scheduling, activation, pausing, resuming, cancellation, and on-demand generation.

Generated from the Celerp 2.9.0 OpenAPI schema, .

GET /subscriptions

List Recurring Document Templates

Return recurring document templates matching the documented filters and pagination options.

Parameters

NameInRequiredTypeDescription
directionquery--string, optionalSort or schedule direction supported by the subscriptions endpoint.
statusquery--string, optionalRecord or workflow status used to filter results or select the requested lifecycle state.
qquery--string, optionalSearch text used to filter matching records.
reviewquery--booleanWhen true, return only agreements with earlier documents waiting for history review.
limitquery--integerMaximum number of records to return.
offsetquery--integerNumber of matching records to skip before returning results.

Responses

StatusDescriptionBody
200Returns the requested recurring document templates.object
422The request failed validation. The response lists each invalid field and why.HTTPValidationError

Example

curl -X GET http://localhost:8000/subscriptions \
  -H "Authorization: Bearer $TOKEN"

GET /subscriptions/catch-up

Catch Up

Unattended agreements further behind than their catch-up window.

Responses

StatusDescriptionBody
200Successful Responseobject

Example

curl -X GET http://localhost:8000/subscriptions/catch-up \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/catch-up/run

Catch Up Run

Bill the chosen periods from the catch-up preview, in order. An item is billed only when the preview lists it and it is its agreement's oldest open period. A refused item says why, the agreement's own state first (paused, cancelled, no schedule) before that it left the preview, and names its period's dates when the schedule gives them.

Request body

FieldTypeRequiredDescription
itemsarray of CatchUpItemyesItems

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/catch-up/run \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

GET /subscriptions/due

List Due

Every active agreement with a period due today: what Generate due would bill.

Responses

StatusDescriptionBody
200Successful Responseobject

Example

curl -X GET http://localhost:8000/subscriptions/due \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/generate-due

Generate All Due

Bill the oldest due period of each listed agreement, each on its own: one refusal never stops the rest. A period billed before this request counts as already billed, never as billed.

Request body

FieldTypeRequiredDescription
itemsarray of CatchUpItemyesItems

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/generate-due \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

GET /subscriptions/summary

Get Summary

What unattended billing did: each bill and email of the last 90 days, and each billing failure, lapsed authorization and email waiting to go out while it lasts, each row with the ``key`` Mark as read posts for it (none for a row shown while it lasts): every row but those this user marked read (``all``: every row).

Parameters

NameInRequiredTypeDescription
allquery--booleanWhen true, return everything unattended billing recorded, not only what came after this user last marked the summary read.

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X GET http://localhost:8000/subscriptions/summary \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/summary/ack

Ack Summary

Mark read the rows the page showed (each row's ``key`` from GET /summary); a key of no row there now is ignored.

Request body

FieldTypeRequiredDescription
keysarray of stringyesKeys

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/summary/ack \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

POST /subscriptions/{entity_id}/activate

Activate Recurring Document

Activate a draft recurring document and schedule its first run.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.

Responses

StatusDescriptionBody
200Returns `ok: true` and the next date a document will be generated.object
422The request failed validation. The response lists each invalid field and why.HTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/activate \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/{entity_id}/bill-early

Bill Early

Bill the next period ahead of its bill date; only the oldest open one.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.

Request body

FieldTypeRequiredDescription
request_keystringyesRequest Key
period_indexinteger, optional--Period Index

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/bill-early \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

POST /subscriptions/{entity_id}/cancel

Cancel Recurring Document

Cancel a recurring document. No further documents are generated.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.

Responses

StatusDescriptionBody
200Returns `ok: true` when the change is saved.object
422The request failed validation. The response lists each invalid field and why.HTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/cancel \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/{entity_id}/generate-due

Generate Due

Bill the agreement's oldest due period.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.

Request body

FieldTypeRequiredDescription
request_keystringyesRequest Key
period_indexinteger, optional--Period Index

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/generate-due \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

POST /subscriptions/{entity_id}/history/{doc_id}/confirm

Confirm History

Place an earlier document in one of its candidate periods.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
doc_idpathyesstringIdentifier of the earlier document waiting in the agreement's history review.

Request body

FieldTypeRequiredDescription
period_indexintegeryesPeriod Index

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/history/:doc_id/confirm \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

POST /subscriptions/{entity_id}/history/{doc_id}/set-aside

Set Aside History

Record that an earlier document billed no period of its own (a duplicate, or one that no longer exists), so review can finish without it.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
doc_idpathyesstringIdentifier of the earlier document waiting in the agreement's history review.

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/history/:doc_id/set-aside \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/{entity_id}/history/{doc_id}/withdraw

Withdraw History

Undo a placement or a set-aside while no later period is billed: the document waits for review again. On an ENDED agreement a placement is final like a bill, and a set-aside always goes back.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
doc_idpathyesstringIdentifier of the earlier document placed in a period or set aside in the agreement's history review.

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/history/:doc_id/withdraw \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/{entity_id}/pause

Pause Recurring Document

Pause a recurring document. No documents are generated until it is resumed.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.

Responses

StatusDescriptionBody
200Returns `ok: true` when the change is saved.object
422The request failed validation. The response lists each invalid field and why.HTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/pause \
  -H "Authorization: Bearer $TOKEN"

GET /subscriptions/{entity_id}/periods

List Periods

The agreement's periods, newest first, and its next bill date.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
beforequery--integer, optionalReturn periods before this period index.

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X GET http://localhost:8000/subscriptions/:entity_id/periods \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/{entity_id}/periods/{k}/reopen

Reopen Period

Open a billed period again once its document no longer bills it (void, or back in draft), so it can be billed once more. Unvoiding or finalizing that document undoes it while no newer bill bills the period (billing.guard_bill_status).

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
kpathyesintegerIndex of the billing period: 0 is the period starting on the first bill date, and each later period counts up by one.

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/periods/:k/reopen \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/{entity_id}/periods/{k}/send

Send Period

Send period ``k``'s document again after a failed or cut-off send (``again``: a new message for one that may already have arrived). ``attempt`` is the stored attempt the user saw, so the same click arriving twice sends once; answered with how its email reads now.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
kpathyesintegerIndex of the billing period: 0 is the period starting on the first bill date, and each later period counts up by one.

Request body

FieldTypeRequiredDescription
attemptintegeryesAttempt
againboolean--Again

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/periods/:k/send \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

POST /subscriptions/{entity_id}/periods/{k}/skip

Skip Period

Record that period ``k`` is not billed, and why.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
kpathyesintegerIndex of the billing period: 0 is the period starting on the first bill date, and each later period counts up by one.

Request body

FieldTypeRequiredDescription
reasonstring--Reason

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/periods/:k/skip \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

POST /subscriptions/{entity_id}/periods/{k}/unskip

Unskip Period

Undo a skip: the period is open again.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.
kpathyesintegerIndex of the billing period: 0 is the period starting on the first bill date, and each later period counts up by one.

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/periods/:k/unskip \
  -H "Authorization: Bearer $TOKEN"

POST /subscriptions/{entity_id}/resume

Resume Recurring Document

Resume a paused recurring document and schedule its next run.

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.

Responses

StatusDescriptionBody
200Returns `ok: true` and the next date a document will be generated.object
422The request failed validation. The response lists each invalid field and why.HTTPValidationError

Example

curl -X POST http://localhost:8000/subscriptions/:entity_id/resume \
  -H "Authorization: Bearer $TOKEN"

PATCH /subscriptions/{entity_id}/schedule

Change Schedule

Change the agreement's schedule terms and unattended modes. Bringing a mode into force, or changing the terms of one that runs, asks for its consent where every agreement write does (billing.write_agreement). Choosing automatic billing asks the bill path first (billing.bill_refusal).

Parameters

NameInRequiredTypeDescription
entity_idpathyesstringIdentifier of the requested Celerp record.

Request body

FieldTypeRequiredDescription
anchor_datestring, optional--Anchor Date
frequencystring, optional--Frequency
custom_interval_daysinteger, optional--Custom Interval Days
billing_timingstring, optional--Billing Timing
term_startstring, optional--Term Start
term_endstring, optional--Term End
cancel_at_period_endboolean, optional--Cancel At Period End
catchup_periodsinteger, optional--Catchup Periods
generation_modestring, optional--Generation Mode
auto_sendboolean, optional--Auto Send

Responses

StatusDescriptionBody
200Successful Responseobject
422Validation ErrorHTTPValidationError

Example

curl -X PATCH http://localhost:8000/subscriptions/:entity_id/schedule \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'