# WithExternalApiPermissions

- 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 permissions to a Microsoft first-party or other API that is not an Aspire resource, such as Microsoft Graph.

## Remarks

For a registration created by Aspire, this adds the permissions to the registration's API permissions list. It grants nothing;
use withExternalApiAdminConsent to opt in to consent. For an existing registration, nothing is deployed: the declaration only
configures the DownstreamApis entries that resources referencing the registration receive.
Delegated permissions let the application act for a signed-in user. Application permissions let it act as itself and always need administrator consent.
The two kinds are separate permissions, even when they share a name. Well-known APIs resolve common permission names to their IDs;
other permissions, and every permission of a custom API, need an explicit id.

## Definition

```go
func (EntraIdApplicationResource) WithExternalApiPermissions(
    api any,
    permissions []*EntraIdExternalApiPermission,
) EntraIdApplicationResource
```

## Parameters

- `api` (`any`) -- A well-known API, or an API identified by its application ID and application ID URI.
- `permissions` ([`[]*EntraIdExternalApiPermission`](/reference/api/go/aspire.hosting.azure.entraid/entraidexternalapipermission.md)) -- The permissions to declare. Each is delegated unless its type is Application.

## Returns

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

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

## Applies to

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