Sitecore Content Hub allow user to create public link and they can use those public links on web application, social channel or any other external/internal application.
In this page, you can find the steps to create public Link. Using this link steps, user can generate Public Links by manually interact with the Sitecore Content Hub.
Sitecore Content Hub provides powerful features Trigger, Action and Script which user can utilize to make this process automatic.
Here, I am going to explain the steps which make this process preprogrammed.
Let’s start the implementation, our first step is to create Script into content hub. If you are new in Sitecore Content Hub, Please refer this page to create basic script.
Add below code inside this new Script which you have created using above page.
using System.Linq;
using System.Threading.Tasks;
var assetId = Context.TargetId;
string OriginalRendition = "downloadOriginal";
// Check if public links don't exist yet
var query = Query.CreateQuery(entities => from e in entities
where e.DefinitionName == "M.PublicLink"
&& e.Parent("AssetToPublicLink") == assetId.Value
&& e.Property("IsDisabled") == false
select e);
query.Take = 1;
var result = await MClient.Querying.QueryIdsAsync(query);
if (result.TotalNumberOfResults > 0)
{
MClient.Logger.Info("Public links already exist for asset with id '" + assetId + "'");
return;
}
// Create public links
await CreateForRendition(OriginalRendition, assetId.Value);
MClient.Logger.Info("Created public link 'downloadOriginal' for asset with id '" + assetId + "'");
async Task CreateForRendition(string rendition, long assetId)
{
var publicLink = await MClient.EntityFactory.CreateAsync("M.PublicLink");
if (publicLink.CanDoLazyLoading())
{
await publicLink.LoadMembersAsync(new PropertyLoadOption("Resource"), new RelationLoadOption("AssetToPublicLink"));
}
publicLink.SetPropertyValue("Resource", rendition);
var relation = publicLink.GetRelation<IChildToManyParentsRelation>("AssetToPublicLink");
if (relation == null)
{
MClient.Logger.Error("Unable to create public link: no AssetToPublicLink relation found.");
return;
}
relation.Parents.Add(assetId);
await MClient.Entities.SaveAsync(publicLink);
return;
}
Note – This script referes “downloadOriginal” rendition only for public link creation.
Once the script is created, Build and Publish in content hub. Now, it is ready for use.
Next step is to create an Action using the Action tiles in the manage section and mapped with the script which you have created in previous step. you have to select “Action scripts” type while creating an Action. If you are new in Sitecore Content Hub, Please refer this page to create Action.

Now you are on your final step where you need to create Trigger in content hub. If you are new in Sitecore Content Hub, Please refer this page to create trigger.
A trigger is a set of actions that are automatically executed after specific events and under specific conditions. You need to configure following details into Trigger based on your requirement.
In General Tab add;
- Objective – Select Entity modification.
- Execution type – Select In background.

In Conditions Tab update;

In Actions Tab add;

Now implementation is done and whenever an asset is moved into approved state, It will trigger the action which we have created and action will invoke script which will generate public link for specific asset.