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

# Rollback Deploy History

> Rollback the API Proxy configuration to a specific deploy history revision. Optionally deploy the rolled-back version to an environment in the same request.

## Endpoint

```
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/deploy-histories/{revision}/rollback/
```

## Authentication

Requires a Personal API Access Token.

### Header

```
Authorization: Bearer YOUR_TOKEN
```

## Request

### Headers

| Header        | Value          | Required |
| ------------- | -------------- | -------- |
| Authorization | Bearer {token} | Yes      |

### Path Parameters

| Parameter    | Type    | Required | Description                                   |
| ------------ | ------- | -------- | --------------------------------------------- |
| projectName  | string  | Yes      | Project name                                  |
| apiProxyName | string  | Yes      | API Proxy name                                |
| revision     | integer | Yes      | Deploy history revision number to rollback to |

### Query Parameters

| Parameter       | Type   | Required | Description                                                                                          |
| --------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------- |
| environmentName | string | No       | If provided, the rolled-back API Proxy is automatically deployed to this environment after rollback. |

### Request Body

This endpoint does not require a request body.

## Response

### Success Response (200 OK) - Rollback Only

```json theme={null}
{
  "status": "SUCCESS",
  "resultMessage": "API Proxy rolled back successfully to deploy history revision (12)."
}
```

### Success Response (200 OK) - Rollback with Deploy

```json theme={null}
{
  "status": "SUCCESS",
  "resultMessage": "API Proxy rolled back successfully to deploy history revision (12). Deployed to environment: production"
}
```

### Partial Success Response (200 OK) - Rollback Succeeded, Deploy Failed

```json theme={null}
{
  "status": "SUCCESS",
  "resultMessage": "API Proxy rolled back successfully but deployment failed: Connection refused"
}
```

#### Response Fields

| Field         | Type   | Description                             |
| ------------- | ------ | --------------------------------------- |
| status        | string | Request status (`SUCCESS` or `FAILURE`) |
| resultMessage | string | Operation result message with details   |

### Error Response (400 Bad Request)

```json theme={null}
{
  "error": "bad_request",
  "error_description": "Rollback failed for deploy history revision (12)!"
}
```

#### Common Causes

* Deploy history record with the given revision does not exist
* Environment name does not exist (when `environmentName` is provided)
* API Proxy snapshot in the deploy history is corrupted

### Error Response (401 Unauthorized)

```json theme={null}
{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}
```

## cURL Examples

### Rollback Only (No Deploy)

```bash theme={null}
curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/petstore-api/deploy-histories/12/rollback/" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### Rollback and Deploy

```bash theme={null}
curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/petstore-api/deploy-histories/12/rollback/?environmentName=production" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## Notes and Warnings

* **Configuration Rollback**: This operation restores the API Proxy configuration (routing, policies, settings) to the state captured in the deploy history record.
* **Deploy List Preserved**: The list of environments the API Proxy is allowed to deploy to is always taken from the current state, not from the historical snapshot.
* **Optional Deploy**: When `environmentName` is provided, the rolled-back configuration is deployed to the specified environment in a single atomic operation.
* **Deploy Failure**: If the optional deploy fails, the rollback itself is still applied. The API Proxy configuration is updated, but you need to deploy manually.

## Permissions

User must have **`API_MANAGEMENT` + `MANAGE`** permission in the project.

## Related Documentation

* [List Deploy History](/api-reference/api-proxies/deployment/list-deploy-history) - List all deploy history records
* [Deploy API Proxy](/api-reference/api-proxies/deployment/deploy-api-proxy) - Deploy API proxy to environment
* [Get Deploy History Detail](/api-reference/api-proxies/deployment/get-deploy-history-detail) - Get full detail of a deploy history record
