function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sambit Rout 26Sambit Rout 26 

I want my attachment in custom object to be accessed by 3rd party through rest api so how can I make my attachment public

Ramesh DRamesh D
@Sambit,
Create ContentDistribution for your attachment and onces it's create use DistributionPublicUrl 
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/api/sforce_api_objects_contentdistribution.htm
https://developer.salesforce.com/docs/atlas.en-us.sfFieldRef.meta/sfFieldRef/salesforce_field_reference_ContentDistribution.htm
 
ContentDistribution newItem = new ContentDistribution();
                    newItem.Name = 'profile Photo'+con.firstName;
                    newItem.ContentVersionId =your attachment version id;
                    newItem.PreferencesAllowViewInBrowser= true;
                    newItem.PreferencesLinkLatestVersion=true;
                    newItem.PreferencesNotifyOnVisit=false;
                    newItem.PreferencesPasswordRequired=false;
                    newItem.PreferencesAllowOriginalDownload= true;
                    Insert NewItem;

then query for it
select ID,DistributionPublicUrl,ContentVersionId, ContentDownloadURL from 
                                                ContentDistribution where ContentVersionId in:VersionIds

I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D