{
  "openapi": "3.1.0",
  "info": {
    "title": "redPIM API",
    "version": "1.0.0",
    "summary": "REST API for the redPIM Cloud PIM system.",
    "description": "Programmatic access to redPIM — a Cloud PIM for technical distributors by redCOMPONENTS.\n\nredPIM is the source of truth for product data: catalogs, categories, products, variants, classification (eClass / ETIM / proficlass), media and exports. This specification documents a representative subset of the REST API. Endpoints follow the action-method routing convention `/api/{Controller}/{Action}`.\n\nAuthentication: endpoints require an authenticated redPIM session (cookie `REDPim.Cookie`). Bearer-token / OAuth 2.0 access for headless agents is on the roadmap — request API access via your redPIM account (me@redcomponents.de).\n\nFor product-data sync integrations (shops, ERPs) see the connector contract documented at https://redpim.de/developers.html#connector.",
    "contact": {
      "name": "redCOMPONENTS — redPIM",
      "email": "me@redcomponents.de",
      "url": "https://redpim.de/developers.html"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://redpim.de/impressum.html"
    }
  },
  "servers": [
    {
      "url": "https://app.redpim.de/api",
      "description": "redPIM production API"
    }
  ],
  "externalDocs": {
    "description": "redPIM Developer Portal",
    "url": "https://redpim.de/developers.html"
  },
  "tags": [
    { "name": "Catalog", "description": "Catalogs, categories, products and values" },
    { "name": "Classification", "description": "eClass / ETIM / proficlass assignment" },
    { "name": "Export", "description": "BMEcat and target-system exports" },
    { "name": "Job", "description": "Background job status" }
  ],
  "security": [
    { "cookieAuth": [] }
  ],
  "paths": {
    "/Catalog/GetStats": {
      "get": {
        "tags": ["Catalog"],
        "operationId": "getCatalogStats",
        "summary": "Get catalog statistics",
        "description": "Returns aggregate statistics for the authenticated department's catalogs (counts of catalogs, categories, products).",
        "responses": {
          "200": {
            "description": "Catalog statistics",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CatalogStats" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/Catalog/AddCatalog": {
      "post": {
        "tags": ["Catalog"],
        "operationId": "addCatalog",
        "summary": "Create a catalog",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CatalogDto" }
            }
          }
        },
        "responses": {
          "200": { "description": "Catalog created" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/Catalog/UpdateCatalog": {
      "post": {
        "tags": ["Catalog"],
        "operationId": "updateCatalog",
        "summary": "Update a catalog",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CatalogDto" }
            }
          }
        },
        "responses": {
          "200": { "description": "Catalog updated" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/Catalog/AddProduct": {
      "post": {
        "tags": ["Catalog"],
        "operationId": "addProduct",
        "summary": "Create a product",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ProductDto" }
            }
          }
        },
        "responses": {
          "200": { "description": "Product created" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/Catalog/UpdateProduct": {
      "post": {
        "tags": ["Catalog"],
        "operationId": "updateProduct",
        "summary": "Update a product",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ProductDto" }
            }
          }
        },
        "responses": {
          "200": { "description": "Product updated" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/Catalog/SetValue": {
      "post": {
        "tags": ["Catalog"],
        "operationId": "setValue",
        "summary": "Set a single field value on an element",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/SetValueDto" }
            }
          }
        },
        "responses": {
          "200": { "description": "Value set" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/Export/StartExport": {
      "post": {
        "tags": ["Export"],
        "operationId": "startExport",
        "summary": "Start an export job",
        "description": "Queues an export (e.g. BMEcat or target-system) as a background job. Poll job status for completion.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/StartExportDto" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Export job queued",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/JobRef" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "REDPim.Cookie",
        "description": "Authenticated redPIM session cookie. Bearer-token / OAuth 2.0 is on the roadmap."
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Authentication required or session expired.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string", "description": "Human-readable error message" }
        }
      },
      "CatalogStats": {
        "type": "object",
        "properties": {
          "catalogs": { "type": "integer", "description": "Number of catalogs" },
          "categories": { "type": "integer", "description": "Number of categories" },
          "products": { "type": "integer", "description": "Number of products" }
        }
      },
      "CatalogDto": {
        "type": "object",
        "required": ["departmentId", "name"],
        "properties": {
          "departmentId": { "type": "string", "format": "uuid" },
          "catalogId": { "type": "string", "format": "uuid" },
          "name": { "type": "string" },
          "catalogType": { "type": "string" },
          "catalogVersion": { "type": "string" }
        }
      },
      "ProductDto": {
        "type": "object",
        "required": ["departmentId", "catalogId"],
        "properties": {
          "departmentId": { "type": "string", "format": "uuid" },
          "catalogId": { "type": "string", "format": "uuid" },
          "productId": { "type": "string", "format": "uuid" },
          "name": { "type": "string" },
          "sku": { "type": "string", "description": "Supplier article number / join key" }
        }
      },
      "SetValueDto": {
        "type": "object",
        "required": ["departmentId", "elementId", "field", "value"],
        "properties": {
          "departmentId": { "type": "string", "format": "uuid" },
          "elementId": { "type": "string", "format": "uuid" },
          "field": { "type": "string" },
          "value": { "type": "string" }
        }
      },
      "StartExportDto": {
        "type": "object",
        "required": ["departmentId", "catalogId"],
        "properties": {
          "departmentId": { "type": "string", "format": "uuid" },
          "catalogId": { "type": "string", "format": "uuid" },
          "exportType": { "type": "string", "description": "e.g. BMEcat, ERP target system" },
          "templateId": { "type": "string", "format": "uuid" }
        }
      },
      "JobRef": {
        "type": "object",
        "properties": {
          "jobId": { "type": "string", "format": "uuid", "description": "Background job id; poll for status" }
        }
      }
    }
  }
}
