> For the complete documentation index, see [llms.txt](https://savv-pro.gitbook.io/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://savv-pro.gitbook.io/welcome/ai-face-swap-api/status-code.md).

# Status Code

## 200 - Response Successful

**Description:** The request was successful, and the server returned the expected response. \
**Example Use Case:** The face swap operation completed successfully, and the processed image URL is returned.

```
{
  "status": "success",
  "file_url": "https://your-storage-url.com/output-image.png",
  "processing_time": 2.45
}
```

## 400 - Bad Request

**Description:** The server could not understand the request due to invalid syntax or missing required parameters.\
**Example Use Case:** The request body is malformed, or a required field is missing.

```
{
  "status": "Error",
  "message": "Invalid command or missing parameter."
}
```

## 401 - Unauthorized

**Description:** The request requires valid authentication credentials.\
**Example Use Case:** The API key is missing, incorrect, or revoked.

```
{
  "status": "Error",
  "message": "Unauthorized. Please provide a valid API key."
}
```

## 403 - Forbidden

**Description:** The server understands the request, but the client does not have permission to access the resource.\
**Example Use Case:** Attempting to access a restricted resource without sufficient privileges.

```
{
  "error": "Invalid API key",
  "type": "HTTPException"
}
```

## 404 - Not Found

**Description:** The requested resource could not be found.\
**Example Use Case:** The specified endpoint or image resource does not exist.

```
{
  "error": "Token not found",
  "type": "HTTPException"
}
```

## 415 - Unsupported Media Type

**Description:** The media format of the requested data is not supported by the server.\
**Example Use Case:** Unsupported file format or invalid image data.

```
{
  "error": "The source file is not a valid image. Please upload a valid image file.",
  "type": "UnsupportedFileTypeError"
}
```

## 422 - Unprocessable Entity

**Description:** The server understands the request but cannot process the contained instructions.\
**Example Use Case:** No faces detected in images or image processing errors.

```
{
  "error": "No faces detected in one or both of the provided images. Please ensure both images contain clearly visible faces.",
  "type": "NoFacesFoundError"
}
```

## 500 - Internal Server Error

**Description:** The server encountered an unexpected condition that prevented it from fulfilling the request.\
**Example Use Case:** Face swap processing failed, file system errors, or unexpected exceptions.

```
{
  "error": "An unexpected error occurred",
  "type": "InternalServerError",
  "detail": "Face swap operation failed: Internal processing error"
}
```

## 504 - API Server Issue

**Description:** The server encountered an unexpected condition that prevented it from fulfilling the request.\
**Example Use Case:** Face swap processing failed, file system errors, or unexpected exceptions.

```
{
"messages":"The request to the API has timed out. Please try again later, or if the issue persists, please contact the API provider"
"info":"Your Client (working) ---> Gateway (working) ---> API (took too long to respond)"
}
```
