# AzureApiManagementApiResource.WithPolicy

- Module: [Aspire.Hosting.Azure.ApiManagement](/reference/api/go/aspire.hosting.azure.apimanagement.md)
- Defined on: [AzureApiManagementApiResource](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementapiresource.md)
- Version: `17.0.0-preview.1.26567.5`
- Kind: `method`

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
type AzureApiManagementApiResource interface {
    // ... omitted for brevity
    WithPolicy(policyXml string) AzureApiManagementApiResource
}
```

## Signature

```go
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()`.

## Defined on

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