For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HomepageProduct HelpLog inTry for Free
Developers HomeAPI ReferenceMCP
Developers HomeAPI ReferenceMCP
  • Getting Started
    • Introduction
    • Authentication with API Keys
    • Authentication with OAuth
    • API Clients
    • Pagination
    • Specifying Fields
    • Filter Parameters
    • HTTP Response Codes
    • Rate Limits
    • Timezone Offsets
    • Rich Text Fields
    • Changelog
  • CRM Core
    • Leads
    • Contacts
    • Opportunities
    • Tasks
    • Files
      • POSTGenerate a signed S3 POST
    • Custom Objects
    • Comments
  • Activities
    • Activities
    • Notes
    • Calls
    • Emails
    • Email Threads
    • WhatsApp Messages
    • Meetings
    • Custom Activities
    • Creations
    • Form Submissions
    • Lead Status Changes
    • Opportunity Status Changes
    • Lead Merges
    • Task Completions
  • Events & Webhooks
    • Webhooks
    • Events
  • Search & Reporting
    • Advanced Filtering
    • Smart Views
    • Reporting
  • Automation & Bulk Actions
    • Sequences (Workflows)
    • Bulk Actions
    • Exports
    • AI Field Enrichment
  • CRM Configuration
    • Custom Fields
    • Custom Activity Types
    • Custom Object Types
    • Pipelines
    • Opportunity Statuses
    • Lead Statuses
    • Integration Links
    • Forms
  • Communication Configuration
    • Email Templates
    • SMS Templates
    • Outcomes
    • Playbooks
    • Scheduling Links Guide
    • Scheduling Links
    • Connected Accounts
    • Send As
    • Unsubscribed Emails
    • Phone Numbers
    • Blocked Phone Numbers
    • Dialers
  • Users & Organizations
    • Users
    • Organizations
    • Memberships
    • Roles
    • Groups
Close

Product

OverviewCommunicationAutomationIntegrationsReportingSMSCallingSecurityForms

Pricing & Use Cases

PricingClose vs Other CRMsCustomer Stories

Resources

Sales BlogSales ResourcesSales GuidesWebinarsOn-Demand DemoSales Tools

Company

AboutCareersPartner with CloseBrand GuidelinesTermsPrivacyGDPRCCPA

Get Help

+1-833-GO-CLOSEHelp CenterDownload the Close AppProduct UpdatesSystem Status
LogoLogo
HomepageProduct HelpLog inTry for Free
CRM Core

Files

Upload files to attach to outgoing emails or other objects via the API.
||View as Markdown|
Was this page helpful?
Edit this page
Previous

Delete a task

Next

Generate a signed S3 POST

Built with

Close users wishing to attach files to outgoing emails or other objects via the Close API must first upload these files using the Files API.

Files will be uploaded to a Close-provided Amazon S3 bucket. The Close API provides the data needed to make a request to S3 to store your file.

To do so:

  1. Make a POST request to /files/upload/ with the filename and content_type of the file you are uploading.
  2. Use the data in the response to construct a multipart/form-data POST request: The request should be to the URL provided in the upload.url. All fields in the upload.fields object must be included in the form fields of the request. This request must be made within 60 seconds of your request to /files/upload, otherwise it will fail. See the AWS documentation for more information.
  3. Once the upload request has been made successfully (201 HTTP status code), the file will be available for use in other API endpoints for at most 24 hours. The response from /files/upload will contain a download.url field, whose value should be used when referencing this file in other API endpoints. Note: attempting to use this file before the S3 upload request has been made successfully will result in a failed request to the Close API.

The below sample code can be used to make the request to S3. This example uses the requests library in Python.

1from closeio_api import Client
2import requests
3
4api = Client("YOUR_API_KEY")
5files_upload_response = api.post("files/upload", {
6 "filename": "image.jpg",
7 "content_type": "image/jpeg"
8})
9
10# Use the data in the response to construct a multipart/form-data POST request
11s3_upload_response = requests.post(
12 files_upload_response["upload"]["url"],
13 data=files_upload_response["upload"]["fields"],
14 files={
15 "file": ("image.jpg", open("path/to/image.jpg", "rb"), "image/jpeg")
16 }
17)
18assert s3_upload_response.status_code == 201
19
20# The file will be available for use in other API endpoints, for example below
21# when creating an email activity.
22email_create_response = api.post("activity/email", data={
23 "attachments": [{
24 "url": files_upload_response["download"]["url"],
25 "filename": "image.jpg",
26 "size": 1108447,
27 "content_type": "image/jpeg"
28 }],
29 "contact_id": "cont_xxx",
30 "lead_id": "lead_xxx",
31 "user_id": "user_xxx",
32 "direction": "outgoing",
33 ...
34})