> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dbhost.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Set database environment label

> Change a DBHost database's environment label to production, staging, development, other or none through the API. Backup schedule is unchanged.

Sets the environment label of one database. Selected-database keys can change
databases they are assigned to; full-account keys can change any database you
own. API access requires a Pro or Business plan.

<Note>
  This route changes the label only. It does not change the database's
  scheduled backup choice, which is set when the database is created. See
  [Backups and retention](/backups-and-retention) for the backup policy per
  environment.
</Note>

## Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `environment` | string or `null` | Yes | `production`, `staging`, `development`, `other`, or `null` to clear the label |

```http theme={null}
PATCH /api/v1/databases/{id}/environment
Authorization: Bearer <api-key>
Content-Type: application/json

{"environment":"staging"}
```

## Response

```json 200 OK theme={null}
{
  "message": "Database environment updated.",
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "environment": "staging"
  }
}
```

The change is recorded in the database's activity log.

## Errors

| Status | Code | Description |
| - | - | - |
| 400 | `VALIDATION_ERROR` | `environment` is missing or not one of the allowed values |
| 400 | `INVALID_JSON` | Request body is not valid JSON |
| 401 | `UNAUTHORIZED` | Missing or invalid API key |
| 403 | `PLAN_API_ACCESS_REQUIRED` | The account is not on Pro or Business |
| 404 | `DATABASE_NOT_FOUND` | Database does not exist or is not visible to this key |
| 413 | `PAYLOAD_TOO_LARGE` | Request body is larger than 64 KB |
| 429 | `RATE_LIMITED` | Too many requests; retry after `Retry-After` seconds |

The CLI equivalent is
`dbhost databases environment <id> <production|staging|development|other|none>`.
In the dashboard, see [Databases](/dashboard/databases).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.