# WithPolicy

- Module: [Aspire.Hosting.Azure.ApiManagement](/reference/api/go/aspire.hosting.azure.apimanagement.md)
- Version: `17.0.0-preview.1.26567.5`
- Kind: `method`
- Defined on: [`AzureApiManagementApiResource`](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementapiresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

Replaces the complete API-level policy document.

## Remarks

Replacing the API policy also replaces the generated backend-routing policy. The supplied document must
configure backend routing when the API should continue forwarding requests.

## Definition

```go
func (AzureApiManagementApiResource) WithPolicy(policyXml string) AzureApiManagementApiResource
```

## Parameters

- `policyXml` (`string`) -- A complete APIM `policies` XML document.

## Returns

[`AzureApiManagementApiResource`](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementapiresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`AzureApiManagementApiResource`](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementapiresource.md)
