# EndpointReference

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

Represents an endpoint reference for a resource with endpoints.

## Definition

```typescript
interface EndpointReference
  extends IExpressionValue,
    IManifestExpressionProvider,
    IValueProvider,
    IValueWithReferences {
  readonly endpointName: string;
  readonly errorMessage: string;
  readonly excludeReferenceEndpoint: boolean;
  readonly exists: boolean;
  readonly host: string;
  readonly isAllocated: boolean;
  readonly isHttp: boolean;
  readonly isHttps: boolean;
  readonly isHttpSchemeNamedEndpoint: boolean;
  readonly port: number;
  readonly resource: IResourceWithEndpoints;
  readonly scheme: string;
  readonly targetPort: number;
  readonly tlsEnabled: boolean;
  readonly url: string;
  getTlsValue(
      enabledValue: ReferenceExpression,
      disabledValue: ReferenceExpression): ReferenceExpression;
  getValueAsync(cancellationToken?: cancellationToken): string;
  property(property: EndpointProperty): EndpointReferenceExpression;
}
```

## Properties

- `endpointName`: `string` `get` -- Gets the name of the endpoint associated with the endpoint reference.
- `errorMessage`: `string` `get` -- Gets or sets a custom error message to be thrown when the endpoint annotation is not found.
- `excludeReferenceEndpoint`: `boolean` `get` -- Gets a value indicating whether this endpoint is excluded from the default set when referencing the resource's endpoints.
- `exists`: `boolean` `get` -- Gets a value indicating whether the endpoint exists.
- `host`: `string` `get` -- Gets the host for this endpoint.
- `isAllocated`: `boolean` `get` -- Gets a value indicating whether the endpoint is allocated.
- `isHttp`: `boolean` `get` -- Gets a value indicating whether the endpoint uses HTTP scheme.
- `isHttps`: `boolean` `get` -- Gets a value indicating whether the endpoint uses HTTPS scheme.
- `isHttpSchemeNamedEndpoint`: `boolean` `get` -- Gets a value indicating whether the endpoint name is "http" or "https", ignoring case. This is a convention used to identify endpoints that will be resolved based on the scheme of the endpoint in service discovery rather than by the specific endpoint name. This is done to allow http endpoints that are dynamically updated to https to be mapped correctly despite the endpoint name no longer matching the scheme.
- `port`: `number` `get` -- Gets the port for this endpoint.
- `resource`: [IResourceWithEndpoints](/reference/api/typescript/aspire.hosting/iresourcewithendpoints.md) `get` -- Gets the resource owner of the endpoint reference.
- `scheme`: `string` `get` -- Gets the scheme for this endpoint.
- `targetPort`: `number` `get` -- Gets the target port for this endpoint. If the port is dynamically allocated, this will return `null`.
- `tlsEnabled`: `boolean` `get` -- Gets a value indicating whether TLS is enabled for this endpoint.
- `url`: `string` `get` -- Gets the URL for this endpoint.

## Methods

- [getTlsValue](/reference/api/typescript/aspire.hosting/endpointreference/gettlsvalue.md) -- `method` -- Gets a conditional expression that resolves to the enabledValue when TLS is enabled on the endpoint, or to the disabledValue otherwise.
    ```typescript
  getTlsValue(enabledValue: ReferenceExpression, disabledValue: ReferenceExpression): ReferenceExpression
  ```
- [getValueAsync](/reference/api/typescript/aspire.hosting/endpointreference/getvalueasync.md) -- `method` -- Gets the URL of the endpoint asynchronously. Waits for the endpoint to be allocated if necessary.
    ```typescript
  getValueAsync(cancellationToken?: cancellationToken): string
  ```
- [property](/reference/api/typescript/aspire.hosting/endpointreference/property.md) -- `method` -- Gets the specified property expression of the endpoint.
    ```typescript
  property(property: EndpointProperty): EndpointReferenceExpression
  ```
