Partners API¶
The Partners API manages the partner/referral program for accountants, advisors, and consultants who refer clients to Carbon Connect. It includes partner registration, authentication, dashboard analytics, referral tracking, commission management, and admin oversight.
Authentication Model¶
Partners have a separate authentication flow from regular users. Partner tokens use the same JWT format but do not include a tenant_id. Partner-authenticated endpoints use a dedicated CurrentPartner dependency.
Partner Registration and Login¶
POST /partners/register¶
Register a new partner account. Partners start with pending status and must be approved by an admin before they can generate referrals.
Authentication: Not required
Status Codes:
| Code | Description |
|---|---|
| 201 | Partner registered |
| 400 | Email already registered |
| 422 | Validation error |
POST /partners/login¶
Authenticate a partner and obtain JWT tokens. Uses OAuth2 password flow.
Authentication: Not required
Status Codes:
| Code | Description |
|---|---|
| 200 | Login successful |
| 401 | Incorrect email or password |
| 403 | Partner account suspended or inactive |
Partner Profile¶
GET /partners/me¶
Get the current partner's profile.
Authentication: Required (Partner token)
PATCH /partners/me¶
Update the current partner's profile.
Authentication: Required (Partner token)
Partner Analytics¶
GET /partners/dashboard¶
Get dashboard statistics for the current partner including referral counts, conversion rates, and commission totals.
Authentication: Required (Partner token)
GET /partners/performance¶
Get performance metrics over time for the current partner.
Authentication: Required (Partner token)
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
months | integer | 12 | Number of months to look back |
Referral Tracking¶
GET /partners/referrals¶
List referrals for the current partner.
Authentication: Required (Partner token)
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
page_size | integer | 20 | Items per page |
status | string | -- | Filter by referral status |
Commission Tracking¶
GET /partners/commissions¶
List commissions for the current partner with summary totals.
Authentication: Required (Partner token)
{
"items": [
{
"id": "c1a2b3c4-d5e6-7890-abcd-ef1234567890",
"referral_id": "r1a2b3c4-d5e6-7890-abcd-ef1234567890",
"amount": 1500.0,
"currency": "EUR",
"status": "approved",
"period": "2025-01",
"created_at": "2025-02-01T00:00:00Z"
}
],
"total": 12,
"page": 1,
"page_size": 20,
"pages": 1,
"total_pending": 3200.0,
"total_approved": 5800.0,
"total_paid": 3500.0
}
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
page_size | integer | 20 | Items per page |
status | string | -- | Filter by commission status |
Response Summary Fields:
| Field | Type | Description |
|---|---|---|
total_pending | float | Total pending commission (EUR) |
total_approved | float | Total approved commission (EUR) |
total_paid | float | Total paid commission (EUR) |
Public Referral Endpoints¶
POST /referrals/click¶
Record a referral link click. This is called when a prospective client clicks a partner's referral link. No authentication is required.
Authentication: Not required
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
referral_code | string | Yes | Partner's referral code |
utm_source | string | No | UTM source parameter |
utm_medium | string | No | UTM medium parameter |
utm_campaign | string | No | UTM campaign parameter |
landing_page | string | No | Landing page path |
Status Codes:
| Code | Description |
|---|---|
| 200 | Click recorded |
| 400 | Partner is not active |
| 404 | Invalid referral code |
Admin Partner Management¶
Admin Access Required
All endpoints under /admin/partners require the authenticated user to have admin or owner role.
GET /admin/partners¶
List all partners with filtering options.
Authentication: Required (Admin/Owner)
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
page_size | integer | 20 | Items per page |
status | string | -- | Filter by partner status |
tier | string | -- | Filter by partner tier |
partner_type | string | -- | Filter by partner type |
GET /admin/partners/{partner_id}¶
Get a partner by ID with full admin details.
Authentication: Required (Admin/Owner)
PATCH /admin/partners/{partner_id}/status¶
Update a partner's status. Used to approve, suspend, or deactivate partners.
Authentication: Required (Admin/Owner)
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | New status: pending, active, suspended, inactive |
notes | string | No | Admin notes about the status change |
PATCH /admin/partners/{partner_id}/tier¶
Update a partner's tier and commission rates.
Authentication: Required (Admin/Owner)
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
tier | string | Yes | Partner tier: bronze, silver, gold, platinum |
first_year_commission_rate | float | No | First year commission rate (0-1) |
ongoing_commission_rate | float | No | Ongoing annual commission rate (0-1) |
Status Codes:
| Code | Description |
|---|---|
| 200 | Partner updated |
| 401 | Not authenticated |
| 403 | Insufficient permissions |
| 404 | Partner not found |