<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/EntityIdentifierConvertible",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents27EntityIdentifierConvertibleP"
  },
  "title" : "EntityIdentifierConvertible"
}
-->

# EntityIdentifierConvertible

An interface for converting between an entity’s identifier and its string
representation.

```
protocol EntityIdentifierConvertible
```

## Overview

Every entity provides a stable, unique identifier that the framework uses
as a concrete reference to the entity while mediating between your
app and other parts of the system. To enforce this requirement, the
[`AppEntity`](/documentation/AppIntents/AppEntity) protocol inherits the <doc://com.apple.documentation/documentation/Swift/Identifiable> protocol.

Wherever possible, use
<doc://com.apple.documentation/documentation/Swift/String>,
<doc://com.apple.documentation/documentation/Swift/Int>, or
<doc://com.apple.documentation/documentation/Foundation/UUID> for an
identifier’s type. If you must use a different data type, use this protocol to
extend that type and implement the required support. For example, an app that
integrates with the <doc://com.apple.documentation/documentation/MusicKit> framework might use
<doc://com.apple.documentation/documentation/MusicKit/MusicItemID> as the type for an entity’s identifier.

```swift
extension MusicItemID: EntityIdentifierConvertible {
    public var entityIdentifierString: String {
        rawValue
    }

    public init?(entityIdentifierString: String) {
        self = MusicItemID(entityIdentifierString)
    }
}
```

> Important: Keep your ``doc://com.apple.AppIntents/documentation/AppIntents/EntityIdentifierConvertible/entityIdentifierString`` to 4096 characters or fewer.
> Otherwise, the framework truncates the value, and you might not be able to
> convert the truncated value back to its originating type.

## Topics

### Creating an identifier string

[`static func entityIdentifier(for: String) -> Self?`](/documentation/AppIntents/EntityIdentifierConvertible/entityIdentifier(for:))

Identifiers should be able to initialize via a `String` format.

### Getting the identifier string

[`var entityIdentifierString: String`](/documentation/AppIntents/EntityIdentifierConvertible/entityIdentifierString)

The `AppEntity`’s identifier value as a `String`.

## Relationships

### Conforming Types

[`SyncableEntityIdentifier`](/documentation/AppIntents/SyncableEntityIdentifier)

[`FileEntityIdentifier`](/documentation/AppIntents/FileEntityIdentifier)

---

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)