Workspace API

Orders, stats & discounts

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

12 min readLast updated Sep 30, 2026

Order history, workspace analytics, conversion tracking and discount management. Stats routes accept a period (?period=7d) or explicit from/to, plus a currency filter. Conversion tracking covers the managed pixel / server-side integrations (GA4, GTM, TikTok, X, LinkedIn, Clarity, Hotjar — create, edit, remove, workspace defaults; Meta stays dashboard-managed), the event log and the per-integration delivery health. 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",      "attribution": {        "utmSource": "string",        "utmMedium": "string",        "utmCampaign": "string",        "utmTerm": "string",        "utmContent": "string",        "fbclid": "string",        "gclid": "string",        "metaCampaignId": "string",        "metaAdId": "string",        "metaCampaignName": "string",        "metaAdName": "string"      }    }  ],  "nextCursor": "string"}
{  "error": "string",  "message": "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",  "message": "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",  "attribution": {    "utmSource": "string",    "utmMedium": "string",    "utmCampaign": "string",    "utmTerm": "string",    "utmContent": "string",    "fbclid": "string",    "gclid": "string",    "metaCampaignId": "string",    "metaAdId": "string",    "metaCampaignName": "string",    "metaAdName": "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"    }  ],  "invoiceData": {    "companyName": "string",    "nip": "string",    "street": "string",    "postalCode": "string",    "city": "string",    "country": "string"  }}
{  "error": "string",  "message": "string"}

Approve a 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",  "message": "string"}

Reject a 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",  "message": "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",  "message": "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",  "message": "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",  "message": "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",  "message": "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",  "message": "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",  "message": "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",  "message": "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",  "message": "string"}

Conversion-tracking event log

GET/conversion-events

Authorization

bearerAuth
AuthorizationBearer <token>

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

In: header

Query Parameters

orderId?string

Only the events produced by this order.

checkoutId?string

Only events from this offer (checkout).

sessionId?string

Only events from one checkout session.

statuses?string

Comma-separated delivery statuses: delivered, failed, sent, consent_blocked.

clients?string

Comma-separated platform ids (meta, metaConversionApi, googleAnalytics, googleTagManager, tiktok, x, linkedin, microsoftClarity, hotjar). Meta has two values — pass both for "Meta".

limit?integer

Newest entries to return (default 20, max 100).

Response Body

application/json

application/json

curl -X GET "https://example.com/conversion-events"
{  "events": [    {      "createdAt": "string",      "platform": "string",      "client": "metaConversionApi",      "integrationId": "string",      "integrationName": "string",      "eventType": "purchase",      "channel": "client",      "status": "sent",      "statusExplanation": "string",      "orderId": "string",      "checkoutId": "string",      "productId": "string",      "productName": "string",      "sessionId": "string",      "eventId": "string",      "testEvent": true,      "httpStatusCode": 0,      "errorMessage": "string",      "requestPayload": {        "eventName": "string",        "eventId": "string",        "actionSource": "string",        "eventTime": 0,        "currency": "string",        "value": 0,        "contentName": "string",        "contentIds": [          "string"        ],        "contents": [          {            "id": "string",            "quantity": 0,            "price": 0          }        ],        "orderId": "string",        "transactionType": "purchase",        "sourceUrl": "string"      },      "providerResponse": {        "eventsReceived": 0,        "traceId": "string",        "messages": [          "string"        ]      }    }  ]}
{  "error": "string",  "message": "string"}

Conversion-tracking health

GET/conversion-tracking/health

Authorization

bearerAuth
AuthorizationBearer <token>

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

In: header

Query Parameters

sinceDays?integer

Stats window in days (default 7, max 90).

Response Body

application/json

application/json

curl -X GET "https://example.com/conversion-tracking/health"
{  "since": "string",  "integrations": [    {      "integrationId": "string",      "name": "string",      "platform": "string",      "client": "metaConversionApi",      "disabled": true,      "isWorkspaceDefault": true,      "health": "healthy",      "healthExplanation": "string",      "stats": {        "total": 0,        "delivered": 0,        "failed": 0,        "sent": 0,        "consentBlocked": 0,        "lastEventAt": "string"      }    }  ]}
{  "error": "string",  "message": "string"}

List conversion-tracking integrations

GET/conversion-tracking/integrations

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/conversion-tracking/integrations"
{}
{  "error": "string",  "message": "string"}

Add or edit a conversion-tracking integration

PUT/conversion-tracking/integrations

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.

PUT /conversion-tracking/integrations — create (no integrationId) or edit (with integrationId) one managed entry. Discriminated by client.

PUT /conversion-tracking/integrations — create (no integrationId) or edit (with integrationId) one managed entry. Discriminated by client.

Response Body

application/json

application/json

curl -X PUT "https://example.com/conversion-tracking/integrations" \  -H "Content-Type: application/json" \  -d '{    "name": "string",    "client": "googleAnalytics",    "measurementId": "string",    "trackPurchase": true,    "trackInitCheckout": true,    "trackAddToCart": true,    "trackTrialStarted": true  }'
{}
{  "error": "string",  "message": "string"}

Remove a conversion-tracking integration

DELETE/conversion-tracking/integrations/{client}/{integrationId}

Authorization

bearerAuth
AuthorizationBearer <token>

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

In: header

Path Parameters

client*string
integrationId*string

Response Body

application/json

application/json

curl -X DELETE "https://example.com/conversion-tracking/integrations/string/string"
{  "removed": true}
{  "error": "string",  "message": "string"}

Set the workspace-default conversion tracking

PUT/conversion-tracking/defaults

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.

PUT /conversion-tracking/defaults — replaces the workspace-default integration ids; [] clears.

Response Body

application/json

application/json

curl -X PUT "https://example.com/conversion-tracking/defaults" \  -H "Content-Type: application/json" \  -d '{    "integrationIds": [      "string"    ]  }'
{  "integrationIds": [    "string"  ]}
{  "error": "string",  "message": "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",  "message": "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",  "message": "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",  "message": "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",  "message": "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",  "message": "string"}

Was this article helpful?

Related articles

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