Workspace API

Orders, stats & discounts

Orders, stats & discounts endpoints of the Zanfia Workspace API, with schemas and code samples.

9 min readLast updated Jul 26, 2026

Order history, workspace analytics, and discount management. Stats routes accept a period (?period=7d) or explicit from/to, plus a currency filter. All routes require a Authorization: Bearer header — see Authentication.

List orders

GET/orders

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Query Parameters

productId?string
status?string
from?string
to?string
search?string
limit?integer
cursor?string

Response Body

application/json

application/json

curl -X GET "https://example.com/orders"
{  "items": [    {      "id": "string",      "productId": "string",      "clientEmail": "string",      "amountCents": 0,      "currency": "string",      "status": "paid",      "createdAt": "string"    }  ],  "nextCursor": "string"}
{  "error": "string"}

Export orders as CSV

GET/orders/export

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Query Parameters

from*string

Window start (ISO date, inclusive). Required.

to*string

Window end (ISO date, inclusive). Required.

productId?string

Only orders of this product.

status?string

Public status filter: paid, pending, refunded, failed.

search?string

Client email/name substring.

includeTest?boolean

true includes simulated test purchases (excluded by default).

maxRows?integer

Row cap: default 10000, max 20000.

Response Body

application/json

application/json

curl -X GET "https://example.com/orders/export?from=string&to=string"
{  "csv": "string",  "rowCount": 0,  "truncated": true}
{  "error": "string"}

Order detail

GET/orders/{orderId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

orderId*string

Order id

Response Body

application/json

application/json

curl -X GET "https://example.com/orders/string"
{  "id": "string",  "productId": "string",  "clientEmail": "string",  "amountCents": 0,  "currency": "string",  "status": "paid",  "createdAt": "string",  "productName": "string",  "clientName": "string",  "internalStatus": "string",  "paymentType": "string",  "paymentGateway": "string",  "quantity": 0,  "couponCode": "string",  "isTest": true,  "invoiceUrl": "string",  "refund": {    "amountCents": 0,    "currency": "string"  },  "additionalProducts": [    {      "productId": "string",      "productName": "string",      "priceId": "string",      "quantity": 0,      "amountCents": 0,      "currency": "string"    }  ]}
{  "error": "string"}

Approve manual order

POST/orders/{orderId}/approve-payment

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

orderId*string

Order id

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Optional body of POST /orders/:orderId/approve-payment. issueInvoice additionally issues an invoice via the workspace's connected invoicing account (checkout selection → workspace default → first connected account); manual orders never issue invoices without this explicit request.

Response Body

application/json

application/json

curl -X POST "https://example.com/orders/string/approve-payment" \  -H "Content-Type: application/json" \  -d '{}'
{  "status": "ok"}
{  "error": "string"}

Reject manual order

POST/orders/{orderId}/reject-payment

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

orderId*string

Order id

Response Body

application/json

application/json

curl -X POST "https://example.com/orders/string/reject-payment"
{  "status": "ok"}
{  "error": "string"}

Headline sales metrics

GET/stats/overview

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Query Parameters

period?string
currency?string

Response Body

application/json

application/json

curl -X GET "https://example.com/stats/overview?period=7d"
{  "totalRevenueCents": 0,  "currency": "string",  "totalOrders": 0,  "period": {    "from": "string",    "to": "string"  }}
{  "error": "string"}

Sales series

GET/stats/sales

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/stats/sales"
{  "currency": "string",  "totalRevenueCents": 0,  "transactions": 0,  "refunds": 0,  "averageOrderValueCents": 0,  "newSubscribers": 0,  "byDay": [    {      "date": "string",      "revenueCents": 0,      "transactions": 0,      "newSubscribers": 0    }  ],  "perProduct": [    {      "id": "string",      "name": "string",      "transactions": 0,      "refunds": 0,      "revenueCents": 0    }  ],  "perCheckout": [    {      "id": "string",      "name": "string",      "transactions": 0,      "refunds": 0,      "revenueCents": 0    }  ],  "period": {    "from": "string",    "to": "string"  }}
{  "error": "string"}

Recurring revenue (MRR)

GET/stats/recurring

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/stats/recurring"
{  "currency": "string",  "mrrCents": 0,  "arrCents": 0,  "mrrByCurrencyCents": {    "property1": 0,    "property2": 0  },  "arrByCurrencyCents": {    "property1": 0,    "property2": 0  },  "activeSubscriptions": 0,  "atRiskMrrCents": 0,  "pausedMrrCents": 0,  "endingSoonCount": 0,  "perProduct": [    {      "productId": "string",      "productName": "string",      "mrrCents": 0,      "activeSubscriptions": 0    }  ]}
{  "error": "string"}

MRR history

GET/stats/recurring/history

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/stats/recurring/history"
{  "currency": "string",  "points": [    {      "date": "string",      "mrrCents": 0,      "activeSubscriptions": 0,      "newMrrCents": 0,      "expansionMrrCents": 0,      "contractionMrrCents": 0,      "churnedMrrCents": 0,      "churnRate": 0    }  ]}
{  "error": "string"}

Checkout funnel

GET/stats/funnel

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/stats/funnel"
{  "totals": {    "sessions": 0,    "formStarted": 0,    "paymentStarted": 0,    "completed": 0,    "abandoned": 0,    "otoViewed": 0,    "otoAccepted": 0,    "otoDeclined": 0  },  "byCheckout": [    {      "checkoutId": "string",      "checkoutName": "string",      "isFree": true,      "productId": "string",      "stats": {        "sessions": 0,        "formStarted": 0,        "paymentStarted": 0,        "completed": 0,        "abandoned": 0,        "otoViewed": 0,        "otoAccepted": 0,        "otoDeclined": 0      }    }  ],  "byDay": [    {      "date": "string",      "stats": {        "sessions": 0,        "formStarted": 0,        "paymentStarted": 0,        "completed": 0,        "abandoned": 0,        "otoViewed": 0,        "otoAccepted": 0,        "otoDeclined": 0      }    }  ],  "period": {    "from": "string",    "to": "string"  }}
{  "error": "string"}

Traffic

GET/stats/traffic

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/stats/traffic"
{  "totals": {    "views": 0,    "entries": 0,    "purchases": 0,    "revenueMinorByCurrency": {      "property1": 0,      "property2": 0    }  },  "pages": [    {      "views": 0,      "entries": 0,      "purchases": 0,      "revenueMinorByCurrency": {        "property1": 0,        "property2": 0      },      "surface": "storefront",      "pageId": "string"    }  ],  "sources": [    {      "views": 0,      "entries": 0,      "purchases": 0,      "revenueMinorByCurrency": {        "property1": 0,        "property2": 0      },      "source": "string"    }  ],  "mediums": [    {      "views": 0,      "entries": 0,      "purchases": 0,      "revenueMinorByCurrency": {        "property1": 0,        "property2": 0      },      "key": "string"    }  ],  "campaigns": [    {      "views": 0,      "entries": 0,      "purchases": 0,      "revenueMinorByCurrency": {        "property1": 0,        "property2": 0      },      "key": "string"    }  ],  "referrers": [    {      "views": 0,      "entries": 0,      "purchases": 0,      "revenueMinorByCurrency": {        "property1": 0,        "property2": 0      },      "key": "string"    }  ],  "countries": [    {      "views": 0,      "entries": 0,      "purchases": 0,      "revenueMinorByCurrency": {        "property1": 0,        "property2": 0      },      "key": "string"    }  ],  "devices": [    {      "views": 0,      "entries": 0,      "purchases": 0,      "revenueMinorByCurrency": {        "property1": 0,        "property2": 0      },      "key": "string"    }  ],  "sourcesTruncated": true,  "period": {    "from": "string",    "to": "string"  }}
{  "error": "string"}

Sessions

GET/stats/sessions

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/stats/sessions"
{  "sessions": [    {      "id": "string",      "checkoutId": "string",      "productId": "string",      "priceId": "string",      "status": "active",      "furthestStage": "viewed",      "converted": true,      "startedAt": "string",      "lastSeenAt": "string",      "abandonedAt": "string",      "convertedAt": "string",      "source": {        "referrer": "string",        "utmSource": "string",        "utmMedium": "string",        "utmCampaign": "string"      },      "country": "string"    }  ],  "period": {    "from": "string",    "to": "string"  }}
{  "error": "string"}

Per-product stats

GET/products/{productId}/stats

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

productId*string

Product id

Response Body

application/json

application/json

curl -X GET "https://example.com/products/string/stats"
{  "productId": "string",  "currency": "string",  "window": {    "startDate": "string",    "endDate": "string"  },  "revenue": {    "totalCents": 0,    "previousTotalCents": 0,    "byDay": [      {        "date": "string",        "revenueCents": 0,        "newStudents": 0      }    ]  },  "students": {    "newInWindow": 0,    "previousNewInWindow": 0,    "churnedInWindow": 0  },  "progress": {    "tracked": 0,    "completedCourse": 0,    "activeLast7Days": 0,    "lessonEngagement": {      "property1": {        "started": 0,        "completed": 0      },      "property2": {        "started": 0,        "completed": 0      }    }  },  "attention": {    "failedRenewalsInWindow": 0,    "pastDueSubscriptions": 0  },  "quizzes": {    "property1": {      "attempts": 0,      "passed": 0    },    "property2": {      "attempts": 0,      "passed": 0    }  },  "activity": [    {      "eventName": "user.UserCreated",      "timestamp": 0,      "clientEmail": "string",      "clientName": "string"    }  ],  "community": {    "unansweredPosts": 0,    "oldestUnanswered": {      "postId": "string",      "channelId": "string",      "title": "string",      "createdAt": 0    },    "openTickets": 0,    "unassignedTickets": 0,    "unreadRepliesAndMentions": 0,    "postsThisWeek": 0,    "postsPreviousWeek": 0  }}
{  "error": "string"}

List discounts

GET/discounts

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/discounts"
{  "items": [    {      "id": "string",      "code": "string",      "percentOff": 0,      "amountOffCents": 0,      "currency": "string",      "active": true,      "usageCount": 0    }  ]}
{  "error": "string"}

Create a discount

POST/discounts

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/discounts" \  -H "Content-Type: application/json" \  -d '{    "code": "string"  }'
{  "id": "string",  "code": "string",  "percentOff": 0,  "amountOffCents": 0,  "currency": "string",  "active": true,  "usageCount": 0}
{  "error": "string"}

Update a discount

PATCH/discounts/{discountId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

discountId*string

Discount id

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X PATCH "https://example.com/discounts/string" \  -H "Content-Type: application/json" \  -d '{}'
{  "id": "string",  "code": "string",  "percentOff": 0,  "amountOffCents": 0,  "currency": "string",  "active": true,  "usageCount": 0}
{  "error": "string"}

Delete a discount

DELETE/discounts/{discountId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

discountId*string

Discount id

Response Body

application/json

application/json

curl -X DELETE "https://example.com/discounts/string"
{  "deleted": true}
{  "error": "string"}

Archive a discount

POST/discounts/{discountId}/archive

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

discountId*string

Discount id

Response Body

application/json

application/json

curl -X POST "https://example.com/discounts/string/archive"
{  "archived": true}
{  "error": "string"}

Was this article helpful?

Related articles

Spotted something off? Tell us at support@zanfia.com.