> This page is for Applications Protection.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.humansecurity.com/llms.txt.

# Integration with gRPC [BETA]

The SDK can be integrated into [gRPC](https://grpc.io/) projects.

## Start the SDK

The automatic interceptor is not supported in gRPC, so you should disable requests interception by setting the `PXPolicy/requestsInterceptedAutomaticallyEnabled` to `false`.

```kotlin
policy.requestsInterceptedAutomaticallyEnabled = false
```

## Adding SDK's HTTP headers to your gRPC requests

In order to include the SDK's HTTP headers in your gRPC requests, you should add them to your request's metadata.

```kotlin
val headers = PerimeterX.INSTANCE.headersForURLRequest()
val metadata = Metadata()
for ((key, value) in headers!!) {
	metadata.put(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER), value)
}

// send you gRPC request with `metadata`...
```

Now, use the `call option` instance when you call your send your gRPC request.

## Handle block responses from your server

After receiving an error in the server's response, the gRPC library will throw an exception. pass the information to SDK with the `handleResponse` function.

```swift
try {
	// send your gRPC request...
} catch (statusException: StatusException) {
  PerimeterX.INSTANCE.handleResponse(null, statusException.status.description!!, 403)
}
```