> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.mercoa.com/embedded-ap-ar/guides/accounts-payable/recurring-payments/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server. ## [API Reference](/api-reference/invoice-template/create) Recurring payments allow your customers to make payments on a custom schedule from a single invoice template. Once set up, the system automatically creates and processes invoices according to your specified payment schedule. ## How Recurring Payments Work Recurring payments are created by creating an [invoice template](/api-reference/invoice-template/create) and then updating it to the `SCHEDULED` status. Invoice templates *create* [invoices](/accounts-payable/invoices) on a custom schedule to pay each recurring payment. To use recurring payments, you must: 1. [Create](/api-reference/invoice-template/create) an invoice template. ### Request POST [https://api.mercoa.com/invoice-template](https://api.mercoa.com/invoice-template) **`Create an invoice template`** ```curl Create an invoice template curl -X POST https://api.mercoa.com/invoice-template \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "amount": 100, "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "currency": "USD", "deductionDate": "2021-01-10T00:00:00Z", "dueDate": "2021-01-13T00:00:00Z", "invoiceDate": "2021-01-01T00:00:00Z", "invoiceNumber": "INV-123", "lineItems": [ { "amount": 100, "category": "EXPENSE", "currency": "USD", "description": "Product A", "glAccountId": "600394", "metadata": { "key1": "value1", "key2": "value2" }, "name": "Product A", "quantity": 1, "serviceEndDate": "2021-01-31T00:00:00Z", "serviceStartDate": "2021-01-01T00:00:00Z", "unitPrice": 100 } ], "noteToSelf": "Monthly recurring payment", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "paymentDestinationOptions": { "type": "check", "delivery": "MAIL", "printDescription": true }, "paymentSchedule": { "type": "monthly", "repeatOnDay": 10, "ends": "2021-01-01T00:00:00Z" }, "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "status": "NEW", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d" }' ``` **`Create an invoice template`** ```python Create an invoice template import requests url = "https://api.mercoa.com/invoice-template" payload = { "amount": 100, "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "currency": "USD", "deductionDate": "2021-01-10T00:00:00Z", "dueDate": "2021-01-13T00:00:00Z", "invoiceDate": "2021-01-01T00:00:00Z", "invoiceNumber": "INV-123", "lineItems": [ { "amount": 100, "category": "EXPENSE", "currency": "USD", "description": "Product A", "glAccountId": "600394", "metadata": { "key1": "value1", "key2": "value2" }, "name": "Product A", "quantity": 1, "serviceEndDate": "2021-01-31T00:00:00Z", "serviceStartDate": "2021-01-01T00:00:00Z", "unitPrice": 100 } ], "noteToSelf": "Monthly recurring payment", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "paymentDestinationOptions": { "type": "check", "delivery": "MAIL", "printDescription": True }, "paymentSchedule": { "type": "monthly", "repeatOnDay": 10, "ends": "2021-01-01T00:00:00Z" }, "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "status": "NEW", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create an invoice template`** ```typescript Create an invoice template import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.invoiceTemplate.create({ status: "NEW", amount: 100, currency: "USD", invoiceDate: new Date("2021-01-01T00:00:00.000Z"), dueDate: new Date("2021-01-13T00:00:00.000Z"), deductionDate: new Date("2021-01-10T00:00:00.000Z"), paymentSchedule: { type: "monthly", repeatOnDay: 10, ends: new Date("2021-01-01T00:00:00.000Z") }, invoiceNumber: "INV-123", noteToSelf: "Monthly recurring payment", payerId: "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", paymentSourceId: "pm_4794d597-70dc-4fec-b6ec-c5988e759769", vendorId: "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", paymentDestinationId: "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", paymentDestinationOptions: { type: "check", delivery: "MAIL", printDescription: true }, lineItems: [{ amount: 100, currency: "USD", description: "Product A", name: "Product A", quantity: 1, unitPrice: 100, category: "EXPENSE", serviceStartDate: new Date("2021-01-01T00:00:00.000Z"), serviceEndDate: new Date("2021-01-31T00:00:00.000Z"), metadata: { "key1": "value1", "key2": "value2" }, glAccountId: "600394" }], creatorEntityId: "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", creatorUserId: "user_e24fc81c-c5ee-47e8-af42-4fe29d895506" }); ``` **`Create an invoice template`** ```go Create an invoice template package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/invoice-template" payload := strings.NewReader("{\n \"amount\": 100,\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"currency\": \"USD\",\n \"deductionDate\": \"2021-01-10T00:00:00Z\",\n \"dueDate\": \"2021-01-13T00:00:00Z\",\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"invoiceNumber\": \"INV-123\",\n \"lineItems\": [\n {\n \"amount\": 100,\n \"category\": \"EXPENSE\",\n \"currency\": \"USD\",\n \"description\": \"Product A\",\n \"glAccountId\": \"600394\",\n \"metadata\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n },\n \"name\": \"Product A\",\n \"quantity\": 1,\n \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n \"unitPrice\": 100\n }\n ],\n \"noteToSelf\": \"Monthly recurring payment\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"paymentDestinationOptions\": {\n \"type\": \"check\",\n \"delivery\": \"MAIL\",\n \"printDescription\": true\n },\n \"paymentSchedule\": {\n \"type\": \"monthly\",\n \"repeatOnDay\": 10,\n \"ends\": \"2021-01-01T00:00:00Z\"\n },\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"status\": \"NEW\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create an invoice template`** ```ruby Create an invoice template require 'uri' require 'net/http' url = URI("https://api.mercoa.com/invoice-template") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"amount\": 100,\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"currency\": \"USD\",\n \"deductionDate\": \"2021-01-10T00:00:00Z\",\n \"dueDate\": \"2021-01-13T00:00:00Z\",\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"invoiceNumber\": \"INV-123\",\n \"lineItems\": [\n {\n \"amount\": 100,\n \"category\": \"EXPENSE\",\n \"currency\": \"USD\",\n \"description\": \"Product A\",\n \"glAccountId\": \"600394\",\n \"metadata\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n },\n \"name\": \"Product A\",\n \"quantity\": 1,\n \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n \"unitPrice\": 100\n }\n ],\n \"noteToSelf\": \"Monthly recurring payment\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"paymentDestinationOptions\": {\n \"type\": \"check\",\n \"delivery\": \"MAIL\",\n \"printDescription\": true\n },\n \"paymentSchedule\": {\n \"type\": \"monthly\",\n \"repeatOnDay\": 10,\n \"ends\": \"2021-01-01T00:00:00Z\"\n },\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"status\": \"NEW\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n}" response = http.request(request) puts response.read_body ``` **`Create an invoice template`** ```java Create an invoice template import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/invoice-template") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"amount\": 100,\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"currency\": \"USD\",\n \"deductionDate\": \"2021-01-10T00:00:00Z\",\n \"dueDate\": \"2021-01-13T00:00:00Z\",\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"invoiceNumber\": \"INV-123\",\n \"lineItems\": [\n {\n \"amount\": 100,\n \"category\": \"EXPENSE\",\n \"currency\": \"USD\",\n \"description\": \"Product A\",\n \"glAccountId\": \"600394\",\n \"metadata\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n },\n \"name\": \"Product A\",\n \"quantity\": 1,\n \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n \"unitPrice\": 100\n }\n ],\n \"noteToSelf\": \"Monthly recurring payment\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"paymentDestinationOptions\": {\n \"type\": \"check\",\n \"delivery\": \"MAIL\",\n \"printDescription\": true\n },\n \"paymentSchedule\": {\n \"type\": \"monthly\",\n \"repeatOnDay\": 10,\n \"ends\": \"2021-01-01T00:00:00Z\"\n },\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"status\": \"NEW\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n}") .asString(); ``` **`Create an invoice template`** ```php Create an invoice template request('POST', 'https://api.mercoa.com/invoice-template', [ 'body' => '{ "amount": 100, "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "currency": "USD", "deductionDate": "2021-01-10T00:00:00Z", "dueDate": "2021-01-13T00:00:00Z", "invoiceDate": "2021-01-01T00:00:00Z", "invoiceNumber": "INV-123", "lineItems": [ { "amount": 100, "category": "EXPENSE", "currency": "USD", "description": "Product A", "glAccountId": "600394", "metadata": { "key1": "value1", "key2": "value2" }, "name": "Product A", "quantity": 1, "serviceEndDate": "2021-01-31T00:00:00Z", "serviceStartDate": "2021-01-01T00:00:00Z", "unitPrice": 100 } ], "noteToSelf": "Monthly recurring payment", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "paymentDestinationOptions": { "type": "check", "delivery": "MAIL", "printDescription": true }, "paymentSchedule": { "type": "monthly", "repeatOnDay": 10, "ends": "2021-01-01T00:00:00Z" }, "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "status": "NEW", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`Create an invoice template`** ```csharp Create an invoice template using RestSharp; var client = new RestClient("https://api.mercoa.com/invoice-template"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"amount\": 100,\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorUserId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"currency\": \"USD\",\n \"deductionDate\": \"2021-01-10T00:00:00Z\",\n \"dueDate\": \"2021-01-13T00:00:00Z\",\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"invoiceNumber\": \"INV-123\",\n \"lineItems\": [\n {\n \"amount\": 100,\n \"category\": \"EXPENSE\",\n \"currency\": \"USD\",\n \"description\": \"Product A\",\n \"glAccountId\": \"600394\",\n \"metadata\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n },\n \"name\": \"Product A\",\n \"quantity\": 1,\n \"serviceEndDate\": \"2021-01-31T00:00:00Z\",\n \"serviceStartDate\": \"2021-01-01T00:00:00Z\",\n \"unitPrice\": 100\n }\n ],\n \"noteToSelf\": \"Monthly recurring payment\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"paymentDestinationOptions\": {\n \"type\": \"check\",\n \"delivery\": \"MAIL\",\n \"printDescription\": true\n },\n \"paymentSchedule\": {\n \"type\": \"monthly\",\n \"repeatOnDay\": 10,\n \"ends\": \"2021-01-01T00:00:00Z\"\n },\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"status\": \"NEW\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create an invoice template`** ```swift Create an invoice template import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "amount": 100, "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorUserId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "currency": "USD", "deductionDate": "2021-01-10T00:00:00Z", "dueDate": "2021-01-13T00:00:00Z", "invoiceDate": "2021-01-01T00:00:00Z", "invoiceNumber": "INV-123", "lineItems": [ [ "amount": 100, "category": "EXPENSE", "currency": "USD", "description": "Product A", "glAccountId": "600394", "metadata": [ "key1": "value1", "key2": "value2" ], "name": "Product A", "quantity": 1, "serviceEndDate": "2021-01-31T00:00:00Z", "serviceStartDate": "2021-01-01T00:00:00Z", "unitPrice": 100 ] ], "noteToSelf": "Monthly recurring payment", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "paymentDestinationOptions": [ "type": "check", "delivery": "MAIL", "printDescription": true ], "paymentSchedule": [ "type": "monthly", "repeatOnDay": 10, "ends": "2021-01-01T00:00:00Z" ], "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "status": "NEW", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/invoice-template")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` 2. Ensure the invoice template has all the necessary information to create recurring invoices: * **Payment Schedule** (set by the `paymentSchedule` field) - defines the frequency and pattern of payments * **First Payment Date** (set by the `deductionDate` field) - when the first recurring payment should be processed * All other fields required to schedule a normal [invoice](/accounts-payable/invoices#4-scheduling-the-payment) 3. [Update](/api-reference/invoice-template/update) the invoice template to the `SCHEDULED` status. Once the invoice template reaches the `SCHEDULED` status, it remains there and begins creating recurring invoices according to the template's `paymentSchedule` and `deductionDate` fields. ## Payment Schedule Types Recurring payments support several schedule types: ### Daily Payments occur every day or every N days: ```json { "type": "daily", "repeatEvery": 1, "ends": "2024-12-31T00:00:00Z" } ``` ### Weekly Payments occur on specific days of the week: ```json { "type": "weekly", "repeatOn": ["1", "3", "5"], // Monday, Wednesday, Friday "repeatEvery": 1, "ends": "2024-12-31T00:00:00Z" } ``` ### Monthly Payments occur on a specific day of the month: ```json { "type": "monthly", "repeatOnDay": 15, // 15th of each month "repeatEvery": 1, "ends": "2024-12-31T00:00:00Z" } ``` ### Yearly Payments occur on a specific date each year: ```json { "type": "yearly", "repeatOnDay": 1, "repeatOnMonth": 1, // January 1st "repeatEvery": 1, "ends": "2024-12-31T00:00:00Z" } ``` ## Invoice Creation Timing ### When Invoices Are Created 1. **First Invoice**: When you update an invoice template to `SCHEDULED` status, the first recurring invoice is immediately created with the `deductionDate` specified in the template. 2. **Subsequent Invoices**: New invoices are created automatically when the previous invoice moves to `PENDING` status on its `deductionDate`. This ensures there's always one upcoming invoice in the `SCHEDULED` state. ### Invoice Status Flow * **SCHEDULED**: Invoice is created and waiting for its payment date * **PENDING**: Payment date has arrived, invoice is being processed * **PAID**: Payment has been successfully processed * **FAILED**: Payment processing failed ### Next Invoice Creation The system automatically calculates the next `deductionDate` based on the payment schedule and creates the next invoice. This process continues until: * The payment schedule reaches its end date * The payment schedule reaches its maximum number of occurrences * The invoice template is updated to `CANCELED` status ## Invoice Numbering for Recurring Invoices When a recurring invoice is created from a template, its invoice number is automatically incremented based on the template's invoice number. For example, if the template's invoice number is `INV-001`, the first recurring invoice will be `INV-002`, the next will be `INV-003`, and so on. The incrementing logic will preserve leading zeros and common patterns (e.g., `INV-099` → `INV-100`). * If the template's invoice number does not end in a number, `-001` will be appended (e.g., `MONTHLY` → `MONTHLY-001`). * The system ensures that each generated invoice number is unique for the same vendor or payer. ### Editing Invoice Numbers You can edit the invoice number of any scheduled recurring invoice after it is created. Changing the invoice number for one invoice does **not** affect the numbering of future or past invoices. Each invoice's number is independent once created. * Editing the invoice number is allowed for scheduled recurring invoices (status `SCHEDULED` and created from a template). * The template's invoice number is only used as a base for generating new recurring invoices; editing a single invoice's number does not change the template or future invoices. ## Approvals for Recurring Payments ### Template Approval When you create an invoice template, it follows the same approval workflow as regular invoices. The template must be approved before it can be scheduled to create recurring invoices. Approval rules (approvers, approval workflow, etc.) apply to the invoice template itself. ### Generated Invoice Approval Once an invoice template is approved and scheduled, all recurring invoices created from that template are **automatically approved** and do not require additional approval. This ensures that recurring payments can proceed without manual intervention for each invoice. **Note**: If you update the invoice template after it's been scheduled, the template may need to be re-approved depending on the changes made, but existing generated invoices remain approved. ## Updating Created Invoices ### Individual Invoice Updates You can update individual recurring invoices using the [Invoice Update API](/api-reference/invoice/update). This allows you to modify: * Amount, currency, and line items * Payment source and destination * Due date and deduction date * Approvers and approval workflow * Notes and metadata * Status (with restrictions) **Important**: Updating an individual invoice does not affect the invoice template or future recurring invoices. ### Invoice Template Updates Updating the invoice template affects future recurring invoices but not already-created invoices. You can modify: * Payment schedule (affects future invoices only) * Amount, currency, and line items (affects future invoices only) * Payment source and destination (affects future invoices only) * Template status (SCHEDULED, CANCELED, etc.) ### Bulk Updates To update multiple recurring invoices at once, you can: 1. **Update the template** - affects all future invoices 2. **Use the Invoice Search API** to find specific invoices and update them individually 3. **Use webhooks** to react to invoice events and make programmatic updates ## Viewing Recurring Invoices ### Finding Recurring Invoices To view recurring invoices created from an invoice template, use the [Invoice Search API](/api-reference/invoice/find) with the `invoiceTemplateId` parameter: ```bash GET /invoice?invoiceTemplateId=invt_12345678-1234-1234-1234-123456789abc ``` ### Invoice Template Details Each recurring invoice includes: * `recurringTemplateId`: Links the invoice to its template * `isRecurringTemplate`: Set to `false` for created invoices * `nextDeductionDate`: Shows when the next invoice will be created (on the template) ### Template Status Tracking The invoice template maintains: * `nextDeductionDate`: When the next recurring invoice will be created * `status`: Current template status (SCHEDULED, CANCELED, etc.) * `paymentSchedule`: The recurring schedule configuration ### Identifying Recurring Invoices When an invoice is created from a recurring template, the invoice response will include a `recurringTemplateId` field that contains the ID of the template that created it. This field is only present for invoices that were created from a recurring template. ```json { "id": "in_12345678-1234-1234-1234-123456789abc", "status": "SCHEDULED", "amount": 100.00, "recurringTemplateId": "invt_87654321-4321-4321-4321-cba987654321", // ... other invoice fields } ``` ## Stopping Recurring Payments ### Cancel the Template To stop an invoice template from creating more invoices, use the [Update Invoice Template API](/api-reference/invoice-template/update) to update the template to the `CANCELED` status: ```json { "status": "CANCELED" } ``` ### End Date in Payment Schedule You can also set an end date in the payment schedule when creating the template: ```json { "paymentSchedule": { "type": "monthly", "repeatOnDay": 15, "ends": "2024-12-31T00:00:00Z" } } ``` ### Maximum Occurrences Set a maximum number of payments: ```json { "paymentSchedule": { "type": "monthly", "repeatOnDay": 15, "ends": 12 // Stop after 12 payments } } ``` ## Best Practices ### Setting Up Recurring Payments 1. **Test with a small amount** first to ensure the schedule works as expected 2. **Use specific end dates** rather than unlimited recurring payments 3. **Monitor the first few payments** to ensure they process correctly 4. **Set up webhooks** to track payment events and failures ### Managing Recurring Payments 1. **Regular monitoring** of payment success rates 2. **Update payment methods** before they expire 3. **Communicate changes** to customers when updating templates 4. **Keep templates simple** - complex schedules can be harder to debug ## Webhooks and Events Recurring payments trigger various events that you can monitor via webhooks: * **Invoice Created**: When a new recurring invoice is created * **Invoice Status Changed**: When an invoice moves between statuses * **Payment Processed**: When a payment is successfully completed * **Payment Failed**: When a payment fails to process Set up webhooks to automatically handle these events and maintain your recurring payment system.