{
  "openapi": "3.0.3",
  "info": {
    "title": "Crescitaly API",
    "version": "1.1.0",
    "description": "Public API schema for Crescitaly dashboard, storefront, and reseller flows."
  },
  "servers": [
    {
      "url": "https://app.crescitaly.com/api"
    }
  ],
  "paths": {
    "/services": {
      "get": {
        "summary": "List services",
        "description": "Get the raw array of available public services.",
        "tags": [
          "Services"
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category filter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "platform",
            "in": "query",
            "required": false,
            "description": "Platform filter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Service status filter",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Service"
                  }
                },
                "examples": {
                  "services": {
                    "summary": "Service catalog",
                    "value": [
                      {
                        "id": "cuid_service",
                        "name": "Instagram Followers",
                        "description": "Instagram follower delivery service",
                        "price": 4.99,
                        "category": "Instagram Followers",
                        "platform": "Instagram",
                        "enabled": true,
                        "min": 100,
                        "max": 100000,
                        "avgTime": "0-6 hours",
                        "linkExample": "https://instagram.com/yourprofile"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "summary": "Authenticate user",
        "description": "Authenticate a user. A completed login sets HttpOnly session and readable CSRF cookies; it never returns the session JWT in JSON. Two-factor accounts receive a temporary challenge response instead.",
        "tags": [
          "Auth"
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "description": "Account email",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "description": "Account password",
                    "format": "password"
                  },
                  "otpCode": {
                    "type": "string",
                    "description": "Six-digit two-factor code when the account requires it",
                    "pattern": "^\\d{6}$"
                  }
                },
                "required": [
                  "email",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "headers": {
              "Set-Cookie": {
                "description": "A completed login sets crescitaly_auth (HttpOnly) and crescitaly_csrf cookies. Multiple Set-Cookie headers can be returned.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthSessionResponse"
                    },
                    {
                      "$ref": "#/components/schemas/TwoFactorChallengeResponse"
                    }
                  ]
                },
                "examples": {
                  "session": {
                    "summary": "Cookie-backed session created",
                    "value": {
                      "user": {
                        "id": "cuid_user",
                        "email": "user@example.com",
                        "name": "User",
                        "role": "customer"
                      }
                    }
                  },
                  "twoFactor": {
                    "summary": "Two-factor challenge required",
                    "value": {
                      "requiresTwoFactor": true,
                      "tempToken": "temporary-2fa-token"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "post": {
        "summary": "Create order",
        "description": "Create an order using a cookie session, bearer session JWT, or API key. Cookie-authenticated mutations also require the matching CSRF token.",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "cookieAuth": [],
            "csrfToken": []
          },
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serviceId": {
                    "type": "string",
                    "description": "Service ID"
                  },
                  "link": {
                    "type": "string",
                    "description": "Target URL",
                    "format": "uri"
                  },
                  "quantity": {
                    "type": "integer",
                    "description": "Order quantity",
                    "minimum": 1
                  }
                },
                "required": [
                  "serviceId",
                  "link",
                  "quantity"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/CreatedOrderResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ApiKeyOrder"
                    }
                  ]
                },
                "examples": {
                  "session": {
                    "summary": "Created session order",
                    "value": {
                      "id": "cuid_order",
                      "publicOrderId": "ORD-12345",
                      "orderId": "ORD-12345",
                      "userId": "cuid_user",
                      "serviceId": "cuid_service",
                      "serviceName": "Instagram Followers",
                      "servicePlatform": "Instagram",
                      "link": "https://instagram.com/yourprofile",
                      "quantity": 1000,
                      "status": "PENDING",
                      "normalizedStatus": "pending",
                      "amount": 4.99,
                      "charge": "4.99",
                      "service": {
                        "name": "Instagram Followers",
                        "platform": "Instagram"
                      },
                      "createdAt": "2026-08-02T12:00:00.000Z",
                      "updatedAt": "2026-08-02T12:00:00.000Z",
                      "commercialDetails": {
                        "clientName": null,
                        "targetUsername": "yourprofile",
                        "targetPlatform": "Instagram",
                        "campaignName": null,
                        "sellPrice": null,
                        "sellCurrency": null,
                        "inferredTargetUsername": "yourprofile",
                        "inferredTargetPlatform": "Instagram"
                      }
                    }
                  },
                  "apiKey": {
                    "summary": "Created order through the API-key branch",
                    "value": {
                      "id": "cuid_order",
                      "order": "cuid_order",
                      "order_id": "cuid_order",
                      "public_order_id": "ORD-12345",
                      "publicOrderId": "ORD-12345",
                      "orderId": "ORD-12345",
                      "status": "Pending",
                      "normalizedStatus": "pending",
                      "charge": "4.9900",
                      "amount": 4.99,
                      "quantity": 1000,
                      "start_count": "0",
                      "remains": "1000",
                      "currency": "USD",
                      "userId": "cuid_user",
                      "serviceId": "cuid_service",
                      "serviceName": "Instagram Followers",
                      "servicePlatform": "Instagram",
                      "service": {
                        "name": "Instagram Followers",
                        "platform": "Instagram"
                      },
                      "link": "https://instagram.com/yourprofile",
                      "createdAt": "2026-08-02T12:00:00.000Z",
                      "updatedAt": "2026-08-02T12:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/orders/api": {
      "post": {
        "summary": "Create API order",
        "description": "Create an order using API key authentication for B2B or reseller flows.",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serviceId": {
                    "type": "string",
                    "description": "Service ID"
                  },
                  "link": {
                    "type": "string",
                    "description": "Target URL",
                    "format": "uri"
                  },
                  "quantity": {
                    "type": "integer",
                    "description": "Order quantity",
                    "minimum": 1
                  }
                },
                "required": [
                  "serviceId",
                  "link",
                  "quantity"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyLegacyCreateOrder"
                },
                "examples": {
                  "order": {
                    "summary": "Created API order",
                    "value": {
                      "id": "cuid_order",
                      "order": "cuid_order",
                      "order_id": "cuid_order",
                      "public_order_id": "ORD-12345",
                      "publicOrderId": "ORD-12345",
                      "orderId": "ORD-12345",
                      "status": "PENDING",
                      "normalizedStatus": "pending",
                      "charge": "4.9900",
                      "amount": 4.99,
                      "quantity": 1000,
                      "start_count": "0",
                      "remains": "1000",
                      "currency": "USD",
                      "userId": "cuid_user",
                      "serviceId": "cuid_service",
                      "serviceName": "Instagram Followers",
                      "servicePlatform": "Instagram",
                      "service": {
                        "name": "Instagram Followers",
                        "platform": "Instagram"
                      },
                      "link": "https://instagram.com/yourprofile",
                      "createdAt": "2026-08-02T12:00:00.000Z",
                      "updatedAt": "2026-08-02T12:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "summary": "Get order",
        "description": "Get order status and details using a session or API key.",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "cookieAuth": []
          },
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Order ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/CustomerOrderStatusResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ApiKeyOrder"
                    }
                  ]
                },
                "examples": {
                  "session": {
                    "summary": "Order details for a session",
                    "value": {
                      "id": "cuid_order",
                      "publicOrderId": "ORD-12345",
                      "userId": "cuid_user",
                      "serviceId": "cuid_service",
                      "serviceName": "Instagram Followers",
                      "link": "https://instagram.com/yourprofile",
                      "quantity": 1000,
                      "status": "completed",
                      "amount": 4.99,
                      "createdAt": "2026-08-02T12:00:00.000Z",
                      "updatedAt": "2026-08-02T12:30:00.000Z",
                      "commercialDetails": {
                        "clientName": null,
                        "targetUsername": "yourprofile",
                        "targetPlatform": "Instagram",
                        "campaignName": null,
                        "sellPrice": null,
                        "sellCurrency": null,
                        "inferredTargetUsername": "yourprofile",
                        "inferredTargetPlatform": "Instagram"
                      },
                      "startCount": 1000,
                      "remains": 0,
                      "completedAt": "2026-08-02T12:30:00.000Z"
                    }
                  },
                  "apiKey": {
                    "summary": "Order details for an API key",
                    "value": {
                      "id": "cuid_order",
                      "order": "cuid_order",
                      "order_id": "cuid_order",
                      "public_order_id": "ORD-12345",
                      "publicOrderId": "ORD-12345",
                      "orderId": "ORD-12345",
                      "status": "Completed",
                      "normalizedStatus": "completed",
                      "charge": "4.9900",
                      "amount": 4.99,
                      "quantity": 1000,
                      "start_count": "0",
                      "remains": "0",
                      "currency": "USD"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/wallet/balance": {
      "get": {
        "summary": "Get wallet balance",
        "description": "Get the authenticated wallet balance. Session authentication returns the dashboard balance summary; API-key authentication returns the integration balance and currency.",
        "tags": [
          "Wallet"
        ],
        "security": [
          {
            "cookieAuth": []
          },
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WalletSessionBalance"
                    },
                    {
                      "$ref": "#/components/schemas/ApiKeyWalletBalance"
                    }
                  ]
                },
                "examples": {
                  "session": {
                    "summary": "Cookie or bearer session response",
                    "value": {
                      "balance": 150,
                      "totalDeposits": 225,
                      "totalSpent": 75
                    }
                  },
                  "apiKey": {
                    "summary": "API-key response",
                    "value": {
                      "balance": "150.00",
                      "currency": "USD"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api-keys": {
      "post": {
        "summary": "Create API key",
        "description": "Create an API key from an authenticated session. Cookie-authenticated mutations also require the matching CSRF token.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "cookieAuth": [],
            "csrfToken": []
          },
          {
            "bearerAuth": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Human-readable label"
                  },
                  "expiresAt": {
                    "type": "string",
                    "description": "ISO expiration date",
                    "format": "date-time"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateApiKeyResponse"
                },
                "examples": {
                  "apiKey": {
                    "summary": "Created API key",
                    "value": {
                      "apiKey": {
                        "id": "cuid_api_key",
                        "userId": "cuid_user",
                        "name": "Reseller Key",
                        "isActive": true,
                        "createdAt": "2026-08-02T12:00:00.000Z"
                      },
                      "key": "crescitaly_xxxxxxxxx"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/market-insights/competitor": {
      "get": {
        "summary": "Get competitor snapshot",
        "description": "Get public competitor snapshot by domain and optional platform.",
        "tags": [
          "Market insights"
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Competitor domain",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "platform",
            "in": "query",
            "required": false,
            "description": "Social platform filter",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompetitorSnapshot"
                },
                "examples": {
                  "snapshot": {
                    "summary": "Competitor pricing snapshot",
                    "value": {
                      "domain": "justanotherpanel.com",
                      "platform": "instagram",
                      "available": true,
                      "totalPanels": 1,
                      "totalServices": 128,
                      "lastUpdated": "2026-08-02T12:00:00.000Z",
                      "panels": [
                        {
                          "id": "cuid_competitor_panel",
                          "name": "JustAnotherPanel",
                          "apiUrl": "https://justanotherpanel.com/api",
                          "lastSyncAt": "2026-08-02T12:00:00.000Z",
                          "serviceCount": 128
                        }
                      ],
                      "categories": [
                        {
                          "category": "followers",
                          "avgPrice": 3.49,
                          "minPrice": 2.99,
                          "maxPrice": 4.2,
                          "serviceCount": 24
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Origin or CSRF validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "crescitaly_auth",
        "description": "HttpOnly session cookie set by POST /auth/login."
      },
      "csrfToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-CSRF-Token",
        "description": "Required with cookieAuth on mutating requests; its value must match the crescitaly_csrf cookie."
      },
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Session JWT accepted by protected routes. POST /auth/login does not expose this token in JSON."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "User": {
        "type": "object",
        "required": [
          "id",
          "email",
          "role"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "role": {
            "type": "string"
          },
          "isAdmin": {
            "type": "boolean"
          },
          "isStaff": {
            "type": "boolean"
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "twoFactorEnabled": {
            "type": "boolean"
          }
        }
      },
      "AuthSessionResponse": {
        "type": "object",
        "required": [
          "user"
        ],
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          }
        },
        "additionalProperties": false
      },
      "TwoFactorChallengeResponse": {
        "type": "object",
        "required": [
          "requiresTwoFactor",
          "tempToken"
        ],
        "properties": {
          "requiresTwoFactor": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "tempToken": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "Service": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "price",
          "category",
          "platform",
          "enabled"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "price": {
            "type": "number"
          },
          "category": {
            "type": "string"
          },
          "platform": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "min": {
            "type": "integer"
          },
          "max": {
            "type": "integer"
          },
          "avgTime": {
            "type": "string"
          },
          "linkExample": {
            "type": "string"
          }
        }
      },
      "CreatedOrderResponse": {
        "type": "object",
        "required": [
          "id",
          "publicOrderId",
          "orderId",
          "userId",
          "serviceId",
          "link",
          "quantity",
          "status",
          "normalizedStatus",
          "amount",
          "charge",
          "service",
          "createdAt",
          "updatedAt",
          "commercialDetails"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "publicOrderId": {
            "type": "string"
          },
          "orderId": {
            "type": "string",
            "deprecated": true
          },
          "userId": {
            "type": "string"
          },
          "serviceId": {
            "type": "string"
          },
          "serviceName": {
            "type": "string"
          },
          "servicePlatform": {
            "type": "string"
          },
          "service": {
            "type": "object",
            "deprecated": true,
            "required": [
              "name",
              "platform"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "platform": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "link": {
            "type": "string",
            "format": "uri"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "description": "Legacy create-response status vocabulary.",
            "enum": [
              "PENDING",
              "PROCESSING",
              "IN_PROGRESS",
              "COMPLETED",
              "PARTIAL",
              "CANCELLED",
              "REFUNDED"
            ]
          },
          "normalizedStatus": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "in_progress",
              "completed",
              "partial",
              "cancelled",
              "refunded"
            ]
          },
          "amount": {
            "type": "number"
          },
          "charge": {
            "type": "string",
            "deprecated": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "commercialDetails": {
            "$ref": "#/components/schemas/OrderCommercialDetails"
          },
          "startCount": {
            "type": "integer"
          },
          "remains": {
            "type": "integer"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "OrderCommercialDetails": {
        "type": "object",
        "required": [
          "clientName",
          "targetUsername",
          "targetPlatform",
          "campaignName",
          "sellPrice",
          "sellCurrency",
          "inferredTargetUsername",
          "inferredTargetPlatform"
        ],
        "properties": {
          "clientName": {
            "type": "string",
            "nullable": true
          },
          "targetUsername": {
            "type": "string",
            "nullable": true
          },
          "targetPlatform": {
            "type": "string",
            "nullable": true
          },
          "campaignName": {
            "type": "string",
            "nullable": true
          },
          "sellPrice": {
            "type": "number",
            "nullable": true
          },
          "sellCurrency": {
            "type": "string",
            "nullable": true
          },
          "inferredTargetUsername": {
            "type": "string",
            "nullable": true
          },
          "inferredTargetPlatform": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CustomerOrderStatusResponse": {
        "type": "object",
        "required": [
          "id",
          "publicOrderId",
          "userId",
          "serviceId",
          "link",
          "quantity",
          "status",
          "amount",
          "createdAt",
          "updatedAt",
          "commercialDetails"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "publicOrderId": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "serviceId": {
            "type": "string"
          },
          "serviceName": {
            "type": "string"
          },
          "servicePlatform": {
            "type": "string"
          },
          "link": {
            "type": "string",
            "format": "uri"
          },
          "quantity": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "in_progress",
              "completed",
              "partial",
              "cancelled",
              "refunded"
            ]
          },
          "amount": {
            "type": "number"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "commercialDetails": {
            "$ref": "#/components/schemas/OrderCommercialDetails"
          },
          "startCount": {
            "type": "integer"
          },
          "remains": {
            "type": "integer"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "ApiKeyOrder": {
        "type": "object",
        "required": [
          "id",
          "order",
          "order_id",
          "public_order_id",
          "publicOrderId",
          "orderId",
          "status",
          "normalizedStatus",
          "charge",
          "amount",
          "quantity",
          "start_count",
          "remains",
          "currency"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "order": {
            "type": "string"
          },
          "order_id": {
            "type": "string"
          },
          "public_order_id": {
            "type": "string"
          },
          "publicOrderId": {
            "type": "string"
          },
          "orderId": {
            "type": "string",
            "deprecated": true
          },
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "In progress",
              "Completed",
              "Partial",
              "Canceled",
              "Refunded"
            ]
          },
          "normalizedStatus": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "in_progress",
              "completed",
              "partial",
              "cancelled",
              "refunded"
            ]
          },
          "charge": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{4}$"
          },
          "amount": {
            "type": "number"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "start_count": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "remains": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "userId": {
            "type": "string"
          },
          "serviceId": {
            "type": "string"
          },
          "serviceName": {
            "type": "string"
          },
          "servicePlatform": {
            "type": "string"
          },
          "service": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "platform": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "link": {
            "type": "string",
            "format": "uri"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "ApiKeyLegacyCreateOrder": {
        "type": "object",
        "required": [
          "id",
          "order",
          "order_id",
          "public_order_id",
          "publicOrderId",
          "orderId",
          "status",
          "normalizedStatus",
          "charge",
          "amount",
          "quantity",
          "start_count",
          "remains",
          "currency"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "order": {
            "type": "string"
          },
          "order_id": {
            "type": "string"
          },
          "public_order_id": {
            "type": "string"
          },
          "publicOrderId": {
            "type": "string"
          },
          "orderId": {
            "type": "string",
            "deprecated": true
          },
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "PROCESSING",
              "IN_PROGRESS",
              "COMPLETED",
              "PARTIAL",
              "CANCELLED",
              "REFUNDED"
            ]
          },
          "normalizedStatus": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "in_progress",
              "completed",
              "partial",
              "cancelled",
              "refunded"
            ]
          },
          "charge": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{4}$"
          },
          "amount": {
            "type": "number"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "start_count": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "remains": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "userId": {
            "type": "string"
          },
          "serviceId": {
            "type": "string"
          },
          "serviceName": {
            "type": "string"
          },
          "servicePlatform": {
            "type": "string"
          },
          "service": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "platform": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "link": {
            "type": "string",
            "format": "uri"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "WalletSessionBalance": {
        "type": "object",
        "required": [
          "balance",
          "totalDeposits",
          "totalSpent"
        ],
        "properties": {
          "balance": {
            "type": "number"
          },
          "totalDeposits": {
            "type": "number"
          },
          "totalSpent": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "ApiKeyWalletBalance": {
        "type": "object",
        "required": [
          "balance",
          "currency"
        ],
        "properties": {
          "balance": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          }
        },
        "additionalProperties": false
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "userId",
          "isActive",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "key": {
            "type": "string",
            "nullable": true
          },
          "maskedKey": {
            "type": "string",
            "nullable": true
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "isActive": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateApiKeyResponse": {
        "type": "object",
        "required": [
          "apiKey",
          "key"
        ],
        "properties": {
          "apiKey": {
            "$ref": "#/components/schemas/ApiKey"
          },
          "key": {
            "type": "string",
            "description": "Raw API key. It is returned only once at creation time."
          }
        },
        "additionalProperties": false
      },
      "CompetitorSnapshot": {
        "type": "object",
        "required": [
          "domain",
          "platform",
          "available",
          "totalPanels",
          "totalServices",
          "lastUpdated",
          "panels",
          "categories"
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "platform": {
            "type": "string",
            "nullable": true
          },
          "available": {
            "type": "boolean"
          },
          "totalPanels": {
            "type": "integer"
          },
          "totalServices": {
            "type": "integer"
          },
          "lastUpdated": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "panels": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name",
                "apiUrl",
                "lastSyncAt",
                "serviceCount"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "apiUrl": {
                  "type": "string",
                  "format": "uri"
                },
                "lastSyncAt": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true
                },
                "serviceCount": {
                  "type": "integer"
                }
              }
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "category",
                "avgPrice",
                "minPrice",
                "maxPrice",
                "serviceCount"
              ],
              "properties": {
                "category": {
                  "type": "string"
                },
                "avgPrice": {
                  "type": "number"
                },
                "minPrice": {
                  "type": "number"
                },
                "maxPrice": {
                  "type": "number"
                },
                "serviceCount": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "message": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "error": {
            "type": "string"
          },
          "statusCode": {
            "type": "integer"
          }
        }
      }
    }
  }
}