# Errors

The HTTP status code tells you what happened; the body carries a machine-readable code.

| HTTP  | Meaning                                    | Retry?                 |
| ----- | ------------------------------------------ | ---------------------- |
| `400` | Validation or business-rule failure        | No, fix the request    |
| `401` | Missing, invalid or expired token          | Log in again, then retry |
| `403` | No permission on this project/environment  | No                     |
| `404` | Resource not found                         | No                     |
| `409` | Conflict, e.g. already exists or busy      | Sometimes, after a wait |
| `429` | Too many attempts                          | Yes, with backoff      |
| `5xx` | Server error                               | Yes, with backoff      |

## Formats

<CodeTabs>

```json title="Validation (400)"
{
  "status": "Error",
  "message": "Validation Error",
  "details": ["Name must be at least 3 characters"]
}
```

```json title="Business rule"
{
  "status": "error",
  "error": { "code": "DEPLOYMENT_NOT_FOUND", "message": "Deployment not found" }
}
```

```json title="Unauthorized (401)"
{
  "status": "error",
  "data": { "errorMessage": "Invalid token or some Error" }
}
```

```json title="Forbidden (403)"
{
  "status": "error",
  "error": { "errorCode": "CASDOOR_AUTHORIZATION_FAILED", "message": "Access denied" }
}
```

</CodeTabs>

## Common codes

| Code                   | Where              | Meaning                                             |
| ---------------------- | ------------------ | --------------------------------------------------- |
| `ENV_EXISTS`           | Environments       | An environment with that name already exists.       |
| `PROJECT_NOT_FOUND`    | Environments       | The `projectId` is wrong.                           |
| `DELETE_NOT_ALLOWED`   | Projects           | Delete the project's environments first.            |
| `ENV_DELETE_FAILED`    | Environments       | Delete the environment's deployments and tools first. |
| `DEPLOYMENT_NOT_FOUND` | Deployments        | Wrong ID, or the deployment is in another environment. |
| `INVALID_TOOL_NAME`    | Tools              | The tool name must not contain the chart name.      |
| `TOOL_BUSY`            | Tools              | A previous change is still rolling out.             |
| `VALIDATION_ERROR`     | Logs               | Invalid log query.                                  |

:::tip
Every response includes an `x-internal-correlationid` header. Include it when you contact support.
:::
