{ "Protocol": "AIXE", "Version": "1.0", "Endpoint": "/aixe/customer/replace-invoice-items", "DiscoveryRequest": "GET /aixe/customer/replace-invoice-items/?", "CanonicalHelpTrigger": "GET /aixe/customer/replace-invoice-items/?", "ActionRequest": "POST /aixe/customer/replace-invoice-items", "Method": "POST", "ContentType": "application/json", "Title": "Replace Invoice Items", "AuthenticationRequired": true, "AccessType": "Customer", "Purpose": "Replace the product selection on your own pending invoice after an availability error, retaining its invoice key. Supply the complete desired selection. Stock is rechecked when placing the order.", "RecurrenceRules": "Product and invoice-item responses include IsSubscription. Subscription items require one line with quantity exactly 1, with no mixed products. Invoice headers include RecurringHours (0 means stopped), FirstOccurrenceDate, LastRecurrenceDate and NextOccurrenceDate in UTC. Use owner/get-recurrence or customer/get-recurrence, then update-recurrence with a current RowVersion. SubscriptionDays on the product automatically sets new subscription invoice hours and the first renewal one interval after the item is added. Customers cannot change subscription schedules. Product changes affect new invoices only. Ordinary invoices can optionally repeat multiple products. Generation copies the source into a fresh Ordered, unpaid invoice with recurrence disabled. The public /renewinvoices trigger needs no authentication and never creates the same occurrence twice.", "InventoryRules": "Drafts do not reserve stock. Completing an administrator order or placing a customer order rechecks every physical product and deducts available stock atomically with submission. Scheduled service lines do not consume physical stock. If a product has become unavailable or insufficient, the whole submission fails: no stock or order status changes are committed. VALIDATION_FAILED explains which product needs replacing or reducing. Customers can use customer/replace-invoice-items on their own Pending invoice with the complete desired Items selection, current RowVersion, then place it again. Administrator item editors remain available for administrator orders. Repeating completion does not deduct again. Completing a quantity edit applies only the difference, and a removed line returns its previously deducted units when the edited order is completed. Concurrent orders cannot consume the same last units. CONFLICT means reload the order before retrying. Stock is not automatically returned by cancellation or refund; those actions do not establish that physical goods were returned. Existing historical invoices are not batch-deducted. Recurring generation also deducts physical stock in its invoice transaction; a shortage rolls back that occurrence and leaves it due for a later retry.", "ThingsYouCanAsk": [ "Help me replace invoice items.", "Show me the information needed to replace invoice items.", "Use this capability for my business." ], "DocumentationSource": "AIXEEndpointRegistry", "ProtocolReference": { "ProtocolHome": "http://aixeprotocol.com/", "CanonicalUsageContract": "http://aixeprotocol.com/usage/?", "Whitepaper": "http://aixeprotocol.com/whitepaper/full-spec.html", "Inventor": "Gregory Oglethorpe", "IncludeIn": [ "/aixe.ai starter discovery documents", "Every endpoint self-description returned by GET /endpoint/?" ], "AIInstruction": "Read this live endpoint contract as operational guidance, not merely as a transport schema. Use its purpose, field meanings, business rules, outcomes, and recovery guidance to reason about whether and how to perform the capability." }, "UsageGuidance": { "Role": "Read this contract and use the capability only for the human\u0027s authorized request.", "CorrectWorkflow": [ "Read this contract and use the capability only for the human\u0027s authorized request.", "Read current public keys and record versions before changing records. Send fields in the JSON body.", "Read SuccessCode and the detailed outcome; a saved business action and its email outcome are separate." ], "DoNotDo": [ "Do not send business variables, keys, filters, or action inputs in the URL or query string.", "Do not infer success from HTTP status alone." ] }, "AIUsageGuidance": { "ContractRole": "This live document teaches an AI what the capability means and how to use it; it is not merely a list of request fields.", "ReasoningInstruction": "Decide whether this capability serves the human\u0027s intent from Purpose and BusinessRules, gather values using each field\u0027s Description and constraints, then interpret the returned SuccessCode before reporting an outcome.", "FieldInstruction": "Field names are transport labels. Their Description, source, constraints, and business meaning explain what information the AI should obtain and why." }, "RequiredFields": { "PersonAuthenticationToken": { "Type": "string", "Description": "Temporary secret from account/login. Authorization uses the active account and its current roles; never echo or store it.", "Required": true, "SubmittedIn": "JSON body" }, "InvoiceKey": { "Type": "string", "Description": "Public UUID identifying the invoice being read or changed. Customer endpoints additionally enforce ownership.", "Required": true, "SubmittedIn": "JSON body", "Format": "UUID" }, "RowVersion": { "Type": "string", "Description": "Opaque base64 version returned by the resource read. For order-related operations use the invoice version. Reload after CONFLICT; do not guess or replace it with a freshly fetched version without reviewing changes.", "Required": true, "SubmittedIn": "JSON body", "Format": "base64" }, "Items": { "Type": "array", "Description": "Complete product selection: array of unique ProductKey UUIDs and integer Quantity values. Scheduled products produce separate quantity-one occurrences. Existing service identities, providers, times and addresses are retained in line order; reducing quantity archives the surplus occurrences, preserving history. Use scheduling/update-item-schedule for each service address/time/provider and remove-invoice-item to target one specific occurrence. Zero excludes a product. An empty replacement removes every line and disables Review. Create-order requires at least one item.", "Required": true, "SubmittedIn": "JSON body", "ItemFields": { "ProductKey": { "Type": "string", "Description": "Public UUID identifying a product from the product catalog.", "Required": true, "SubmittedIn": "JSON body", "Format": "UUID" }, "Quantity": { "Type": "integer", "Description": "Positive whole-number product quantity, within the currently available inventory.", "Required": true, "SubmittedIn": "JSON body" } } } }, "OptionalFields": {}, "BusinessRules": [ "Submit the business inputs for the intended action and inspect its returned SuccessCode.", "Only active authorized accounts may use protected capabilities. Customer order queries are restricted to the authenticated customer\u0027s orders before filtering. Internal notes, staff activity and vendor details are owner-only.", "Dates and text filters can be supplied independently or together. Searches expose all matches through continuation; there is no silent first-50 or first-200 cutoff.", "Customer selection is empty without Search or explicit ListAll. The configured customer result limit is disclosed as AppliedLimit.", "Payment amounts, identity and invoice relationships are permanent. No payment deletion exists. Update-payment-details accepts only date, method, reference and note in addition to its keys and versions. Negative entries require a note and cannot exceed net collected. Overpayments are retained as credit.", "The status endpoint sets any supported status, including backward moves and reopening. Pickup/delivery compatibility applies. It sends no email and does not claim the checklist is complete. Finalize-order requires every current line packed and commits readiness before its immediate email attempt.", "Email is attempted immediately with a bounded SMTP timeout. Failed sends log a NOC and stop. No queue, delivery worker or automatic retry exists. A mail failure never reverses a saved order, payment or vendor assignment. Explicit resend-request is a new intentional send.", "Customer deletion removes access and preserves invoice history. Referenced vendors must be deactivated. Administrators cannot remove themselves or the last active administrator. Passwords and SMTP secrets are never returned.", "Editing a submitted record requires its returned RowVersion. Stale edits fail and must be reviewed before submitting a new request. Unsupported fields are rejected rather than silently accepted." ], "ResponseFields": { "SuccessCode": { "Type": "string", "Description": "SUCCESS confirms the read or committed business action. Check email acceptance separately. A failed email-only action returns EMAIL_NOT_SENT. HTTP status alone does not establish success.", "Required": true, "SubmittedIn": "Response body" }, "Order": { "Type": "object", "Description": "Invoice Header with public key, number, row version, dates, customer name, fulfillment request and ledger-aware totals; Customer contact snapshot; Delivery address; Notes; Items with product keys and row versions. Owner responses additionally contain internal notes, activities, payments and status choices. Customer responses omit those private fields.", "Required": true, "SubmittedIn": "Response body" } }, "Errors": [ { "SuccessCode": "VALIDATION_FAILED", "Meaning": "One or more required request values are missing or malformed.", "Recovery": "Use the field descriptions and constraints in this contract, correct the named fields, and retry the same capability.", "Recoverable": true }, { "SuccessCode": "UNAUTHORIZED", "Meaning": "The submitted identity or token does not authorize this capability or record scope.", "Recovery": "Use the correct active authentication token and confirm the required account role.", "Recoverable": true }, { "SuccessCode": "NOT_FOUND", "Meaning": "A submitted public key did not identify a record within this capability\u0027s declared scope.", "Recovery": "Re-check the key against a current list or creation response; do not treat this as a missing web route.", "Recoverable": true }, { "SuccessCode": "CONFLICT", "Meaning": "The capability could not complete for an execution failure.", "Recovery": "Read the returned message and error detail. Retry only when the response identifies a recoverable condition.", "Recoverable": false }, { "SuccessCode": "EMAIL_NOT_SENT", "Meaning": "The capability could not complete for an execution failure.", "Recovery": "Read the returned message and error detail. Retry only when the response identifies a recoverable condition.", "Recoverable": false }, { "SuccessCode": "FAILED", "Meaning": "The capability could not complete for an execution failure.", "Recovery": "Read the returned message and error detail. Retry only when the response identifies a recoverable condition.", "Recoverable": false } ], "ActionResponse": { "RequiredResponseFields": [ "SuccessCode" ], "SuccessCodes": [ "SUCCESS" ], "FailureCodes": [ "VALIDATION_FAILED", "UNAUTHORIZED", "NOT_FOUND", "CONFLICT", "EMAIL_NOT_SENT", "FAILED" ], "NonFinalCodes": [], "MissingOrEmptyResponse": "Treat as FAILED.", "Rule": "The endpoint response is authoritative. Only an exact SuccessCode value listed in SuccessCodes means the business action succeeded; HTTP status alone does not declare the AIXE outcome." } }