openapi: 3.0.0
security: []
servers:
  - url: https://api.example.com
info:
  description: Generic IDL for external apps in app directory
  version: Not Applicable
  title: Hootsuite Apps API
  x-spec-id: external-apps
  x-sdk-name: external_apps
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
tags:
  - name: PlannedContent
    description: Endpoints that need to implemented to support planned content
  - name: OAuth2
    description: Endpoints that need to be implemented to support OAuth2
  - name: Status
    description: Endpoints for status checks
  - name: MediaLibrary
    description: Endpoints for media library
  - name: CRM
    description: Endpoints for CRM integration
paths:
  /v1/oauth2/authorize:
    get:
      tags:
        - OAuth2
      operationId: OAuth2Authorize
      summary: Get OAuth2 authorization
      description: <p> <a href='https://tools.ietf.org/html/rfc6749#section-3.1'>OAuth2 Authorize</a> endpoint. Please note that this authorization url is configured in the developer portal. </p>
      parameters:
        - in: query
          name: response_type
          schema:
            type: string
          required: true
          description: oauth2 response_type
        - in: query
          name: client_id
          schema:
            type: string
          required: true
          description: oauth2 client_id
        - in: query
          name: redirect_uri
          schema:
            type: string
          required: true
          description: oauth2 redirect_uri
        - in: query
          name: state
          schema:
            type: string
          required: false
          description: oauth2 state
        - in: query
          name: scope
          schema:
            type: string
          required: false
          description: oauth2 scope
      responses:
        "200":
          description: successful operation
        "400":
          description: Bad request.
        "500":
          description: Unexpected error.
  /v1/oauth2/token:
    post:
      tags:
        - OAuth2
      operationId: Oauth2Token
      summary: Get OAuth2 token
      description: |-
        <p>Partner token endpoint. <code>client_secret</code>, <code>code</code>, and <code>refresh_token</code> are credentials. Do not log them.</p> <p> <a href='https://tools.ietf.org/html/rfc6749#section-3.2'>OAuth2 Token</a> endpoint. Please note that this authorization url is configured in the developer portal. The required parameters depend on the grant type requested: </p>
        <p>Authorization Code (Media Library/Planned Content)</p> <ul> <li>grant_type: authorization_code</li> <li>client_id</li> <li>client_secret</li> <li>code</li> <li>redirect_uri</li> </ul>
        <p>Refresh Token (Media Library/Planned Content)</p> <ul> <li>grant_type: refresh_token</li> <li>client_id </li> <li>client_secret </li> <li>refresh_token </li> </ul>
        <p>Client Credentials (CRM integration)</p> <ul> <li>grant_type: client_credentials</li> <li>client_id </li> <li>client_secret </li> <li>scope: CRM-Instance-URL provided by the customer </li> </ul>
      requestBody:
        required: true
        description: token request payload, form-encoded
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - grant_type
              properties:
                grant_type:
                  example: authorization_code
                  type: string
                  enum:
                    - authorization_code
                    - refresh_token
                    - client_credentials
                code:
                  example: example
                  type: string
                redirect_uri:
                  example: example
                  type: string
                client_id:
                  example: example
                  type: string
                client_secret:
                  example: example
                  type: string
                refresh_token:
                  example: example
                  type: string
                scope:
                  example: example
                  type: string
                  description: |
                    <ul>
                    <li>For CRM apps, this will be the instance URL provided by the customer and match the CRM-Instance-URL header.</li>
                    </ul>
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                required:
                  - access_token
                  - token_type
                properties:
                  access_token:
                    example: example
                    type: string
                  token_type:
                    example: example
                    type: string
                  expires_in:
                    example: 12345
                    type: integer
                    format: int64
                  refresh_token:
                    example: example
                    type: string
        "400":
          description: Bad request.
        "500":
          description: Unexpected error.
  /v1/planned-content:
    get:
      tags:
        - PlannedContent
      operationId: GetPlannedContent
      summary: Get planned content
      description: This endpoint returns planned content items based on the provided parameters.
      security:
        - bearerAuth: []
      parameters:
        - in: query
          name: startDate
          schema:
            type: string
            format: date
          required: false
          description: Starting due-date to filter on, YYYY-MM-DD format
        - in: query
          name: endDate
          schema:
            type: string
            format: date
          required: false
          description: Ending due-date to filter on, YYYY-MM-DD format
        - in: query
          name: parentId
          schema:
            type: string
          required: false
          description: Parent folder ID to view content in
        - in: query
          name: cursor
          schema:
            type: string
          required: false
          description: Cursor for pagination
        - in: query
          name: query
          schema:
            type: string
          required: false
          description: Search query
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    maxItems: 1000
                    items:
                      type: object
                      required:
                        - id
                      properties:
                        id:
                          type: string
                        name:
                          type: string
                        body:
                          type: string
                        mediaType:
                          type: string
                          enum:
                            - folder
                            - plannedContent
                        permalink:
                          type: string
                        tags:
                          type: array
                          maxItems: 1000
                          items:
                            type: string
                        links:
                          type: array
                          maxItems: 1000
                          items:
                            type: string
                        attachments:
                          type: array
                          maxItems: 1000
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: string
                              name:
                                type: string
                              mediaType:
                                type: string
                              mimeType:
                                type: string
                              durationInSeconds:
                                type: integer
                              subtitleFileName:
                                type: string
                              subtitles:
                                type: string
                              original:
                                type: object
                                required:
                                  - url
                                properties:
                                  url:
                                    type: string
                                  width:
                                    type: integer
                                  height:
                                    type: integer
                                  sizeInBytes:
                                    type: integer
                              thumbnail:
                                type: object
                                required:
                                  - url
                                properties:
                                  url:
                                    type: string
                                  width:
                                    type: integer
                                  height:
                                    type: integer
                        author:
                          type: object
                          required:
                            - id
                          properties:
                            id:
                              type: string
                            firstName:
                              type: string
                            lastName:
                              type: string
                            avatarUrl:
                              type: string
                        dates:
                          type: object
                          required:
                            - created
                            - updated
                            - due
                          properties:
                            created:
                              type: string
                            updated:
                              type: string
                            due:
                              type: string
                  meta:
                    type: object
                    properties:
                      cursor:
                        type: string
                      isSearchable:
                        type: boolean
        "400":
          description: Bad request.
        "500":
          description: Unexpected error.
  /v1/status:
    get:
      tags:
        - Status
      operationId: GetStatus
      summary: Get status
      description: Handles the status endpoint
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                type: string
        "400":
          description: Bad request.
        "500":
          description: Unexpected error.
  /v1/media:
    get:
      description: Retrieve media content and optionally filter by search criteria and mediaType. If no parameters are given, the app should return either the contents of the base folder if it has a folder hierarchy or trending/popular media results otherwise.
      operationId: GetMedia
      summary: Get media
      tags:
        - MediaLibrary
      security:
        - bearerAuth: []
      parameters:
        - in: query
          name: parentId
          description: The id of the parent folder whose children are requested.
          required: false
          schema:
            type: string
        - in: query
          name: cursor
          description: |
            A cursor returned by a previous call to this endpoint. Used to return the next page of results. 
            All params from the previous request must be encoded in the cursor, so that a subsequent call can be made  with only the cursor to fetch the next or previous page of results.
          required: false
          schema:
            type: string
        - in: query
          name: query
          description: Search text.
          required: false
          schema:
            type: string
        - in: query
          name: pageSize
          description: Number of results to return per page
          required: false
          schema:
            type: integer
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - metadata
                properties:
                  data:
                    type: array
                    maxItems: 1000
                    description: The media results
                    items:
                      type: object
                      required:
                        - mediaType
                      properties:
                        id:
                          type: string
                          description: Resource ID. This field must be included for folders.
                          example: 12345qqq
                        name:
                          type: string
                          description: Resource filename.
                          example: my_picture.jpg
                        altText:
                          type: string
                          description: Alt-text for the image, if available.
                          example: Picture of a beautiful sunset
                        mediaType:
                          type: string
                          enum:
                            - AnimatedGif
                            - Image
                            - Folder
                            - Video
                          example: Image
                        mimeType:
                          type: string
                          description: |
                            This field is optional ONLY in the case where the original.url field ends in an identifiable  file extension (such as '.jpg'). In every other case it is required. Regardless of whether  the mimeType is included or inferred from the URL, the response must be one of the enumerated  mimeTypes.
                          enum:
                            - image/jpeg
                            - image/png
                            - image/gif
                            - video/mp4
                            - application/vnd.hootsuite.folder
                          example: image/jpeg
                        original:
                          type: object
                          description: The original media file. This field is required for all files except folders.
                          required:
                            - url
                            - width
                            - height
                          properties:
                            url:
                              type: string
                              description: URL to the media resource.
                              example: https://imagezzzz.com/my_image.jpg
                            width:
                              type: integer
                              format: int64
                              description: Width in pixels.
                              example: 200
                            height:
                              type: integer
                              format: int64
                              description: Height in pixels.
                              example: 200
                            sizeInBytes:
                              type: integer
                              format: int64
                              description: File size in bytes. This is a hint and should be provided if available.
                              example: 300
                        thumbnail:
                          type: object
                          description: A smaller thumbnail for display in a selector. This field is REQUIRED for all files except folders.
                          required:
                            - url
                            - width
                            - height
                          properties:
                            url:
                              type: string
                              description: URL to the thumbnail.
                              example: https://imagezzzz.com/my_image_small.jpg
                            width:
                              type: integer
                              format: int64
                              description: Width in pixels.
                              example: 100
                            height:
                              type: integer
                              format: int64
                              description: Height in pixels.
                              example: 100
                        durationInSeconds:
                          type: integer
                          format: int64
                          description: This field is REQUIRED for videos.
                          example: 120
                        subtitleFileName:
                          type: string
                          description: |
                            Name for the SubRip subtitles file in the format given here: https://www.facebook.com/help/www/1528795707381162
                          example: example.en_US.srt
                        subtitles:
                          type: string
                          description: URL to the SubRip subtitles file (max 200kB)
                          example: https://imagezzzz.com/my_subtitles.srt
                        tags:
                          type: array
                          maxItems: 1000
                          description: Tags for the image, these may be included in posts when the media item is attached
                          items:
                            type: string
                  metadata:
                    type: object
                    description: The metadata response envelope.
                    required:
                      - cursor
                    properties:
                      cursor:
                        type: object
                        description: |
                          The cursors used to get the next or previous page of results. These should be URL-safe.
                          All params from the request must be encoded in the cursor, so that a subsequent call can be made with only the cursor to fetch the next or previous page of results.
                          If there are no more results in the cursor's direction, it can be omitted.
                        properties:
                          next:
                            type: string
                            description: |
                              A cursor that can be used to return the next page of results. This should be URL-safe.  If there are no more results, it can be omitted.
                            example: encodedxjatcd83nn39d99093kknext
                          previous:
                            type: string
                            description: |
                              A cursor that can be used to return the previous page of results. This should be URL-safe. If there are no previous results, this can be omitted.
                            example: encodedxjatcd83nn39d99093kkprev
  /v1/case:
    post:
      operationId: createCase
      summary: Create case
      description: |
        Partner endpoint. Creates a CRM case. The body includes the member `email` on `createdByMember` and `metadata.sharedKey`, an encrypted shared secret. Contact attributes can include email and phone. Do not log them.
      tags:
        - CRM
      security:
        - bearerAuth: []
      parameters:
        - in: header
          name: X-Hub-Signature-256
          schema:
            type: string
          required: true
          description: A hex-encoded SHA256 signature preceded with sha256=
      requestBody:
        description: New case to be created
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - subject
                - conversationId
                - contactProfile
                - metadata
              properties:
                subject:
                  example: example
                  type: string
                conversationId:
                  example: example
                  type: string
                  format: conversation-id
                createdByMember:
                  type: object
                  required:
                    - name
                    - email
                  properties:
                    name:
                      type: string
                    email:
                      type: string
                      format: email
                socialProfile:
                  type: object
                  required:
                    - socialNetworkType
                  properties:
                    socialNetworkType:
                      type: string
                      enum:
                        - TWITTER
                        - FACEBOOK
                        - FACEBOOKPAGE
                        - LINKEDIN
                        - LINKEDINCOMPANY
                        - LINKEDINGROUP
                        - INSTAGRAM
                        - INSTAGRAMBUSINESS
                        - INSTAGRAMPERSONAL
                        - INSTAGRAMPROFESSIONAL
                        - INAPPCHAT
                        - WHATSAPP
                        - TIKTOKBUSINESS
                        - THREADS
                        - SMS
                        - TELEGRAM
                        - WECHAT
                        - YOUTUBECHANNEL
                        - UNKNOWN
                    name:
                      type: string
                    externalId:
                      type: string
                    mediumIdentifier:
                      type: object
                      required:
                        - value
                        - type
                      properties:
                        type:
                          type: string
                          enum:
                            - URL
                            - PHONE
                            - EMAIL
                            - ID
                        value:
                          type: string
                contactProfile:
                  type: object
                  required:
                    - socialNetworkType
                    - id
                  properties:
                    socialNetworkType:
                      type: string
                      enum:
                        - TWITTER
                        - FACEBOOK
                        - FACEBOOKPAGE
                        - LINKEDIN
                        - LINKEDINCOMPANY
                        - LINKEDINGROUP
                        - INSTAGRAM
                        - INSTAGRAMBUSINESS
                        - INSTAGRAMPERSONAL
                        - INAPPCHAT
                        - WHATSAPP
                        - TIKTOKBUSINESS
                        - THREADS
                        - UNKNOWN
                    id:
                      type: string
                      format: contact-profile-id
                    socialNetworkContactProfileId:
                      type: string
                    primaryIdentifier:
                      type: string
                    secondaryIdentifier:
                      type: string
                    pictureUrl:
                      type: string
                      format: uri
                crmContact:
                  type: object
                  required:
                    - id
                  properties:
                    id:
                      type: string
                contactAttributes:
                  type: array
                  items:
                    type: object
                    required:
                      - attribute
                    properties:
                      attribute:
                        type: string
                      value:
                        type: string
                      identifier:
                        type: string
                defaultContactAttributes:
                  type: object
                  properties:
                    email:
                      type: string
                      format: email
                    phone:
                      type: string
                    language:
                      type: string
                    vip:
                      type: boolean
                    url:
                      type: string
                      format: uri
                    name:
                      type: string
                metadata:
                  type: object
                  required:
                    - sharedKey
                    - id
                    - instanceUrl
                    - expiresAt
                  properties:
                    id:
                      description: CRM integration ID
                      type: string
                      format: crm-id
                    instanceUrl:
                      description: The instance URL provided by the customer
                      type: string
                      format: uri
                    sharedKey:
                      type: object
                      required:
                        - key
                        - nonce
                      properties:
                        key:
                          type: string
                          format: byte
                          description: base64-encoded shared secret that is GCM-AES256-encrypted using `nonce` and application shared key
                        nonce:
                          type: string
                          format: byte
                          description: base64-encoded nonce value
                    expiresAt:
                      description: Expiry time for the request
                      type: string
                      format: date-time
      responses:
        "201":
          description: Case created successfully
        "400":
          description: Case creation failed
        "401":
          description: Unauthorized
  /v1/contact:
    delete:
      operationId: deleteContacts
      summary: Delete contact data
      description: |
        Partner endpoint. Deletes personal data stored for a case contact. Do not log the request body.
      tags:
        - CRM
      security:
        - bearerAuth: []
      parameters:
        - in: header
          name: X-Hub-Signature-256
          schema:
            type: string
          required: true
          description: A hex-encoded SHA256 signature preceded with sha256=
      requestBody:
        description: Contacts to remove
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contacts
                - metadata
              properties:
                contacts:
                  description: Contacts to remove
                  type: array
                  items:
                    type: object
                    required:
                      - id
                    properties:
                      id:
                        type: string
                metadata:
                  type: object
                  required:
                    - sharedKey
                    - id
                    - instanceUrl
                    - expiresAt
                  properties:
                    id:
                      description: CRM integration ID
                      type: string
                      format: crm-id
                    instanceUrl:
                      description: The instance URL provided by the customer
                      type: string
                      format: uri
                    sharedKey:
                      type: object
                      required:
                        - key
                        - nonce
                      properties:
                        key:
                          type: string
                          format: byte
                          description: base64-encoded shared secret that is GCM-AES256-encrypted using `nonce` and application shared key
                        nonce:
                          type: string
                          format: byte
                          description: base64-encoded nonce value
                    expiresAt:
                      description: Expiry time for the request
                      type: string
                      format: date-time
      responses:
        "204":
          description: Contact PII removed successfully
        "401":
          description: Unauthorized
  /v1/subscribe:
    post:
      tags:
        - CRM
      operationId: subscribe
      summary: Subscribe to CRM events
      description: |
        Partner endpoint. Required only when the app does not register its CRM events callback during installation.
      security:
        - bearerAuth: []
      parameters:
        - in: header
          name: X-Hub-Signature-256
          schema:
            type: string
          required: true
          description: A hex-encoded SHA256 signature preceded with sha256=
      requestBody:
        description: Subscription request
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - url
                - metadata
              properties:
                url:
                  example: https://example.com
                  description: Webhook url to register. This MUST be https or the request should be rejected.
                  type: string
                  format: uri
                metadata:
                  type: object
                  required:
                    - sharedKey
                    - id
                    - instanceUrl
                    - expiresAt
                  properties:
                    id:
                      description: CRM integration ID
                      type: string
                      format: crm-id
                    instanceUrl:
                      description: The instance URL provided by the customer
                      type: string
                      format: uri
                    sharedKey:
                      type: object
                      required:
                        - key
                        - nonce
                      properties:
                        key:
                          type: string
                          format: byte
                          description: base64-encoded shared secret that is GCM-AES256-encrypted using `nonce` and application shared key
                        nonce:
                          type: string
                          format: byte
                          description: base64-encoded nonce value
                    expiresAt:
                      description: Expiry time for the request
                      type: string
                      format: date-time
      responses:
        "201":
          description: successful operation
      callbacks:
        caseUpdates:
          "{$request.body#/url}":
            post:
              security:
                - bearerAuth: []
              parameters:
                - in: header
                  name: X-Hub-Signature-256
                  schema:
                    type: string
                  required: true
                  description: A hex-encoded SHA256 signature preceded with sha256=
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      type: object
                      required:
                        - events
                      properties:
                        events:
                          type: array
                          items:
                            anyOf:
                              - type: object
                                required:
                                  - eventType
                                  - timestamp
                                  - version
                                  - caseId
                                  - crmContactId
                                  - conversationId
                                properties:
                                  eventType:
                                    type: string
                                  timestamp:
                                    type: string
                                  version:
                                    type: number
                                    default: 1
                                  caseId:
                                    type: string
                                  crmContactId:
                                    type: string
                                  conversationId:
                                    type: string
                              - type: object
                                required:
                                  - eventType
                                  - timestamp
                                  - version
                                  - caseId
                                  - conversationId
                                properties:
                                  eventType:
                                    type: string
                                  timestamp:
                                    type: string
                                  version:
                                    type: number
                                    default: 1
                                  caseId:
                                    type: string
                                  conversationId:
                                    type: string
                              - type: object
                                required:
                                  - eventType
                                  - timestamp
                                  - version
                                  - command
                                properties:
                                  eventType:
                                    type: string
                                  timestamp:
                                    type: string
                                  version:
                                    type: number
                                    default: 1
                                  reason:
                                    type: string
                                    description: Human readable reason
                                  command:
                                    required:
                                      - commandType
                                      - version
                                      - conversationId
                                    properties:
                                      commandType:
                                        type: string
                                      version:
                                        type: number
                                        default: 1
                                      createdByMember:
                                        type: object
                                        required:
                                          - name
                                          - email
                                        properties:
                                          name:
                                            type: string
                                          email:
                                            type: string
                                      conversationId:
                                        type: string
                            discriminator:
                              propertyName: eventType
                              mapping:
                                CASE_CREATED: "#/components/schemas/CaseCreated"
                                CASE_CLOSED: "#/components/schemas/CaseClosed"
                                ERROR: "#/components/schemas/Error"
              responses:
                "200":
                  description: successful operation
  /v1/conversation/events:
    post:
      operationId: acceptConversationEvent
      summary: Accept conversation event
      description: Accept an inbound or outbound message event for the CRM case conversation feed. Returns 200 when the event is accepted or already processed (same eventId).
      tags:
        - CRM
      security:
        - bearerAuth: []
      parameters:
        - in: header
          name: X-Hub-Signature-256
          schema:
            type: string
          required: true
          description: A hex-encoded SHA256 signature preceded with sha256=
      requestBody:
        description: Conversation events
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - caseId
                - event
                - metadata
              properties:
                caseId:
                  example: example
                  type: string
                event:
                  required:
                    - eventType
                  properties:
                    eventType:
                      type: string
                      enum:
                        - INBOUND_MESSAGE_ADDED
                        - OUTBOUND_MESSAGE_ADDED
                        - INBOUND_MESSAGE_EDITED
                        - OUTBOUND_MESSAGE_EDITED
                        - MESSAGE_MASKED
                        - MESSAGE_DELETED
                  oneOf:
                    - allOf:
                        - allOf:
                            - allOf:
                                - type: object
                                  required:
                                    - eventId
                                    - conversationId
                                    - eventType
                                  properties:
                                    eventId:
                                      type: string
                                      description: Globally unique event identifier for idempotent processing.
                                    conversationId:
                                      type: string
                                      format: conversation-id
                                      description: Hootsuite conversation this event targets.
                                    eventType:
                                      type: string
                                      enum:
                                        - INBOUND_MESSAGE_ADDED
                                        - OUTBOUND_MESSAGE_ADDED
                                        - INBOUND_MESSAGE_EDITED
                                        - OUTBOUND_MESSAGE_EDITED
                                        - MESSAGE_MASKED
                                        - MESSAGE_DELETED
                                - type: object
                                  required:
                                    - messageId
                                  properties:
                                    messageId:
                                      type: string
                                      format: message-id
                                      description: Hootsuite message id targeted by this event.
                            - type: object
                              required:
                                - sentAt
                                - message
                              properties:
                                sentAt:
                                  type: string
                                  format: date-time
                                  description: When the message was sent (from the medium message timestamp).
                                message:
                                  type: object
                                  required:
                                    - socialProfile
                                    - contactProfile
                                    - messageData
                                  properties:
                                    socialProfile:
                                      type: object
                                      required:
                                        - id
                                      properties:
                                        id:
                                          type: string
                                    contactProfile:
                                      type: object
                                      required:
                                        - id
                                      properties:
                                        id:
                                          type: string
                                          format: contact-profile-id
                                    messageData:
                                      type: object
                                      required:
                                        - attachments
                                      properties:
                                        text:
                                          type: string
                                          nullable: true
                                        attachments:
                                          type: array
                                          items:
                                            type: object
                                            required:
                                              - externalUrl
                                              - mediaType
                                            properties:
                                              externalUrl:
                                                type: string
                                              url:
                                                type: object
                                                required:
                                                  - value
                                                  - postProcessingType
                                                properties:
                                                  value:
                                                    type: string
                                                    format: url
                                                  postProcessingType:
                                                    type: string
                                                    enum:
                                                      - S3
                                                      - NONE
                                              mediaType:
                                                type: string
                                                enum:
                                                  - IMAGE
                                                  - VIDEO
                                                  - AUDIO
                                                  - LOCATION
                                                  - FILE
                    - allOf:
                        - allOf:
                            - allOf:
                                - type: object
                                  required:
                                    - eventId
                                    - conversationId
                                    - eventType
                                  properties:
                                    eventId:
                                      type: string
                                      description: Globally unique event identifier for idempotent processing.
                                    conversationId:
                                      type: string
                                      format: conversation-id
                                      description: Hootsuite conversation this event targets.
                                    eventType:
                                      type: string
                                      enum:
                                        - INBOUND_MESSAGE_ADDED
                                        - OUTBOUND_MESSAGE_ADDED
                                        - INBOUND_MESSAGE_EDITED
                                        - OUTBOUND_MESSAGE_EDITED
                                        - MESSAGE_MASKED
                                        - MESSAGE_DELETED
                                - type: object
                                  required:
                                    - messageId
                                  properties:
                                    messageId:
                                      type: string
                                      format: message-id
                                      description: Hootsuite message id targeted by this event.
                            - type: object
                              required:
                                - sentAt
                                - message
                              properties:
                                sentAt:
                                  type: string
                                  format: date-time
                                  description: When the message was sent (from the medium message timestamp).
                                message:
                                  type: object
                                  required:
                                    - socialProfile
                                    - contactProfile
                                    - messageData
                                  properties:
                                    socialProfile:
                                      type: object
                                      required:
                                        - id
                                      properties:
                                        id:
                                          type: string
                                    contactProfile:
                                      type: object
                                      required:
                                        - id
                                      properties:
                                        id:
                                          type: string
                                          format: contact-profile-id
                                    messageData:
                                      type: object
                                      required:
                                        - attachments
                                      properties:
                                        text:
                                          type: string
                                          nullable: true
                                        attachments:
                                          type: array
                                          items:
                                            type: object
                                            required:
                                              - externalUrl
                                              - mediaType
                                            properties:
                                              externalUrl:
                                                type: string
                                              url:
                                                type: object
                                                required:
                                                  - value
                                                  - postProcessingType
                                                properties:
                                                  value:
                                                    type: string
                                                    format: url
                                                  postProcessingType:
                                                    type: string
                                                    enum:
                                                      - S3
                                                      - NONE
                                              mediaType:
                                                type: string
                                                enum:
                                                  - IMAGE
                                                  - VIDEO
                                                  - AUDIO
                                                  - LOCATION
                                                  - FILE
                    - allOf:
                        - allOf:
                            - allOf:
                                - type: object
                                  required:
                                    - eventId
                                    - conversationId
                                    - eventType
                                  properties:
                                    eventId:
                                      type: string
                                      description: Globally unique event identifier for idempotent processing.
                                    conversationId:
                                      type: string
                                      format: conversation-id
                                      description: Hootsuite conversation this event targets.
                                    eventType:
                                      type: string
                                      enum:
                                        - INBOUND_MESSAGE_ADDED
                                        - OUTBOUND_MESSAGE_ADDED
                                        - INBOUND_MESSAGE_EDITED
                                        - OUTBOUND_MESSAGE_EDITED
                                        - MESSAGE_MASKED
                                        - MESSAGE_DELETED
                                - type: object
                                  required:
                                    - messageId
                                  properties:
                                    messageId:
                                      type: string
                                      format: message-id
                                      description: Hootsuite message id targeted by this event.
                            - type: object
                              required:
                                - messageData
                              properties:
                                messageData:
                                  type: object
                                  required:
                                    - attachments
                                  properties:
                                    text:
                                      type: string
                                      nullable: true
                                    attachments:
                                      type: array
                                      items:
                                        type: object
                                        required:
                                          - externalUrl
                                          - mediaType
                                        properties:
                                          externalUrl:
                                            type: string
                                          url:
                                            type: object
                                            required:
                                              - value
                                              - postProcessingType
                                            properties:
                                              value:
                                                type: string
                                                format: url
                                              postProcessingType:
                                                type: string
                                                enum:
                                                  - S3
                                                  - NONE
                                          mediaType:
                                            type: string
                                            enum:
                                              - IMAGE
                                              - VIDEO
                                              - AUDIO
                                              - LOCATION
                                              - FILE
                    - allOf:
                        - allOf:
                            - allOf:
                                - type: object
                                  required:
                                    - eventId
                                    - conversationId
                                    - eventType
                                  properties:
                                    eventId:
                                      type: string
                                      description: Globally unique event identifier for idempotent processing.
                                    conversationId:
                                      type: string
                                      format: conversation-id
                                      description: Hootsuite conversation this event targets.
                                    eventType:
                                      type: string
                                      enum:
                                        - INBOUND_MESSAGE_ADDED
                                        - OUTBOUND_MESSAGE_ADDED
                                        - INBOUND_MESSAGE_EDITED
                                        - OUTBOUND_MESSAGE_EDITED
                                        - MESSAGE_MASKED
                                        - MESSAGE_DELETED
                                - type: object
                                  required:
                                    - messageId
                                  properties:
                                    messageId:
                                      type: string
                                      format: message-id
                                      description: Hootsuite message id targeted by this event.
                            - type: object
                              required:
                                - messageData
                              properties:
                                messageData:
                                  type: object
                                  required:
                                    - attachments
                                  properties:
                                    text:
                                      type: string
                                      nullable: true
                                    attachments:
                                      type: array
                                      items:
                                        type: object
                                        required:
                                          - externalUrl
                                          - mediaType
                                        properties:
                                          externalUrl:
                                            type: string
                                          url:
                                            type: object
                                            required:
                                              - value
                                              - postProcessingType
                                            properties:
                                              value:
                                                type: string
                                                format: url
                                              postProcessingType:
                                                type: string
                                                enum:
                                                  - S3
                                                  - NONE
                                          mediaType:
                                            type: string
                                            enum:
                                              - IMAGE
                                              - VIDEO
                                              - AUDIO
                                              - LOCATION
                                              - FILE
                    - allOf:
                        - allOf:
                            - type: object
                              required:
                                - eventId
                                - conversationId
                                - eventType
                              properties:
                                eventId:
                                  type: string
                                  description: Globally unique event identifier for idempotent processing.
                                conversationId:
                                  type: string
                                  format: conversation-id
                                  description: Hootsuite conversation this event targets.
                                eventType:
                                  type: string
                                  enum:
                                    - INBOUND_MESSAGE_ADDED
                                    - OUTBOUND_MESSAGE_ADDED
                                    - INBOUND_MESSAGE_EDITED
                                    - OUTBOUND_MESSAGE_EDITED
                                    - MESSAGE_MASKED
                                    - MESSAGE_DELETED
                            - type: object
                              required:
                                - messageId
                              properties:
                                messageId:
                                  type: string
                                  format: message-id
                                  description: Hootsuite message id targeted by this event.
                        - type: object
                          properties:
                            text:
                              type: string
                              nullable: true
                    - allOf:
                        - allOf:
                            - type: object
                              required:
                                - eventId
                                - conversationId
                                - eventType
                              properties:
                                eventId:
                                  type: string
                                  description: Globally unique event identifier for idempotent processing.
                                conversationId:
                                  type: string
                                  format: conversation-id
                                  description: Hootsuite conversation this event targets.
                                eventType:
                                  type: string
                                  enum:
                                    - INBOUND_MESSAGE_ADDED
                                    - OUTBOUND_MESSAGE_ADDED
                                    - INBOUND_MESSAGE_EDITED
                                    - OUTBOUND_MESSAGE_EDITED
                                    - MESSAGE_MASKED
                                    - MESSAGE_DELETED
                            - type: object
                              required:
                                - messageId
                              properties:
                                messageId:
                                  type: string
                                  format: message-id
                                  description: Hootsuite message id targeted by this event.
                  discriminator:
                    propertyName: eventType
                    mapping:
                      INBOUND_MESSAGE_ADDED: "#/components/schemas/InboundMessageAddedEvent"
                      OUTBOUND_MESSAGE_ADDED: "#/components/schemas/OutboundMessageAddedEvent"
                      INBOUND_MESSAGE_EDITED: "#/components/schemas/InboundMessageEditedEvent"
                      OUTBOUND_MESSAGE_EDITED: "#/components/schemas/OutboundMessageEditedEvent"
                      MESSAGE_MASKED: "#/components/schemas/MessageMaskedEvent"
                      MESSAGE_DELETED: "#/components/schemas/MessageDeletedEvent"
                metadata:
                  type: object
                  required:
                    - sharedKey
                    - id
                    - instanceUrl
                    - expiresAt
                  properties:
                    id:
                      description: CRM integration ID
                      type: string
                      format: crm-id
                    instanceUrl:
                      description: The instance URL provided by the customer
                      type: string
                      format: uri
                    sharedKey:
                      type: object
                      required:
                        - key
                        - nonce
                      properties:
                        key:
                          type: string
                          format: byte
                          description: base64-encoded shared secret that is GCM-AES256-encrypted using `nonce` and application shared key
                        nonce:
                          type: string
                          format: byte
                          description: base64-encoded nonce value
                    expiresAt:
                      description: Expiry time for the request
                      type: string
                      format: date-time
      responses:
        "200":
          description: Event accepted or already processed (idempotent).
        "400":
          description: Bad request.
        "401":
          description: Unauthorized
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        Bearer token that allows Hootsuite to issue requests on a user's behalf. The token is generated by a prior call to /v1/oauth2/token.
  schemas:
    CaseCreated:
      type: object
      required:
        - eventType
        - timestamp
        - version
        - caseId
        - crmContactId
        - conversationId
      properties:
        eventType:
          type: string
        timestamp:
          type: string
        version:
          type: number
          default: 1
        caseId:
          type: string
        crmContactId:
          type: string
        conversationId:
          type: string
    CaseClosed:
      type: object
      required:
        - eventType
        - timestamp
        - version
        - caseId
        - conversationId
      properties:
        eventType:
          type: string
        timestamp:
          type: string
        version:
          type: number
          default: 1
        caseId:
          type: string
        conversationId:
          type: string
    Error:
      type: object
      required:
        - eventType
        - timestamp
        - version
        - command
      properties:
        eventType:
          type: string
        timestamp:
          type: string
        version:
          type: number
          default: 1
        reason:
          type: string
          description: Human readable reason
        command:
          required:
            - commandType
            - version
            - conversationId
          properties:
            commandType:
              type: string
            version:
              type: number
              default: 1
            createdByMember:
              type: object
              required:
                - name
                - email
              properties:
                name:
                  type: string
                email:
                  type: string
            conversationId:
              type: string
    InboundMessageAddedEvent:
      allOf:
        - allOf:
            - allOf:
                - type: object
                  required:
                    - eventId
                    - conversationId
                    - eventType
                  properties:
                    eventId:
                      type: string
                      description: Globally unique event identifier for idempotent processing.
                    conversationId:
                      type: string
                      format: conversation-id
                      description: Hootsuite conversation this event targets.
                    eventType:
                      type: string
                      enum:
                        - INBOUND_MESSAGE_ADDED
                        - OUTBOUND_MESSAGE_ADDED
                        - INBOUND_MESSAGE_EDITED
                        - OUTBOUND_MESSAGE_EDITED
                        - MESSAGE_MASKED
                        - MESSAGE_DELETED
                - type: object
                  required:
                    - messageId
                  properties:
                    messageId:
                      type: string
                      format: message-id
                      description: Hootsuite message id targeted by this event.
            - type: object
              required:
                - sentAt
                - message
              properties:
                sentAt:
                  type: string
                  format: date-time
                  description: When the message was sent (from the medium message timestamp).
                message:
                  type: object
                  required:
                    - socialProfile
                    - contactProfile
                    - messageData
                  properties:
                    socialProfile:
                      type: object
                      required:
                        - id
                      properties:
                        id:
                          type: string
                    contactProfile:
                      type: object
                      required:
                        - id
                      properties:
                        id:
                          type: string
                          format: contact-profile-id
                    messageData:
                      type: object
                      required:
                        - attachments
                      properties:
                        text:
                          type: string
                          nullable: true
                        attachments:
                          type: array
                          items:
                            type: object
                            required:
                              - externalUrl
                              - mediaType
                            properties:
                              externalUrl:
                                type: string
                              url:
                                type: object
                                required:
                                  - value
                                  - postProcessingType
                                properties:
                                  value:
                                    type: string
                                    format: url
                                  postProcessingType:
                                    type: string
                                    enum:
                                      - S3
                                      - NONE
                              mediaType:
                                type: string
                                enum:
                                  - IMAGE
                                  - VIDEO
                                  - AUDIO
                                  - LOCATION
                                  - FILE
    OutboundMessageAddedEvent:
      allOf:
        - allOf:
            - allOf:
                - type: object
                  required:
                    - eventId
                    - conversationId
                    - eventType
                  properties:
                    eventId:
                      type: string
                      description: Globally unique event identifier for idempotent processing.
                    conversationId:
                      type: string
                      format: conversation-id
                      description: Hootsuite conversation this event targets.
                    eventType:
                      type: string
                      enum:
                        - INBOUND_MESSAGE_ADDED
                        - OUTBOUND_MESSAGE_ADDED
                        - INBOUND_MESSAGE_EDITED
                        - OUTBOUND_MESSAGE_EDITED
                        - MESSAGE_MASKED
                        - MESSAGE_DELETED
                - type: object
                  required:
                    - messageId
                  properties:
                    messageId:
                      type: string
                      format: message-id
                      description: Hootsuite message id targeted by this event.
            - type: object
              required:
                - sentAt
                - message
              properties:
                sentAt:
                  type: string
                  format: date-time
                  description: When the message was sent (from the medium message timestamp).
                message:
                  type: object
                  required:
                    - socialProfile
                    - contactProfile
                    - messageData
                  properties:
                    socialProfile:
                      type: object
                      required:
                        - id
                      properties:
                        id:
                          type: string
                    contactProfile:
                      type: object
                      required:
                        - id
                      properties:
                        id:
                          type: string
                          format: contact-profile-id
                    messageData:
                      type: object
                      required:
                        - attachments
                      properties:
                        text:
                          type: string
                          nullable: true
                        attachments:
                          type: array
                          items:
                            type: object
                            required:
                              - externalUrl
                              - mediaType
                            properties:
                              externalUrl:
                                type: string
                              url:
                                type: object
                                required:
                                  - value
                                  - postProcessingType
                                properties:
                                  value:
                                    type: string
                                    format: url
                                  postProcessingType:
                                    type: string
                                    enum:
                                      - S3
                                      - NONE
                              mediaType:
                                type: string
                                enum:
                                  - IMAGE
                                  - VIDEO
                                  - AUDIO
                                  - LOCATION
                                  - FILE
    InboundMessageEditedEvent:
      allOf:
        - allOf:
            - allOf:
                - type: object
                  required:
                    - eventId
                    - conversationId
                    - eventType
                  properties:
                    eventId:
                      type: string
                      description: Globally unique event identifier for idempotent processing.
                    conversationId:
                      type: string
                      format: conversation-id
                      description: Hootsuite conversation this event targets.
                    eventType:
                      type: string
                      enum:
                        - INBOUND_MESSAGE_ADDED
                        - OUTBOUND_MESSAGE_ADDED
                        - INBOUND_MESSAGE_EDITED
                        - OUTBOUND_MESSAGE_EDITED
                        - MESSAGE_MASKED
                        - MESSAGE_DELETED
                - type: object
                  required:
                    - messageId
                  properties:
                    messageId:
                      type: string
                      format: message-id
                      description: Hootsuite message id targeted by this event.
            - type: object
              required:
                - messageData
              properties:
                messageData:
                  type: object
                  required:
                    - attachments
                  properties:
                    text:
                      type: string
                      nullable: true
                    attachments:
                      type: array
                      items:
                        type: object
                        required:
                          - externalUrl
                          - mediaType
                        properties:
                          externalUrl:
                            type: string
                          url:
                            type: object
                            required:
                              - value
                              - postProcessingType
                            properties:
                              value:
                                type: string
                                format: url
                              postProcessingType:
                                type: string
                                enum:
                                  - S3
                                  - NONE
                          mediaType:
                            type: string
                            enum:
                              - IMAGE
                              - VIDEO
                              - AUDIO
                              - LOCATION
                              - FILE
    OutboundMessageEditedEvent:
      allOf:
        - allOf:
            - allOf:
                - type: object
                  required:
                    - eventId
                    - conversationId
                    - eventType
                  properties:
                    eventId:
                      type: string
                      description: Globally unique event identifier for idempotent processing.
                    conversationId:
                      type: string
                      format: conversation-id
                      description: Hootsuite conversation this event targets.
                    eventType:
                      type: string
                      enum:
                        - INBOUND_MESSAGE_ADDED
                        - OUTBOUND_MESSAGE_ADDED
                        - INBOUND_MESSAGE_EDITED
                        - OUTBOUND_MESSAGE_EDITED
                        - MESSAGE_MASKED
                        - MESSAGE_DELETED
                - type: object
                  required:
                    - messageId
                  properties:
                    messageId:
                      type: string
                      format: message-id
                      description: Hootsuite message id targeted by this event.
            - type: object
              required:
                - messageData
              properties:
                messageData:
                  type: object
                  required:
                    - attachments
                  properties:
                    text:
                      type: string
                      nullable: true
                    attachments:
                      type: array
                      items:
                        type: object
                        required:
                          - externalUrl
                          - mediaType
                        properties:
                          externalUrl:
                            type: string
                          url:
                            type: object
                            required:
                              - value
                              - postProcessingType
                            properties:
                              value:
                                type: string
                                format: url
                              postProcessingType:
                                type: string
                                enum:
                                  - S3
                                  - NONE
                          mediaType:
                            type: string
                            enum:
                              - IMAGE
                              - VIDEO
                              - AUDIO
                              - LOCATION
                              - FILE
    MessageMaskedEvent:
      allOf:
        - allOf:
            - type: object
              required:
                - eventId
                - conversationId
                - eventType
              properties:
                eventId:
                  type: string
                  description: Globally unique event identifier for idempotent processing.
                conversationId:
                  type: string
                  format: conversation-id
                  description: Hootsuite conversation this event targets.
                eventType:
                  type: string
                  enum:
                    - INBOUND_MESSAGE_ADDED
                    - OUTBOUND_MESSAGE_ADDED
                    - INBOUND_MESSAGE_EDITED
                    - OUTBOUND_MESSAGE_EDITED
                    - MESSAGE_MASKED
                    - MESSAGE_DELETED
            - type: object
              required:
                - messageId
              properties:
                messageId:
                  type: string
                  format: message-id
                  description: Hootsuite message id targeted by this event.
        - type: object
          properties:
            text:
              type: string
              nullable: true
    MessageDeletedEvent:
      allOf:
        - allOf:
            - type: object
              required:
                - eventId
                - conversationId
                - eventType
              properties:
                eventId:
                  type: string
                  description: Globally unique event identifier for idempotent processing.
                conversationId:
                  type: string
                  format: conversation-id
                  description: Hootsuite conversation this event targets.
                eventType:
                  type: string
                  enum:
                    - INBOUND_MESSAGE_ADDED
                    - OUTBOUND_MESSAGE_ADDED
                    - INBOUND_MESSAGE_EDITED
                    - OUTBOUND_MESSAGE_EDITED
                    - MESSAGE_MASKED
                    - MESSAGE_DELETED
            - type: object
              required:
                - messageId
              properties:
                messageId:
                  type: string
                  format: message-id
                  description: Hootsuite message id targeted by this event.
