To create or update a public link you need to have X-Auth-Token header set for all requests which you send. It can be obtained as described here: https://docs.stylelabs.com/contenthub/4.1.x/content/integrations/rest-api/authenticate/get-token.html

Send a POST request to /api/entitydefinitions/M.PublicLink/entities URL with the following body:

{
"properties": {
"RelativeUrl": "067baf76e8eb4ef2a6ece6fe611013a0",
"Resource": "downloadOriginal",
"ExpirationDate": "2021-10-30T12:16:00.176Z",
"ConversionConfiguration": {}
},
"is_root_taxonomy_item": false,
"is_path_root": false,
"inherits_security": true,
"entitydefinition": {
"href": "https://YourCHHostnameGoesHere/api/entitydefinitions/M.PublicLink"
},
"relations": {
"AssetToPublicLink": {
"parents": [
{
"href": "https://YourCHHostnameGoesHere/api/entities/IDOFYOURASSET"
}
]
}
}
}

 
If the operation is successful, 201 response code must be received and the body must have id and identifier of the created entity. RelativeUrl must be a unique random guid.

Send GET request to /api/entities/PublicLinkEntityId and check the properties.Status value in the returned response. When it is Completed, the link is ready.

Send a PUT request to api/entities/PublicLinkEntityId URL with the body which has modifications to the properties which needs to be updated.

For example, changing the ExpirationDate can be done as follows:

{
"properties": {
"ExpirationDate": "2021-11-30T12:16:00.176Z"
},
"entitydefinition": {
"href": "https://YourCHHostnameGoesHere/api/entitydefinitions/M.PublicLink"
}
}

 
entitydefinition property is mandatory and must be present in the request.