{
  "openapi": "3.1.0",
  "info": {
    "title": "Craftwork Assets API",
    "version": "2.0.0",
    "description": "Public read-only access to published Craftwork design assets and catalog facets. Protected source-file URLs are not included."
  },
  "servers": [
    {
      "url": "https://craftwork.design"
    }
  ],
  "externalDocs": {
    "description": "Assets API documentation",
    "url": "https://craftwork.design/.well-known/api-docs/assets.md"
  },
  "paths": {
    "/api/v2/assets/catalog": {
      "get": {
        "operationId": "listAssets",
        "summary": "Browse published assets",
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categorySlug",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categoryIds",
            "in": "query",
            "description": "Comma-separated category IDs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subCategories",
            "in": "query",
            "description": "Comma-separated subcategory IDs. The parameter name is retained for compatibility.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tagIds",
            "in": "query",
            "description": "Comma-separated tag IDs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tagSlugs",
            "in": "query",
            "description": "Comma-separated tag slugs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filterByPrice",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["free", "paid"]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "recent",
                "popular",
                "trending",
                "created_at",
                "updated_at",
                "download_count",
                "name"
              ],
              "default": "recent"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"],
              "default": "desc"
            }
          },
          {
            "name": "taste",
            "in": "query",
            "description": "Pass 1 to let assets from packs our editors rate highly for visual quality win close calls. Meant for agents; the default order ignores it.",
            "schema": {
              "type": "string",
              "enum": ["1"]
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/AssetCatalog"
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/api/v2/assets/search": {
      "get": {
        "operationId": "searchAssets",
        "summary": "Search published assets",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Search text. The alias `query` is also accepted.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "categoryIds",
            "in": "query",
            "description": "Comma-separated category IDs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subcategoryIds",
            "in": "query",
            "description": "Comma-separated subcategory IDs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "taste",
            "in": "query",
            "description": "Pass 1 to let assets from packs our editors rate highly for visual quality win close calls. Meant for agents; the default order ignores it.",
            "schema": {
              "type": "string",
              "enum": ["1"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching public asset cards.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/assets/by-product": {
      "get": {
        "operationId": "listAssetsByProduct",
        "summary": "List published assets belonging to a product or pack",
        "parameters": [
          {
            "name": "productId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/AssetCatalog"
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/api/v2/assets/categories": {
      "get": {
        "operationId": "listAssetCategories",
        "summary": "List asset categories and public asset counts",
        "responses": {
          "200": {
            "description": "Asset category facets.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/assets/subcategories": {
      "get": {
        "operationId": "listAssetSubcategories",
        "summary": "List asset subcategories",
        "parameters": [
          {
            "name": "slug",
            "in": "query",
            "description": "Optional parent category slug.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Asset subcategory facets.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Page": {
        "name": "page",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 20
        }
      }
    },
    "responses": {
      "AssetCatalog": {
        "description": "A page of public asset cards.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AssetCatalogResponse"
            }
          }
        }
      },
      "ValidationError": {
        "description": "One or more query parameters are invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/JsonResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "AssetCatalogResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "required": ["data", "pagination"],
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AssetCard"
                }
              },
              "pagination": {
                "$ref": "#/components/schemas/Pagination"
              }
            }
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": true
      },
      "AssetCard": {
        "type": "object",
        "required": ["id", "name", "slug", "isFree"],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "preview": {
            "type": ["object", "null"],
            "additionalProperties": true
          },
          "downloadCount": {
            "type": "integer",
            "minimum": 0
          },
          "isFree": {
            "type": "boolean"
          },
          "hasAssetLink": {
            "type": "boolean"
          },
          "hasFigmaLink": {
            "type": "boolean"
          },
          "hasFramerLink": {
            "type": "boolean"
          },
          "productId": {
            "type": ["integer", "null"]
          }
        },
        "additionalProperties": true
      },
      "Pagination": {
        "type": "object",
        "required": ["page", "limit", "total", "totalPages", "hasNextPage", "hasPrevPage"],
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "limit": {
            "type": "integer",
            "minimum": 1
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "totalPages": {
            "type": "integer",
            "minimum": 0
          },
          "hasNextPage": {
            "type": "boolean"
          },
          "hasPrevPage": {
            "type": "boolean"
          }
        }
      },
      "JsonResponse": {
        "type": "object",
        "additionalProperties": true
      }
    }
  }
}
