{
  "post": {
    "tags": ["Image Processing"],
    "summary": "Remove background from image",
    "description": "Removes the background from an image using a third-party API service. The processed image is saved to the media directory following the PHP structure.\n\n**Authentication:**\n- Requires `API-KEY` header with the encryption key (UUID) returned from `/api/save-credentials`\n- The encryption key must have `removeBackground` credentials configured\n\n**File Structure:**\n- Processed images are saved to: `{mediaPath}/{original_dir}/{original_filename}/converted/{original_filename}_pdrembg.png`",
    "security": [
      {
        "ApiKeyAuth": []
      }
    ],
    "requestBody": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "image_url": {
                "type": "string",
                "format": "uri",
                "description": "URL of the image to process",
                "example": "https://example.com/image.jpg"
              },
              "image_convert_type": {
                "type": "string",
                "description": "Optional image conversion type",
                "example": "png"
              }
            },
            "required": ["image_url"]
          }
        }
      }
    },
    "responses": {
      "200": {
        "description": "Background removed successfully.",
        "summary": "Successful Operation.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "example": "Background removed successfully"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["Success"],
                      "example": "Success"
                    },
                    "message": {
                      "type": "string",
                      "example": "Background removed successfully"
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "file": {
                          "type": "string",
                          "description": "Relative path to the processed image from media root",
                          "example": "productdesigner/imagecolor/sample/converted/sample_pdrembg.png"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "400": {
        "description": "Bad Request - Invalid parameters or missing required fields.",
        "summary": "Bad Request.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "examples": ["Invalid image URL or missing required fields"]
                }
              }
            }
          }
        }
      },
      "401": {
        "description": "Unauthorized - Missing or invalid encryption key in API-KEY header, or remove background credentials not configured.",
        "summary": "Unauthorized.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "examples": [
                    "Encryption key missing. Please provide encryption key in API-KEY header.",
                    "Invalid encryption key format. Expected UUID format.",
                    "Failed to decrypt credentials. Invalid encryption key or corrupted credential file.",
                    "Credential not found. Please ensure credentials are saved and the correct encryption key is provided.",
                    "Remove background credentials not configured for this encryption key. Please save remove background credentials first."
                  ]
                }
              }
            }
          }
        }
      },
      "500": {
        "description": "Internal Server Error - Failed to process the image.",
        "summary": "Internal Server Error.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "example": "Failed to process image"
                }
              }
            }
          }
        }
      }
    }
  }
}
