Skip to content

API Controllers Implementation Changelog

Implementation Date: February 4, 2026 Status: Complete


Summary

Implemented 5 missing API controllers for the Partner API (v1) as identified in the infrastructure audit. These controllers were referenced in routes/api_v1.php but did not exist, causing 404 errors.


Files Created

Controllers

File Purpose Methods
app/Http/Controllers/Api/V1/PartnerController.php Partner profile management profile()
app/Http/Controllers/Api/V1/PartnerListingController.php Marketplace listings index(), show(), update(), seoScore(), recommendations()
app/Http/Controllers/Api/V1/CoSellController.php Co-sell opportunities index(), store(), show(), update(), timeline()
app/Http/Controllers/Api/V1/PartnerAnalyticsController.php Analytics & reporting summary(), reports(), showReport()
app/Http/Controllers/Api/V1/WebhookController.php Webhook management index(), store(), destroy(), events(), test()

Models

File Purpose
app/Models/Webhook.php Webhook configuration storage

Migrations

File Purpose
database/migrations/2026_02_04_000001_create_webhooks_table.php Create webhooks table

Database Changes Required

New Table: webhooks

CREATE TABLE webhooks (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    user_id BIGINT UNSIGNED NOT NULL,
    url VARCHAR(2048) NOT NULL,
    events JSON NOT NULL,
    description VARCHAR(255) NULL,
    secret VARCHAR(64) NOT NULL COMMENT 'Hashed secret for payload verification',
    active BOOLEAN DEFAULT TRUE,
    last_triggered_at TIMESTAMP NULL,
    last_response_code INT NULL,
    failure_count INT DEFAULT 0,
    disabled_at TIMESTAMP NULL,
    disabled_reason VARCHAR(255) NULL,
    created_at TIMESTAMP NULL,
    updated_at TIMESTAMP NULL,
    deleted_at TIMESTAMP NULL,

    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
    INDEX idx_webhooks_user_active (user_id, active),
    INDEX idx_webhooks_active (active)
);

Modified Table: webhookhistory

Adds optional foreign key to link delivery history to webhook configurations:

ALTER TABLE webhookhistory
ADD COLUMN webhook_id BIGINT UNSIGNED NULL AFTER id,
ADD CONSTRAINT fk_webhookhistory_webhook
    FOREIGN KEY (webhook_id) REFERENCES webhooks(id) ON DELETE SET NULL;

Environment Variables

No new environment variables required for this implementation.

The controllers use existing configuration: - Database connection (existing) - Authentication via auth:api middleware (existing) - Rate limiting via throttle:partner (existing)


Deployment Steps

  1. Run Migration

    php artisan migrate
    

  2. Clear Route Cache (if cached)

    php artisan route:clear
    php artisan route:cache
    

  3. Clear Application Cache

    php artisan cache:clear
    php artisan config:clear
    


API Endpoints Now Functional

Method Endpoint Controller
GET /api/v1/partners/profile PartnerController@profile
GET /api/v1/partners/listings PartnerListingController@index
GET /api/v1/partners/listings/{id} PartnerListingController@show
PUT /api/v1/partners/listings/{id} PartnerListingController@update
GET /api/v1/partners/listings/{id}/seo PartnerListingController@seoScore
GET /api/v1/partners/listings/{id}/recommendations PartnerListingController@recommendations
GET /api/v1/partners/cosell/opportunities CoSellController@index
POST /api/v1/partners/cosell/opportunities CoSellController@store
GET /api/v1/partners/cosell/opportunities/{id} CoSellController@show
PATCH /api/v1/partners/cosell/opportunities/{id} CoSellController@update
GET /api/v1/partners/cosell/opportunities/{id}/timeline CoSellController@timeline
GET /api/v1/partners/analytics/summary PartnerAnalyticsController@summary
GET /api/v1/partners/analytics/reports PartnerAnalyticsController@reports
GET /api/v1/partners/analytics/reports/{id} PartnerAnalyticsController@showReport
GET /api/v1/partners/webhooks WebhookController@index
POST /api/v1/partners/webhooks WebhookController@store
DELETE /api/v1/partners/webhooks/{id} WebhookController@destroy
GET /api/v1/partners/webhooks/events WebhookController@events
POST /api/v1/partners/webhooks/test WebhookController@test

Models Used

The controllers leverage existing models where possible:

Controller Model(s) Used
PartnerController Partner (existing)
PartnerListingController CloudMarketplaceListing (existing)
CoSellController CoSellPlan, CoSellRelationship, Partner (all existing)
PartnerAnalyticsController CloudMarketplaceListing, CoSellPlan, Partner (all existing)
WebhookController Webhook (new)

Authentication & Authorization

  • All endpoints require auth:api authentication (already configured in routes)
  • Rate limiting applied via throttle:partner middleware
  • User ownership verified in each controller method
  • Partner access verified through team membership

Testing

Recommended tests to add:

# Create test file
php artisan make:test Api/V1/PartnerApiTest

# Run tests
php artisan test --filter=PartnerApiTest

Notes

  1. CoSell Model: The API uses CoSellPlan as the "opportunity" model. This represents joint GTM campaign plans between partners.

  2. Partner Access: Partners are accessed through the team relationship (User → Team → Partner), not directly linked to users.

  3. Webhook Limits: Webhook creation is limited by subscription tier:

  4. Starter: 2 webhooks
  5. Accelerate: 5 webhooks
  6. Command: 20 webhooks
  7. Enterprise: 100 webhooks

  8. SEO Data: SEO scores are pulled from listing metadata and compliance reports. Full SEO analysis requires the MarketplaceListingSEOCapability.


Implementation by Claude Code on February 4, 2026