GenAiPromptTemplate defines a versioned Prompt Builder template: the instructions sent for generation, its Salesforce record and field associations, its inputs and data providers, and version-specific model and output settings. It is the template definition, not a generated response or a record of runtime execution.
Availability requires Prompt Builder to be enabled in the org and the acting user to have the Prompt Template Manager permission. General administrative or API access does not replace this type-specific prerequisite.
Key Elements
| Element | What the Element Controls |
|---|---|
type |
Required template use. Allowed values are einstein_gpt__fieldCompletion, einstein_gpt__salesEmail, einstein_gpt__recordSummary, einstein_gpt__flex, and einstein_gpt__caseEmailDraft. |
activeVersionIdentifier |
Selects the active version by matching that version's versionIdentifier. The selected version must be Published. |
templateVersions |
Required array of nested versions. Each version's versionIdentifier must be unique within the template. Its required status is Draft or Published. |
content, templateFormat
|
Version-level prompt text and format. content is required. The exposed templateFormat values are FormulaExpression and Jinja; expression-style examples do not describe the only available format. |
inputs |
The version's input contract. Each input uses apiName for its parameter name, definition for its type, referenceName for expressions, and required to distinguish required from optional input. |
templateDataProviders |
Additional data sources for a version, such as flows, invocable actions, or Apex methods. A provider's required definition identifies its source, and its required referenceName identifies it in expressions. |
parameters |
Bindings inside a data provider. definition specifies the argument type, parameterName identifies the provider argument, isRequired describes whether it is required, and valueExpression supplies its value or expression. |
relatedEntity, relatedField
|
The Salesforce entity and field associated with the template. These fields do not enumerate every object or field used by its inputs, providers, or prompt expressions. |
primaryModel, generationTemplateConfigs
|
The version's model and policy references. Each policy reference uses generationConfigDeveloperName to identify a policy by developer name. |
responseFormat, outputSchema
|
The version's response format and expected JSON schema. Format values are HTML, JSON, and MarkDown. The schema describes expected output, not a documented guarantee of conformance. |
isCitationEnabled |
Whether generated responses include citations. |
fileDroppingStrategy |
How attached files are managed when context limits are exceeded. This affects which supplied file context can be retained. |
visibility |
The template's visibility scope. Documented values are API and Global. The exposed enumeration also includes Locked and Private, without documented access semantics for those additional values. |
overridable |
Whether the template can be overridden when it is part of a managed package. |
Behavior and Constraints
Publication and activation are separate. A version's status records whether it is Draft or Published. The template's activeVersionIdentifier selects which version is active. Publishing a version and selecting it as active are not the same setting.
Published versions cannot be edited through either the UI or Metadata API. Changing published prompt content therefore requires a different version rather than an in-place rewrite. When evaluating a version change, consider its content, model, inputs, data providers, policies, and output settings together.
Each versionIdentifier must be unique within its template. If one is not supplied, Salesforce generates it. Retrieve the deployed component to obtain the generated value. Versions, inputs, providers, and provider parameters are nested structures within the template, not independently deployed prompt-template components.
Input types and expression names serve different purposes. An input's definition is a URI, a structured identifier for its type. For example, SOBJECT://Account identifies a record input, while SOBJECT://Account/Description identifies a field input. Inputs can also represent Apex primitive data types. The apiName names the parameter; referenceName identifies it in prompt expressions.
Data providers add another layer of dependencies. A provider definition such as flow://ns__CallToActionFlow identifies the source. Its parameters bind template inputs or other values to provider arguments. For example, valueExpression can contain {!$Input:Recipient}. The provider retrieves information, and the prompt's content can consume its output.
Prompt expressions can reference both input fields and provider results. Examples include {!$Input:Recipient.Name} and {!$Flow:Fetch_Products.Prompt}. Dependencies can therefore be embedded in content and valueExpression, not just in dedicated reference fields. Checking only relatedEntity and relatedField misses these connections.
Generation settings belong to each version. Policies referenced through generationTemplateConfigs describe high-level behavior such as allowed languages, conversation style, or desired response length; their definitions reside in configuration files. outputSchema describes the expected JSON structure, while responseFormat selects the response format. Neither setting establishes a documented guarantee that every generated response conforms to the schema.
When diagnosing missing file context, examine fileDroppingStrategy. It governs attached-file management when context limits are exceeded, rather than merely controlling presentation.
Deployment and Retrieval
Metadata API components use the suffix .genAiPromptTemplate and reside in the genAiPromptTemplates folder. A source-format file can appear as genAiPromptTemplates/Quick_Summary.genAiPromptTemplate-meta.xml. The template's masterLabel is a required user-friendly name.
GenAiPromptTemplate supports the * wildcard in package.xml. Use GenAiPromptTemplate as the manifest type name. See Salesforce's manifest deployment and retrieval guidance.
To retrieve the type with Salesforce CLI, use sf project retrieve start -o source-org -m GenAiPromptTemplate. The retrieving user still needs Prompt Template Manager permission, and Prompt Builder must be enabled in the org.
The deployment unit is the template containing its nested versions and definitions. Before changing a retrieved component, distinguish published versions from drafts: Metadata API cannot rewrite published content. Also preserve the relationship between activeVersionIdentifier and the intended published version's versionIdentifier.
For dependency checks, examine input and parameter definition values, provider definitions, content, and valueExpression. Provider definitions can point to flows, invocable actions, or Apex methods, and retriever-backed definitions can contain environment-specific names.
Package-build access can differ from access in the development org. A reported second-generation managed-package remedy configured packageMetadataAccess.permissionSets with EinsteinGPTPromptTemplateManager for both package-build and scratch-org configuration. This is a permission-context diagnostic, not evidence that the type is categorically unsupported in managed packages.
A record page can also depend on a template by name. If a field's generativePromptTemplate property names a template absent from the target org, deployment can fail. A separate report found that deploying enablement settings before the templates resolved an availability error; that report does not establish a universal requirement to split those deployments.
Relationships
Template dependencies include typed URI definitions, record and field associations, and expressions inside prompt text or provider bindings. The references below identify metadata connections; they do not describe every dependency that can be embedded in a prompt.
References
-
ApexClass:definition, where the nested definition and URI identify an Apex type or method source. -
CustomObject:definition, where the URI identifies a Salesforce object. -
Flow:definitionwithintemplateDataProviders, using a flow URI such asflow://ns__CallToActionFlow.
Referenced By
-
GenAiBundle:invocationTarget.
Name-based association: FlexiPage can identify a template through a field's generativePromptTemplate property. This property stores the template name and is separate from the invocationTarget reference above.
Documentation Inconsistencies
The documented visibility values are API and Global, while the exposed enumeration also includes Locked and Private. Detailed access behavior is not documented for those additional names. Do not infer who can view, edit, or invoke a template from those names alone.
Reported Issues
-
Broad retrieval can fail even for an administrator. In a 2025 report, retrieval returned
INSUFFICIENT_ACCESS: insufficient access rights on entity: GenAiPromptTemplatedespite administrative permissions, including API access. An answer identified Prompt Template Manager as the missing type-specific permission and suppliedsf org assign permset -n EinsteinGPTPromptTemplateManagerto assign the permission set. See the retrieval access discussion. -
A managed-package build can report the type as unsupported because of its access context. In March 2025, a namespaced second-generation managed-package build returned
These entities are not supported: [GenAiPromptTemplate]. The reported remedy addedEinsteinGPTPromptTemplateManagerunderpackageMetadataAccess.permissionSetsin both package-build and scratch-org configuration. This was a reported permission remedy, not a general packaging prohibition. See the package-build access discussion. -
A missing template can block record-page deployment. A January 2025 report attributed
isn't a valid value for Generative Prompt TemplateduringFlexiPagedeployment to the named template being absent from the target org. The page referenced it through a field'sgenerativePromptTemplateproperty. See the record-page dependency discussion. -
Deploying enablement settings and templates together can produce an availability error in some circumstances. The same January 2025 discussion reported
Not available for deploy for this organizationand described deploying the settings first, followed by the templates, as the workaround. Separate deployments are not established as universally required. See the enablement deployment report. -
Retriever-backed templates can fail validation when the target cannot resolve a provider. A 2025 report involving definitions beginning
invocable://getEinsteinRetrieverResults/returnedcannot describe data provider. Migration guidance remains unresolved: one answer claimed that the internalAIRetrieverDefinitionwas unavailable for migration, while a separate March 2026 answer tentatively suggested data kits and reported replacing retriever names between environments. These reports support checking target-specific provider resolution, not a blanket conclusion about retriever migration support. See the retriever validation failure and the retriever deployment discussion.
Common Questions
How do I retrieve GenAiPromptTemplate metadata?
Use sf project retrieve start -o source-org -m GenAiPromptTemplate, or include the type in package.xml; wildcard retrieval is supported. Prompt Builder must be enabled, and the retrieving user needs Prompt Template Manager permission even if the user already has general administrative and API access.
How do I make a prompt template version active?
Set activeVersionIdentifier to the selected version's versionIdentifier. That version must have status set to Published. Publication and activation are separate settings.
Can I edit a published prompt template version through Metadata API?
No. Published versions cannot be edited through Metadata API or the UI. Change the content in a different version rather than rewriting the published version in place.
Why does FlexiPage deployment say a template isn't a valid value for Generative Prompt Template?
A reported cause is that the template named by the field's generativePromptTemplate property is absent from the target org. Check that named template, not just the record page and its field.
Why does a retriever-backed template fail with cannot describe data provider?
This has been reported when a template uses invocable://getEinsteinRetrieverResults/ provider definitions that fail to resolve in the target environment. Check the target-specific provider and retriever names. The discussions do not establish a universal retriever migration procedure or a blanket lack of migration support.