# Create an SMS activity

POST https://api.close.com/api/v1/activity/sms/
Content-Type: application/json

*status* must be one of the following:

 - `inbox` to log an already received SMS.
 - `draft` to create a draft SMS.
 - `scheduled` to send an SMS at a scheduled date and time, which must be specified in the `date_scheduled` field.
 - `outbox` to actually **send** an SMS. To delay SMS sending by a few seconds (to allow undo), specify `send_in` in seconds (must be less than 60).
 - `sent` to log an already sent SMS.

Only drafts can be modified, and their status can be changed to `scheduled` (to send later) or `outbox` (to send immediately). Scheduled SMS, or SMS in outbox that weren't sent yet can be canceled by setting the status back to `draft`.

You have to provide a `local_phone` that will be used to send the SMS. The number you choose has to be associated with a Phone Number of type `internal`. See the [Phone Numbers](/resources/phone-numbers/) paragraph for more details.

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, but `status="inbox"`, `direction` will default to "inbound". Otherwise, `direction` defaults to "outbound".

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.

Reference: https://developer.close.com/api/resources/activities/sms/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /activity/sms/:
    post:
      operationId: create
      summary: Create an SMS activity
      description: >-
        *status* must be one of the following:

         - `inbox` to log an already received SMS.
         - `draft` to create a draft SMS.
         - `scheduled` to send an SMS at a scheduled date and time, which must be specified in the `date_scheduled` field.
         - `outbox` to actually **send** an SMS. To delay SMS sending by a few seconds (to allow undo), specify `send_in` in seconds (must be less than 60).
         - `sent` to log an already sent SMS.

        Only drafts can be modified, and their status can be changed to
        `scheduled` (to send later) or `outbox` (to send immediately). Scheduled
        SMS, or SMS in outbox that weren't sent yet can be canceled by setting
        the status back to `draft`.


        You have to provide a `local_phone` that will be used to send the SMS.
        The number you choose has to be associated with a Phone Number of type
        `internal`. See the [Phone Numbers](/resources/phone-numbers/) paragraph
        for more details.


        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, but `status="inbox"`, `direction` will
        default to "inbound". Otherwise, `direction` defaults to "outbound".


        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.
      tags:
        - subpackage_activitiesSms
      parameters:
        - name: send_to_inbox
          in: query
          required: false
          schema:
            type: boolean
        - name: Authorization
          in: header
          description: Basic authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SMSActivity'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                description: Any type
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: Any type
        '404':
          description: Not found
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSMSActivity'
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    CreateSmsActivityAttachmentsItemsContentType:
      type: string
      enum:
        - application/pdf
        - application/vcard
        - audio/3gpp
        - audio/3gpp2
        - audio/L24
        - audio/ac3
        - audio/amr
        - audio/amr-nb
        - audio/basic
        - audio/mp4
        - audio/mpeg
        - audio/ogg
        - audio/vnd.rn-realaudio
        - audio/vnd.wave
        - audio/webm
        - image/bmp
        - image/gif
        - image/jpeg
        - image/jpg
        - image/png
        - image/tiff
        - text/calendar
        - text/csv
        - text/directory
        - text/richtext
        - text/rtf
        - text/vcard
        - text/x-vcard
        - video/3gpp
        - video/3gpp-tt
        - video/3gpp2
        - video/H261
        - video/H263
        - video/H263-1998
        - video/H263-2000
        - video/H264
        - video/mp4
        - video/mpeg
        - video/quicktime
        - video/webm
      title: CreateSmsActivityAttachmentsItemsContentType
    CreateSmsActivityAttachmentsItems:
      type: object
      properties:
        content_type:
          $ref: '#/components/schemas/CreateSmsActivityAttachmentsItemsContentType'
        filename:
          type: string
        url:
          type: string
      required:
        - content_type
        - filename
        - url
      title: CreateSmsActivityAttachmentsItems
    CreateSmsActivityDirection:
      type: string
      enum:
        - inbound
        - outbound
      title: CreateSmsActivityDirection
    CreateSmsActivitySource:
      type: string
      enum:
        - Close.io
        - External
      title: CreateSmsActivitySource
    CreateSmsActivityStatus:
      type: string
      enum:
        - inbox
        - draft
        - scheduled
        - outbox
        - sent
        - error
      title: CreateSmsActivityStatus
    CreateSMSActivity:
      type: object
      properties:
        activity_at:
          type:
            - string
            - 'null'
          format: date-time
        attachments:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/CreateSmsActivityAttachmentsItems'
        contact_id:
          type:
            - string
            - 'null'
        created_by_id:
          type:
            - string
            - 'null'
        date_created:
          type:
            - string
            - 'null'
          format: date-time
        direction:
          $ref: '#/components/schemas/CreateSmsActivityDirection'
        lead_id:
          type:
            - string
            - 'null'
        local_phone:
          type:
            - string
            - 'null'
          description: Phone number in E.164 format
        organization_id:
          type:
            - string
            - 'null'
        remote_phone:
          type:
            - string
            - 'null'
          description: Phone number in E.164 format
        source:
          $ref: '#/components/schemas/CreateSmsActivitySource'
        status:
          $ref: '#/components/schemas/CreateSmsActivityStatus'
        template_id:
          type:
            - string
            - 'null'
        text:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
      required:
        - status
      title: CreateSMSActivity
    PhoneActivityDirection:
      type: string
      enum:
        - inbound
        - outbound
      description: |-
        Direction of a phone call or an SMS message.

        If you want to use this for a new activity, consider more generic
        CommunicationDirection instead.
      title: PhoneActivityDirection
    PhoneActivitySource:
      type: string
      enum:
        - Close.io
        - External
      description: Source of a phone call or an SMS message.
      title: PhoneActivitySource
    MessageStatus:
      type: string
      enum:
        - inbox
        - draft
        - scheduled
        - outbox
        - sent
        - error
      description: |-
        Status of a message, such as Email or SMS.

        This set of statuses should be enough to support features such as
        "send later" or "undo send".
      title: MessageStatus
    SMSActivity:
      type: object
      properties:
        _type:
          type: string
        activity_at:
          type:
            - string
            - 'null'
          format: date-time
        agent_action_reason:
          type:
            - string
            - 'null'
        agent_config_id:
          type:
            - string
            - 'null'
        contact_id:
          type:
            - string
            - 'null'
        cost:
          type:
            - string
            - 'null'
        created_by:
          type:
            - string
            - 'null'
        created_by_name:
          type:
            - string
            - 'null'
        date_created:
          type: string
          format: date-time
        date_scheduled:
          type:
            - string
            - 'null'
          format: date-time
        date_sent:
          type:
            - string
            - 'null'
          format: date-time
        date_updated:
          type: string
          format: date-time
        direction:
          $ref: '#/components/schemas/PhoneActivityDirection'
        error_message:
          type:
            - string
            - 'null'
        id:
          type: string
        lead_id:
          type:
            - string
            - 'null'
        local_country_iso:
          type:
            - string
            - 'null'
        local_phone:
          type:
            - string
            - 'null'
        local_phone_formatted:
          type:
            - string
            - 'null'
        organization_id:
          type: string
        remote_country_iso:
          type:
            - string
            - 'null'
        remote_phone:
          type:
            - string
            - 'null'
        remote_phone_formatted:
          type:
            - string
            - 'null'
        sequence_id:
          type:
            - string
            - 'null'
        sequence_name:
          type:
            - string
            - 'null'
        sequence_subscription_id:
          type:
            - string
            - 'null'
        source:
          $ref: '#/components/schemas/PhoneActivitySource'
        status:
          $ref: '#/components/schemas/MessageStatus'
        template_id:
          type:
            - string
            - 'null'
        text:
          type:
            - string
            - 'null'
        updated_by:
          type:
            - string
            - 'null'
        updated_by_name:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
        user_name:
          type:
            - string
            - 'null'
        users:
          type: array
          items:
            type: string
      required:
        - _type
        - activity_at
        - contact_id
        - cost
        - created_by
        - date_created
        - date_scheduled
        - date_sent
        - date_updated
        - direction
        - error_message
        - id
        - lead_id
        - local_country_iso
        - local_phone
        - local_phone_formatted
        - organization_id
        - remote_country_iso
        - remote_phone
        - remote_phone_formatted
        - source
        - status
        - template_id
        - text
        - updated_by
        - user_id
        - users
      title: SMSActivity
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: basic
    OAuth2:
      type: http
      scheme: bearer

```