Skip to navigation
ActivitiesSMS

Create an SMS activity

View as Markdown

Create an SMS activity, either to log an SMS that was sent or received outside Close, or to have Close send it.

status must be one of the following:

  • inbox to log an already received SMS.
  • sent to log an already sent SMS.
  • draft to create a draft SMS.
  • scheduled to send an SMS at the date and time in date_scheduled. This requires a plan that includes scheduled SMS.
  • outbox to send an SMS now. To delay sending by a few seconds (to allow undo), set send_in to a number of seconds, up to 60.

Only drafts can be modified, and their status can be changed to scheduled (to send later) or outbox (to send immediately). A scheduled SMS, or an SMS in the outbox that wasn’t sent yet, can be canceled by setting its status back to draft.

To send an SMS, provide remote_phone and the local_phone to send from. The number you choose has to be associated with a Phone Number of type internal. See the Phone Numbers paragraph for more details.

Instead of local_phone, you can set caller_id_mode to auto to let Close pick the number. auto requires a plan that includes Local Presence. On a plan without it, Close accepts auto only if the sender’s Membership has default_caller_id_mode set to auto. The sender is the user in user_id, or the authenticated user if user_id is absent. Close then sends the SMS from the default_caller_id of that Membership. If default_caller_id is unset or cannot send the SMS, Close uses the oldest number that the sender can send from.

A template_id referencing an SMS Template may be provided instead of text to automatically render that template and use the content as text.

When direction is not provided, it defaults to inbound if status is inbox, and to outbound otherwise. When source is not provided, it defaults to External if status is inbox or sent, and to Close.io otherwise.

When creating a new SMS with the status set to inbox, you can pass the query parameter send_to_inbox with the value of true to create a corresponding Inbox Notification for the SMS.

Returns 400 if the SMS is invalid, for example if text is empty for an SMS that isn’t a draft, if Close can’t send an SMS to remote_phone, or if your organization can’t pay for the SMS.

Authentication

AuthorizationBasic
Use your API key as the username and leave the password empty.
OR
AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Query parameters

send_to_inboxbooleanOptional

Set to true to also create an Inbox notification for the SMS. Only allowed when creating an SMS with status set to inbox. Defaults to false.

_fieldsstringOptional

Comma-separated list of fields to include in the response.

Request

This endpoint expects an object.
statusenumRequired

Status of the SMS. Use inbox or sent to log an SMS, draft to save a draft, outbox to send it now or scheduled to send it at date_scheduled. Close sets error when sending fails.

activity_atdatetime or nullOptional

When the SMS happened. Defaults to date_created, and is set to the time the SMS is sent.

attachmentslist of objects or nullOptional
Files to send with the SMS as an MMS, at most 10. Can only be changed while the SMS is a draft.
caller_id_modeenum or nullOptional

How to choose local_phone when sending. auto lets Close pick the number. A logged SMS can’t have a Caller ID mode. Can only be changed while the SMS is a draft.

Allowed values:
contact_idstring or nullOptional
ID of the contact the SMS is with. Can only be changed while the SMS is a draft.
created_bystring or nullOptional

ID of the user who created the SMS. Defaults to you. Setting another user requires the manage_organization permission, otherwise you are used instead.

date_createddatetime or nullOptional
When the SMS was created, e.g. when importing older SMS. Defaults to now.
date_scheduleddatetimeOptional

When to send the message. Required when status is scheduled, and ignored otherwise.

directionenum or nullOptional

Whether the SMS was received (inbound) or sent (outbound). Defaults to inbound when status is inbox, and to outbound otherwise. Can’t be changed later.

Allowed values:
lead_idstring or nullOptional

ID of the lead the SMS belongs to. For a logged SMS (source is External), it defaults to the lead of contact_id, or of the oldest contact with remote_phone. Once set, it can’t be removed.

local_phonestring or nullOptional

Your Close phone number to send the SMS from, or that received it, in E.164 format. Required to send (outbox or scheduled) unless caller_id_mode is auto. Can only be changed while the SMS is a draft.

organization_idstring or nullOptional
ID of your organization. Defaults to the organization of your API key or OAuth token.
remote_phonestring or nullOptional

Phone number of the other party, in E.164 format. Required to send. A logged SMS needs remote_phone or contact_id. Can only be changed while the SMS is a draft.

send_ininteger or nullOptional0-60Defaults to 0

Seconds to delay sending, to allow undo. Only used when status is outbox.

sourceenum or nullOptional

External to log an SMS that was sent or received outside Close, or Close.io for an SMS that Close sends. Defaults to External when status is inbox or sent, and to Close.io otherwise. Can’t be changed later.

Allowed values:
template_idstring or nullOptional

ID of an SMS template. When you create an SMS with a template_id and no text, Close renders the template into text, which requires lead_id. Can only be changed while the SMS is a draft.

textstring or nullOptional

Text of the SMS. Required unless status is draft, or you send attachments or a template_id. An SMS to send can be at most 1,000 bytes of UTF-8 text. Can only be changed while the SMS is a draft.

user_idstring or nullOptional

ID of the user who sent or received the SMS. Defaults to you. Setting another user requires the manage_organization permission, otherwise you are used instead.

Response

Successful response
_typestring

Type of the activity, e.g. Call, Email or Note.

activity_atdatetime or null

When the activity happened, e.g. when an Email or SMS was sent. Defaults to date_created.

attachmentslist of objects
Files sent or received with the SMS. An SMS with attachments is an MMS.
caller_id_modeenum or null

How local_phone was chosen for an outgoing SMS. null for incoming, logged and older SMS.

Allowed values:
caller_id_reasonenum or null

Why Close chose local_phone when caller_id_mode is auto. null otherwise, and until Close sends the SMS.

Allowed values:
contact_idstring or null

ID of the Contact the activity is with, or null if it isn’t with a particular Contact.

coststring or null

What Close charges for the SMS, in cents, as a decimal string (e.g. "1.5"). null if there’s no charge, e.g. for a logged SMS.

created_bystring or null

ID of the user who created the activity, or null if it wasn’t created by a user.

date_createddatetime
When the activity was created.
date_scheduleddatetime or null

When the SMS is scheduled to be sent, or null if it wasn’t scheduled.

date_sentdatetime or null

When the SMS was sent. null until it’s sent.

date_updateddatetime
When the activity was last updated.
directionenum
Whether the SMS was received or sent.
Allowed values:
error_messagestring or null

Why the SMS failed to send, when status is error. Null otherwise.

idstring

ID of the activity, e.g. acti_abc123.

lead_idstring or null

ID of the Lead the activity is on. Can be null for Calls and SMS with phone numbers that don’t match any Contact.

local_country_isostring or null

ISO 3166-1 alpha-2 code of the country of local_phone.

local_phonestring or null

Your phone number that sent or received the SMS, in E.164 format. null for a logged SMS that doesn’t say which number was used.

local_phone_formattedstring or null

local_phone formatted for display.

organization_idstring
ID of the organization the activity belongs to.
remote_country_isostring or null

ISO 3166-1 alpha-2 code of the country of remote_phone.

remote_phonestring or null

Phone number of the other party, in E.164 format. null for a logged SMS that only names a contact.

remote_phone_formattedstring or null

remote_phone formatted for display.

sourceenum

Whether Close sent or received the SMS (Close.io), or it was logged from elsewhere (External).

Allowed values:
statusenum

Where the SMS is in its lifecycle, e.g. draft, outbox or sent.

template_idstring or null

ID of the SMS template the text was rendered from, or null if no template was used. The template may since have been deleted.

textstring or null
Text of the SMS.
updated_bystring or null

ID of the user who last updated the activity, or null if it wasn’t updated by a user.

user_idstring or null

ID of the user the activity belongs to, e.g. who made the Call or sent the Email. Can be null, e.g. for an incoming SMS to a group number.

agent_action_reasonstring or nullOptional

Why an agent created the activity (send_scheduling_link, custom_agent_decision or voice_agent_callback), or null if no agent created it.

created_by_agent_idstring or nullOptional

ID of the agent that created the activity, e.g. agentconfig_abc123, or null if no agent created it.

created_by_namestring or nullOptional

Name of the user in created_by.

sequence_idstring or nullOptional

ID of the Workflow that created the activity, e.g. seq_abc123, or null.

sequence_namestring or nullOptional

Name of the Workflow in sequence_id.

sequence_subscription_idstring or nullOptional

ID of the Workflow Run, i.e. the Contact’s enrollment in the Workflow, that created the activity, e.g. sub_abc123, or null.

updated_by_namestring or nullOptional

Name of the user in updated_by.

user_namestring or nullOptional

Name of the user in user_id.

agent_config_idstring or nullOptionalDeprecated

Deprecated. Use created_by_agent_id instead.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
429
Too Many Requests Error