How to Manage Invoices via the CAKE API

This article will cover the following:


Overview

The Billing & Payments API gives you programmatic access to your platform's financial data — affiliate invoices, billing cycles, payment methods, and currencies. All write operations modify financial records, so validate affiliate IDs and date ranges before submitting requests.

Caution:
Invoice creation and updates are write operations that modify financial records. Always validate affiliate IDs, date ranges, and status values before submitting.

List Invoices

GET /api/2/invoices.json
ParameterTypeRequiredDescription
invoice_idintegerNoFilter to a specific invoice by ID.
affiliate_idintegerNoFilter invoices for a specific affiliate.
advertiser_idintegerNoFilter invoices for a specific advertiser.
invoice_statusstringNoFilter by status: pending, approved, paid, or void.
start_datedateNoInvoices with period starting on or after this date (YYYY-MM-DD).
end_datedateNoInvoices with period ending on or before this date (YYYY-MM-DD).
start_at_rowintegerNoRow offset. Default: 0.
row_limitintegerNoMax invoices. Default: 100.

Sample request

GET https://yourdomain.cake.com/api/2/invoices.json ?api_key=YOUR_API_KEY &affiliate_id=67890 &invoice_status=pending &start_date=2024-01-01 &row_limit=25

Sample response

{ "request_status": "Success", "invoices": [{ "invoice_id": 4821, "affiliate_id": 67890, "affiliate_name": "Acme Media Group", "invoice_status": "pending", "start_date": "2024-01-01", "end_date": "2024-01-31", "total_amount": "1250.00", "currency": "USD" }], "total_rows": 1 }

Create Invoice

Generates a new invoice for a specified affiliate. CAKE calculates the invoice total based on the affiliate's conversions and earnings within the given period.

POST /api/2/invoice.json
ParameterTypeRequiredDescription
affiliate_idintegerYesID of the affiliate for whom the invoice is created.
start_datedateYesStart of the billing period (YYYY-MM-DD).
end_datedateYesEnd of the billing period (YYYY-MM-DD).
memostringNoOptional internal note to attach to the invoice.

Sample request

POST https://yourdomain.cake.com/api/2/invoice.json?api_key=YOUR_API_KEY { "affiliate_id": 67890, "start_date": "2024-01-01", "end_date": "2024-01-31", "memo": "January 2024 manual invoice" }

Sample response

{ "request_status": "Success", "invoice": { "invoice_id": 4822, "affiliate_id": 67890, "invoice_status": "pending", "total_amount": "980.50", "currency": "USD" } }

Update Invoice

Updates the status, memo, or payment date of an existing invoice. When recording a payment, supply paid_at alongside invoice_status: paid.

POST /api/2/update_invoice.json
ParameterTypeRequiredDescription
invoice_idintegerYesID of the invoice to update.
invoice_statusstringNoNew status: pending, approved, paid, or void.
memostringNoUpdated internal note.
paid_atdatetimeNoPayment timestamp. Supply with invoice_status: paid.

Sample request

POST https://yourdomain.cake.com/api/2/update_invoice.json?api_key=YOUR_API_KEY { "invoice_id": 4821, "invoice_status": "paid", "paid_at": "2024-02-15T10:00:00Z" }

Sample response

{ "request_status": "Success", "invoice": { "invoice_id": 4821, "invoice_status": "paid", "paid_at": "2024-02-15T10:00:00Z" } }

Billing Reference Data

Use these lookup endpoints to retrieve valid IDs for billing cycles, payment methods, currencies, and tax classes before creating or updating records.

GET /api/2/billing_cycles.json
ParameterTypeRequiredDescription
billing_cycle_idintegerNoFilter to a specific billing cycle by ID.

Sample request

GET https://yourdomain.cake.com/api/2/billing_cycles.json?api_key=YOUR_API_KEY

Sample response

{ "request_status": "Success", "billing_cycles": [ {"billing_cycle_id": 1, "billing_cycle_name": "Weekly"}, {"billing_cycle_id": 2, "billing_cycle_name": "Bi-Weekly"}, {"billing_cycle_id": 3, "billing_cycle_name": "Monthly"} ] }
GET /api/2/payment_methods.json
ParameterTypeRequiredDescription
payment_method_idintegerNoFilter to a specific payment method by ID.

Sample request

GET https://yourdomain.cake.com/api/2/payment_methods.json?api_key=YOUR_API_KEY

Sample response

{ "request_status": "Success", "payment_methods": [ {"payment_type_id": 1, "payment_type_name": "Check"}, {"payment_type_id": 2, "payment_type_name": "Wire Transfer"}, {"payment_type_id": 3, "payment_type_name": "PayPal"} ] }

If you have any questions, please reach out to your dedicated CAKE Client Success Manager/Account Manager or contact the CAKE Support Team at support@getCAKE.com.


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.