API Reference

Base URL: https://www.cockpitkingdom.com/public/api

All protected endpoints require a Bearer token in the Authorization header:
Authorization: Bearer ck_your_token_here

Get your token via POST /public/api/auth/register or POST /public/api/auth/login.

🔐 Authentication

POST /public/api/auth/register

Create a new seller account and receive an API token.

Request body (JSON)

{
  "username": "simbuilder42",
  "email": "you@example.com",
  "password": "SecurePass123"
}

Response 201

{
  "success": true,
  "data": {
    "user": { "id": 5, "username": "simbuilder42", "role": "seller" },
    "token": "ck_a1b2c3d4..."
  }
}
POST /public/api/auth/login

Authenticate and retrieve your token.

Request body

{ "email": "you@example.com", "password": "SecurePass123" }
GET /public/api/auth/me 🔒 auth

Returns the authenticated user's info, profile and stats.

POST /public/api/auth/token 🔒 auth

Generate an additional token (e.g. for a specific integration).

{ "label": "My app integration" }
GET /public/api/auth/tokens 🔒 auth

List all your tokens. Add ?id=X with DELETE method to revoke one.

📦 Products

GET /public/api/products/public

Browse all marketplace products. No authentication required.

Query parameters

ParamTypeDescription
qstringKeyword search (title, description, seller)
typedigital|physicalFilter by product type
catintCategory ID
sortnewest|oldest|price_asc|price_desc|popularSort order
pageintPage number (default 1)
per_pageintResults per page (max 50)
GET /public/api/products 🔒 auth

List your own products with pagination and filters.

POST /public/api/products 🔒 auth

Create a new product.

Request body (JSON)

{
  "title": "B737 MCP Panel Config",
  "description": "Complete MCP configuration for MSFS 2020...",
  "price_cents": 1999,
  "type": "digital",
  "category_id": 2
}
FieldTypeDescription
titlestring*Product name (3–255 chars)
descriptionstring*Full description (min 10 chars)
price_centsint*Price in euro cents (0 = free)
typedigital|physical*Product type
stock_qtyintStock (physical only, default 0)
category_idintCategory ID (see /public/api/categories)
GET /public/api/products/{id} 🔒 auth

Full product detail including images, files, stats and category.

PUT /public/api/products/{id} 🔒 auth

Full replacement update (all fields required).

PATCH /public/api/products/{id} 🔒 auth

Partial update — only send the fields you want to change.

{ "price_cents": 2499, "stock_qty": 10 }
DELETE /public/api/products/{id} 🔒 auth

Permanently delete a product and all its media files.

POST /public/api/products/{id}/image 🔒 auth

Upload a product image. Send as multipart/form-data, field name: image. Max 8MB. JPG, PNG, WebP, GIF.

curl -X POST https://www.cockpitkingdom.com/public/api/products/5/image \
  -H "Authorization: Bearer ck_..." \
  -F "image=@/path/to/photo.jpg"
DELETE /public/api/products/{id}/image/{mediaId} 🔒 auth

Remove a specific image. Get mediaId from the product detail response.

POST /public/api/products/{id}/file 🔒 auth

Upload the downloadable file for a digital product. Field: file. Max 200MB.

👤 Profile

GET /public/api/profile 🔒 auth

Get your public profile, account info, and token list.

PUT /public/api/profile 🔒 auth

Update your public profile. All fields optional with PATCH semantics.

{
  "bio": "B737 sim builder based in Paris",
  "location": "Paris, France",
  "sim_platform": "MSFS 2020, X-Plane 12",
  "website": "https://mysite.com"
}
POST /public/api/profile/avatar 🔒 auth

Upload your avatar. multipart/form-data, field: avatar. Max 4MB. JPG, PNG, WebP.

📋 Orders

GET /public/api/orders 🔒 auth

List orders received for your products. Includes revenue summary in meta.

ParamTypeDescription
statuspending|paid|shipped|cancelledFilter by status
product_idintFilter by product
pageintPage number
GET /public/api/orders/{id} 🔒 auth

Full order detail including buyer info.

PUT /public/api/orders/{id}/status 🔒 auth

Update order status (useful for physical products).

{ "status": "shipped" }

🏷️ Categories

GET /public/api/categories

List all categories with product count. No authentication required.

Example response

{
  "success": true,
  "data": [
    { "id": 1, "name": "MCP Panels", "slug": "mcp-panels", "product_count": 12 },
    { "id": 2, "name": "Arduino Scripts", "slug": "arduino-scripts", "product_count": 7 }
  ]
}

⚠️ Error responses

HTTP CodeMeaning
400Bad request / missing required field
401Missing or invalid token
403Forbidden (role mismatch)
404Resource not found
405Method not allowed
409Conflict (e.g. duplicate email)
413File too large
415Unsupported file type
422Validation error (see errors field)
500Server error
{
  "success": false,
  "error": "Validation failed.",
  "errors": {
    "title": ["title is required."],
    "price_cents": ["price_cents must be numeric."]
  }
}

🚀 Quick start (curl)

# 1. Create account
curl -X POST https://www.cockpitkingdom.com/public/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username":"pilot42","email":"you@test.com","password":"MyPass123"}'

# → save the token from the response

TOKEN="ck_your_token_here"

# 2. Create a product
curl -X POST https://www.cockpitkingdom.com/public/api/products \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"B737 MCP Config","description":"Full config for MSFS 2020 B737","price_cents":1499,"type":"digital"}'

# → save the product id

PRODUCT_ID=7

# 3. Upload an image
curl -X POST https://www.cockpitkingdom.com/public/api/products/$PRODUCT_ID/image \
  -H "Authorization: Bearer $TOKEN" \
  -F "image=@/path/to/screenshot.jpg"

# 4. Upload the downloadable file
curl -X POST https://www.cockpitkingdom.com/public/api/products/$PRODUCT_ID/file \
  -H "Authorization: Bearer $TOKEN" \
  -F "file=@/path/to/config.zip"

# 5. Check your orders
curl https://www.cockpitkingdom.com/public/api/orders \
  -H "Authorization: Bearer $TOKEN"

CockpitKingdom API v1.0 — Back to marketplace