# WithApiPermissions

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

Declares that this registration requires delegated permissions to scopes of another registration in the AppHost.

## Remarks

This adds the scopes to the registration's API permissions, the list shown in the portal. It grants nothing:
users are prompted to consent the first time they sign in unless an administrator consents
(`WithAdminConsent`)
or `api` pre-authorizes the caller (`WithPreAuthorizedApplication`).
A token request can cover the scopes of only one API. Request the scopes of each API in a separate token request.
For an existing caller, only consumer DownstreamApis configuration is emitted; configure its API permissions manually.
```
var entraApi = builder.AddEntraIdApplication("entra-api")
.WithScope("access_as_user", "Allows the app to call the API on behalf of the signed-in user.");
var entraWeb = builder.AddEntraIdApplication("entra-web")
.WithApiPermissions(entraApi, "access_as_user");
```

## Definition

```go
func (EntraIdApplicationResource) WithApiPermissions(
    api EntraIdApplicationResource,
    scopeNames []string,
) EntraIdApplicationResource
```

## Parameters

- `api` ([`EntraIdApplicationResource`](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md)) -- The registration that exposes the scopes.
- `scopeNames` (`[]string`) -- The names of the scopes, added with `WithScope` to `api`.

## Returns

[`EntraIdApplicationResource`](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md) -- The resource builder for chaining.

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

## Applies to

- [`EntraIdApplicationResource`](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md)
