Submit Attachments (Docs Alias)
Documentation-friendly alias for submitting base64-encoded attachments.
Backend path: /services/data/v54.0/sobjects/Attachment.
Attachments must be transmitted to the Attachment endpoint (separate from application create/update).
Request Body
Content type: application/json
Required2 fields
Opportunityobjectattachmentsarray<object>minItems=1
Validations (2)
attachments
minItems=1
attachments[].Body
format=byte
Responses
201
Attachments created successfully
Attachments created successfully
Common2 fields
idstringId of the created record
successbooleanWhen Provided1 field
errorsarray<string>Example response
id: 00P1800000ABCdEAAW success: true errors: []
400
Bad request (e.g., file too large, missing Opportunity ID)
Bad request (e.g., file too large, missing Opportunity ID)
Attachment Requirements
- Opportunity ID is required
- File size limit: 100 MB per file
- Maximum total attachment size: 2 GB
- Files must be converted to Base64
Code samples
Copy-paste ready code in your preferred language.
API call
Copy/paste friendly
curl -X POST "https://test.salesforce.com/applications/attachments" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"Opportunity": {
"Id": "YOUR_OPPORTUNITY_ID"
},
"attachments": [
{
"Body": "BASE64_ENCODED_FILE",
"ContentType": "text/plain",
"Name": "example.txt"
}
]
}'