So I was wondering how I can attach a file to an account. Basically what we do is sell a product online that requires an agreement. When they buy the product, we generate a pdf of the agreement and mail it to them. What I would like to do is upload the pdf agreement and attach it to the corresponding opportunity or account. I am pretty sure this can be accomplished, but I don't see much documentation on it. I am using php and the API to create everything. Any one have any ideas?

3 Answers 3


You can just create an Attachment on the Account. It should work the same way as creating an object in Salesforce.

Some important considerations:

  • The API sends and receives the binary file attachment data encoded as a base64Binary data type. Prior to creating a record, client applications must encode the binary attachment data as base64. Upon receiving a response, client applications must decode the base64 data to binary (this conversion is usually handled for you by the SOAP client).

  • The create call restricts these files to a maximum size of 5 MB. For a file attached to a Solution, the limit is 1.5MB. The maximum email attachment size is 3 MB.

  • 1
    This worked perfectly for what I was trying to achieve. Thanks for the advice!
    – jeffro25
    Feb 6, 2013 at 15:26

I would recommend using chatter files related to the record rather than attachments as chatter files have a number of features that attachments lack.

To upload a file and relate it to a record you use a feeditem with the following required fields.

ContentData: base64 encoded file
ContentFileName: file name
ParentId: account/opportunity ID
Type: 'ContentPost'

I would like to recommend ready to use Salesforce Appexchange Native App Cloud Drop in order to store any number and size of files that can be associated with any salesforce object. Cloud Drop is one of a smart and excellent native app available which integrated Salesforce with Rackspace. Please check the following link for more information:


Thanks Anchal Garg

  • Can you explain the benefits of this over the default attachements, and how this can be API integrated ? Else this is pretty much advertising which usually gets removed. Feb 24, 2014 at 11:27
  • Samuel ,As you know their are several limitation of salesforce default attachment : 1. Max size of attachment that can be associated with a particular sfdc record is 5 MB 2. Also the size of the uploaded file count against the salesforce file storage space (which seems to be costly if user needs to attach large no. of file.) So, A good solution for this issue would be use third party api(Rest) for saving file content there and making a record for that in salesforce for fetching the content of file .CloudDrop app is using same logic for uploading and downloading of the file to Rackspace server. Feb 26, 2014 at 5:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .