{"openapi":"3.1.0","info":{"title":"PUT /api/v1/recurring/{template_id}","version":"1.0.0","description":"Update recurring template"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/recurring/{template_id}":{"put":{"tags":["recurring"],"summary":"Update recurring template","description":"Update an existing recurring template.","operationId":"update_recurring_template","parameters":[{"name":"template_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Template Id"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecurringTemplateUpdate"},"example":{"days_until_due":30,"name":"Monthly Rent - Updated","template_data":{"amount":375000,"description":"Office rent for 456 New St"}}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_RecurringTemplateResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"update_recurring_template_api_v1_recurring__template_id__put"}}},"components":{"schemas":{"CustomerSummary":{"properties":{"id":{"type":"string","title":"Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"}},"type":"object","required":["id"],"title":"CustomerSummary","description":"Summary of customer for response."},"FrequencyEnum":{"type":"string","enum":["daily","weekly","biweekly","monthly","quarterly","annually"],"title":"FrequencyEnum","description":"Recurrence frequency options."},"RecurrenceTypeEnum-Output":{"type":"string","enum":["invoice","bill","journal_entry"],"title":"RecurrenceTypeEnum","description":"Type of recurring document."},"RecurringStatusEnum":{"type":"string","enum":["active","paused","completed","cancelled"],"title":"RecurringStatusEnum","description":"Status of the recurring template."},"RecurringTemplateResponse":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"name":{"type":"string","title":"Name"},"recurrence_type":{"$ref":"#/components/schemas/RecurrenceTypeEnum-Output"},"status":{"$ref":"#/components/schemas/RecurringStatusEnum"},"frequency":{"$ref":"#/components/schemas/FrequencyEnum"},"start_date":{"type":"string","format":"date","title":"Start Date"},"end_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"End Date"},"next_occurrence":{"type":"string","format":"date","title":"Next Occurrence"},"last_generated":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Generated"},"day_of_month":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Day Of Month"},"day_of_week":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Day Of Week"},"max_occurrences":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Occurrences"},"occurrences_generated":{"type":"integer","title":"Occurrences Generated"},"template_data":{"additionalProperties":true,"type":"object","title":"Template Data"},"days_until_due":{"type":"integer","title":"Days Until Due"},"auto_send":{"type":"boolean","title":"Auto Send"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"customer":{"anyOf":[{"$ref":"#/components/schemas/CustomerSummary"},{"type":"null"}]},"vendor":{"anyOf":[{"$ref":"#/components/schemas/VendorSummary"},{"type":"null"}]},"contract_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contract Id"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"},"amount_in_dollars":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Amount In Dollars"},"frequency_display":{"type":"string","title":"Frequency Display"},"days_until_next":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Days Until Next"},"is_due":{"type":"boolean","title":"Is Due"},"should_generate":{"type":"boolean","title":"Should Generate"}},"type":"object","required":["id","business_id","name","recurrence_type","status","frequency","start_date","next_occurrence","occurrences_generated","template_data","days_until_due","auto_send","created_at","updated_at","frequency_display","is_due","should_generate"],"title":"RecurringTemplateResponse","description":"Response schema for recurring template.","example":{"amount_in_dollars":3500.0,"auto_send":false,"business_id":"abcdef01-2345-6789-abcd-ef0123456789","created_at":"2026-01-07T12:00:00Z","day_of_month":1,"days_until_due":15,"days_until_next":25,"frequency":"monthly","frequency_display":"Monthly","id":"01234567-89ab-cdef-0123-456789abcdef","is_due":false,"name":"Monthly Rent","next_occurrence":"2026-02-01","occurrences_generated":0,"recurrence_type":"bill","should_generate":false,"start_date":"2026-02-01","status":"active","template_data":{"amount":350000,"description":"Office rent"},"updated_at":"2026-01-07T12:00:00Z","vendor":{"email":"billing@property.com","id":"vendor-uuid","name":"Property Management LLC"}},"examples":[{"amount_in_dollars":3500.0,"auto_send":false,"business_id":"abcdef01-2345-6789-abcd-ef0123456789","created_at":"2026-01-07T12:00:00Z","day_of_month":1,"days_until_due":15,"days_until_next":25,"frequency":"monthly","frequency_display":"Monthly","id":"01234567-89ab-cdef-0123-456789abcdef","is_due":false,"name":"Monthly Rent","next_occurrence":"2026-02-01","occurrences_generated":0,"recurrence_type":"bill","should_generate":false,"start_date":"2026-02-01","status":"active","template_data":{"amount":350000,"description":"Office rent"},"updated_at":"2026-01-07T12:00:00Z","vendor":{"email":"billing@property.com","id":"vendor-uuid","name":"Property Management LLC"}}]},"RecurringTemplateUpdate":{"properties":{"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Updated name"},"currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Currency","description":"Updated currency (USD, CAD, AUD, EUR, or GBP)"},"frequency":{"anyOf":[{"$ref":"#/components/schemas/FrequencyEnum"},{"type":"null"}],"description":"Updated frequency"},"days_until_due":{"anyOf":[{"type":"integer","maximum":365.0,"minimum":0.0},{"type":"null"}],"title":"Days Until Due","description":"Updated days until due"},"day_of_month":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Day Of Month","description":"Updated day of month (1-31). Only applies to monthly/quarterly/annually frequencies. If the day doesn't exist in a month, generates on the last day instead."},"day_of_week":{"anyOf":[{"type":"integer","maximum":6.0,"minimum":0.0},{"type":"null"}],"title":"Day Of Week","description":"Updated day of week (0=Monday, 6=Sunday). Only applies to weekly/biweekly frequencies."},"end_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"End Date","description":"Updated end date. Whichever of end_date or max_occurrences is reached first stops generation."},"max_occurrences":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Max Occurrences","description":"Updated max occurrences. Whichever of end_date or max_occurrences is reached first stops generation."},"notes":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Notes","description":"Updated notes"},"template_data":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Template Data","description":"Updated template data"},"auto_send":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Auto Send","description":"Updated auto-send setting"},"customer_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Id","description":"Updated customer ID (only for invoice templates)"},"vendor_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Id","description":"Updated vendor ID (only for bill templates)"},"contract_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contract Id","description":"Updated contract ID (invoice templates only) — used to link a recurring schedule to a contract as a follow-up call after creation, the same pattern the invoice-creation endpoint uses for `Invoices.contract_id` (see ContractInvoiceModal)."}},"type":"object","title":"RecurringTemplateUpdate","description":"Schema for updating a recurring template.","example":{"days_until_due":30,"name":"Monthly Rent - Updated","template_data":{"amount":375000,"description":"Office rent for 456 New St"}},"examples":[{"days_until_due":30,"name":"Monthly Rent - Updated","template_data":{"amount":375000,"description":"Office rent for 456 New St"}}]},"SuccessEnvelope_RecurringTemplateResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/RecurringTemplateResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[RecurringTemplateResponse]"},"VendorSummary":{"properties":{"id":{"type":"string","title":"Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"}},"type":"object","required":["id"],"title":"VendorSummary","description":"Summary of vendor for response."},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}