# Trigger service deployment

Source: https://govform.com/resources/documentation/article/33-04-api-trigger-service-deployment
Topic: Govform API & MCP

**API units: 5.** Each accepted deployment or undeployment request uses 5 units.

This endpoint triggers a service deployment. You can specify the version of the service to deploy.

## Endpoint and parameters

```
PUT /api/service-deployments/{libraryId}/{serviceId}/{version}
```

| Parameter | Description | Mandatory |
| --- | --- | --- |
| **libraryId** | The ID of the library of the service to deploy | yes |
| **serviceId** | The service ID of the service to deploy | yes |
| **version** | Provides the version number to deploy. You can find version numbers for your service listed in the Change management page of Digital Service Builder. If set to **latest**, the latest version is deployed. If set to **remove**, the service is removed from the environment. | yes |

### Query parameters

None

**Authentication:** send `GovformsApiKey <key-id>:<key-secret>` in the `Authorization` header. Substitute credentials from your secrets manager; never copy a live key into documentation, source control or logs.

## Examples

Request Headers

| Header name | value |
| --- | --- |
| Authorization | GovformsApiKey <key-id>:<key-secret> |

**Deploy latest version to QA example**

Request URL

```
PUT https://qa.cloud.govforms.uk/api/service-deployments/demo-library/demo-service-1/latest
```

Request body This endpoint does not expect a request body.   Response Headers

| Header name | value |
| --- | --- |
| Content-Type | application/json |

Response body 200 OK

```
{
  "isDeployed": true,
  "serviceVersion": 125,
  "versionTimestamp": "2023-03-14T10:51:44.288+00:00",
  "lastDeploymentTimestamp": "2023-03-15T15:22:13.552+00:00"
}
```

**Deploy specified version to Production example**

Request URL

```
PUT https://cloud.govforms.uk/api/service-deployments/demo-library/demo-service-1/125
```

Request body This endpoint does not expect a request body.   Response Headers

| Header name | value |
| --- | --- |
| Content-Type | application/json |

Response body 200 OK

```
{
  "isDeployed": true,
  "serviceVersion": 125,
  "versionTimestamp": "2023-03-14T10:51:44.288+00:00",
  "lastDeploymentTimestamp": "2023-03-15T15:22:13.552+00:00"
}
```

**Remove service from Production example**

Request URL

```
PUT https://cloud.govforms.uk/api/service-deployments/demo-library/demo-service-1/remove
```

Request body This endpoint does not expect a request body.   Response Headers

| Header name | value |
| --- | --- |
| Content-Type | application/json |

Response body 200 OK

```
{
  "isDeployed": false
}
```

* * *
