<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/EntityURLRepresentation",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents23EntityURLRepresentationV"
  },
  "title" : "EntityURLRepresentation"
}
-->

# EntityURLRepresentation

The type that provides the URL for an app entity.

```
struct EntityURLRepresentation<Entity> where Entity : AppEntity
```

## Overview

If you adopt the [`URLRepresentableEntity`](/documentation/AppIntents/URLRepresentableEntity) protocol in an app entity, use this type to build the URL for your entity.
Construct the type as a Swift string that contains characters suitable for use in a URL. To incorporate content from
your app entity’s properties into the URL, include a key path to the property in your string. The following example shows an
app entity that represents a specific inventory item. Before returning the URL, this type replaces the `\(\.$contentID)`
key path with the value in the `contentID` property.

```swift
struct MyAppData: AppEntity, URLRepresentableEntity {
    static let defaultQuery = MyAppDataQuery()

    @Property(title: "Content ID")
    var contentID: String

    static var urlRepresentation = URLRepresentation("https://example.com/note=\(.$contentID)")
}
```

Make sure the properties you include in your URL representation contain a URL-friendly type. The system automatically
converts properties of type <doc://com.apple.documentation/documentation/Swift/String>,
<doc://com.apple.documentation/documentation/Swift/Int>, and <doc://com.apple.documentation/documentation/Foundation/URL>
to values suitable for inclusion in a URL. To incorporate other types, implement the
[`CustomURLRepresentationParameterConvertible`](/documentation/AppIntents/CustomURLRepresentationParameterConvertible) protocol in the type.

## Topics

### Initializers

[`init(String)`](/documentation/AppIntents/EntityURLRepresentation/init(_:))

Creates a URL representation for an app entity using the provided Swift string.

## Relationships

### Conforms To

[`ExpressibleByStringLiteral`](/documentation/Swift/ExpressibleByStringLiteral)

[`ExpressibleByExtendedGraphemeClusterLiteral`](/documentation/Swift/ExpressibleByExtendedGraphemeClusterLiteral)

[`ExpressibleByUnicodeScalarLiteral`](/documentation/Swift/ExpressibleByUnicodeScalarLiteral)

[`ExpressibleByStringInterpolation`](/documentation/Swift/ExpressibleByStringInterpolation)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)