Rentberry Messages API

Messages

OpenAPI Specification

rentberry-messages-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Rentberry Messages API
  description: Renting Done Right. Finally.
  version: 4
tags:
- name: Messages
  description: Messages
paths:
  /v{version}/messages/{userType}:
    get:
      tags:
      - Messages
      summary: Get list of conversations for user.
      description: Available since API version 1. Returns paginated list of conversations for tenant or homeowner.
      operationId: get_api_v1_messages_list
      parameters:
      - name: userType
        in: path
        description: User type filter
        required: true
        schema:
          type: string
          pattern: tenant|homeowner
          enum:
          - tenant
          - homeowner
      - name: page
        in: query
        description: Page number
        required: false
        schema:
          type: integer
          default: 1
      - name: limit
        in: query
        description: Items per page
        required: false
        schema:
          type: integer
          default: 10
      - name: version
        in: path
        required: true
        schema:
          type: string
          pattern: \d+
      responses:
        '200':
          description: Returns paginated list of conversations.
          content:
            application/json:
              schema:
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/ConversationResponse'
                  total:
                    type: integer
                  page:
                    type: integer
                type: object
        '401':
          description: Unauthorized
      security:
      - XAuthToken: []
  /v{version}/messages/apartment/{id}:
    put:
      tags:
      - Messages
      summary: Get or create conversation for apartment listing.
      description: Available since API version 1. Gets existing or creates new conversation for apartment listing.
      operationId: put_api_v1_messages_get_conversation_by_apartment
      parameters:
      - name: id
        in: path
        description: Apartment listing ID
        required: true
        schema:
          type: integer
          pattern: \d+
      - name: version
        in: path
        required: true
        schema:
          type: string
          pattern: \d+
      requestBody:
        required: false
        content:
          application/json:
            schema:
              properties:
                userId:
                  description: Partner user ID (optional)
                  type: integer
              type: object
      responses:
        '200':
          description: Returns conversation ID.
          content:
            application/json:
              schema:
                properties:
                  id:
                    type: integer
                type: object
        '400':
          description: Invalid request or user trying to message themselves
        '401':
          description: Unauthorized
        '403':
          description: User not related to listing
      security:
      - XAuthToken: []
  /v{version}/messages/rental/{id}:
    put:
      tags:
      - Messages
      summary: Get or create conversation for rental.
      description: Available since API version 1. Gets existing or creates new conversation for rental between tenant and homeowner.
      operationId: put_api_v1_messages_get_conversation_by_rental
      parameters:
      - name: id
        in: path
        description: Rental ID
        required: true
        schema:
          type: integer
          pattern: \d+
      - name: version
        in: path
        required: true
        schema:
          type: string
          pattern: \d+
      responses:
        '200':
          description: Returns conversation ID.
          content:
            application/json:
              schema:
                properties:
                  id:
                    type: integer
                type: object
        '401':
          description: Unauthorized
        '403':
          description: User not related to rental
      security:
      - XAuthToken: []
  /v{version}/messages/conversation/{id}:
    get:
      tags:
      - Messages
      summary: Get conversation details.
      description: Available since API version 1. Returns detailed information about a specific conversation.
      operationId: get_api_v1_conversation
      parameters:
      - name: id
        in: path
        description: Conversation ID
        required: true
        schema:
          type: integer
      - name: version
        in: path
        required: true
        schema:
          type: string
          pattern: \d+
      responses:
        '200':
          description: Returns conversation details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationResponse'
        '401':
          description: Unauthorized
        '403':
          description: Access denied to conversation
        '404':
          description: Conversation not found
      security:
      - XAuthToken: []
  /v{version}/messages/{id}:
    get:
      tags:
      - Messages
      summary: Get messages from conversation.
      description: Available since API version 1. Returns paginated list of messages from a conversation.
      operationId: get_api_v1_messages_get_conversation
      parameters:
      - name: id
        in: path
        description: Conversation ID
        required: true
        schema:
          type: integer
          pattern: \d+
      - name: before
        in: query
        description: Get messages before this message ID
        required: false
        schema:
          type: integer
      - name: limit
        in: query
        description: Number of messages to return
        required: false
        schema:
          type: integer
          default: 20
      - name: version
        in: path
        required: true
        schema:
          type: string
          pattern: \d+
      responses:
        '200':
          description: Returns messages from conversation.
          content:
            application/json:
              schema:
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/ConversationMessage'
                  hasMessagesBefore:
                    description: Whether there are more messages before this batch
                    type: boolean
                type: object
        '401':
          description: Unauthorized
        '403':
          description: Access denied to conversation
      security:
      - XAuthToken: []
    post:
      tags:
      - Messages
      summary: Send message to conversation.
      description: Available since API version 1. Sends a new message to the specified conversation.
      operationId: post_api_v1_message_create
      parameters:
      - name: id
        in: path
        description: Conversation ID
        required: true
        schema:
          type: integer
          pattern: \d+
      - name: version
        in: path
        required: true
        schema:
          type: string
          pattern: \d+
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageType'
      responses:
        '200':
          description: Message sent successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationMessage'
        '400':
          description: Validation failed
        '401':
          description: Unauthorized
        '403':
          description: Access denied to conversation
      security:
      - XAuthToken: []
components:
  schemas:
    User:
      required:
      - nameFirst
      - nameLast
      - username
      - phone
      - birthday
      properties:
        hasPassword:
          type: boolean
        phoneCountryCode:
          type: string
        id:
          type: integer
        nameFirst:
          type: string
          maxLength: 255
          minLength: 2
        nameMiddle:
          type: string
          maxLength: 255
          minLength: 1
        nameLast:
          type: string
          maxLength: 255
          minLength: 2
        company:
          $ref: '#/components/schemas/Company'
        companyName:
          type: string
          maxLength: 255
          minLength: 1
        username:
          type: string
          maxLength: 255
          minLength: 1
        profilePictureThumbs:
          type: string
        phone:
          type: string
          maxLength: 15
          minLength: 7
        birthday:
          type: string
          format: date-time
        bio:
          type: string
          maxLength: 1500
        oauthProviders:
          type: array
          items:
            $ref: '#/components/schemas/UserOauthProvider'
        address:
          $ref: '#/components/schemas/UserAddress'
        creditScore:
          $ref: '#/components/schemas/UserCreditScore'
        criminalReport:
          $ref: '#/components/schemas/UserCriminalReport'
        stripeCustomer:
          $ref: '#/components/schemas/UserStripeCustomer'
        active:
          type: boolean
          default: true
        fromNotBerryForbiddenCountry:
          type: boolean
          default: false
        verified:
          type: boolean
          default: false
        emailVerified:
          type: boolean
          default: false
        phoneVerified:
          type: boolean
          default: false
        registered:
          type: boolean
          default: true
        emailNotVerifiedAfter:
          type: string
          format: date-time
        lastActiveAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        statusType:
          type: string
          default: regular
          enum:
          - regular
          - premium
          - premium_pending
          - vip
          - vip_pending
        authToken:
          type: string
        rentalHistory:
          type: array
          items:
            $ref: '#/components/schemas/UserRentalHistory'
        deleted:
          type: boolean
          default: false
        rentalPaymentAccount:
          $ref: '#/components/schemas/RentalPaymentAccount'
        newsletterSubscription:
          type: boolean
          default: false
        premiumPartner:
          type: boolean
          default: false
        locale:
          type: string
          default: en_US
          enum:
          - en_US
          - es_ES
        currency:
          type: string
        lengthUnit:
          type: string
          enum:
          - m
          - ft
        isRaiUser:
          type: boolean
          default: false
      type: object
    MessageType:
      required:
      - body
      properties:
        body:
          type: string
      type: object
    UserOauthProvider:
      properties:
        id:
          type: integer
        provider:
          type: string
        providerId:
          type: string
        connectId:
          type: string
        nameFirst:
          type: string
        nameLast:
          type: string
        pictureUrl:
          type: string
        appId:
          type: string
      type: object
    ConversationResponse:
      properties:
        conversationId:
          type: integer
        lastMessage:
          $ref: '#/components/schemas/ConversationMessage'
        partner:
          $ref: '#/components/schemas/User'
        apartmentId:
          type: integer
        isViewed:
          type: boolean
        topicType:
          type: string
        apartmentAddress:
          $ref: '#/components/schemas/ListingAddress'
        countUnreaded:
          type: integer
        countUnviewed:
          type: integer
        apartmentUrl:
          type: string
      type: object
    UserRentalHistory:
      required:
      - address
      - city
      - homeownerPhone
      properties:
        id:
          type: integer
        user:
          $ref: '#/components/schemas/User'
        applicantId:
          type: integer
        address:
          type: string
          maxLength: 255
          minLength: 3
        city:
          type: string
          maxLength: 255
          minLength: 3
        price:
          type: integer
        term:
          type: integer
        homeownerPhone:
          type: integer
          maxLength: 15
          minLength: 7
      type: object
    Country:
      properties:
        shortCode:
          title: 'ISO 3166-1 alpha-2

            Use in geocoding responses from Google.'
          type: string
        longCode:
          title: ISO 3166-1 alpha-3.
          type: string
        name:
          type: string
        phone:
          type: string
      type: object
    UserCriminalReport:
      properties:
        criminalRecordFound:
          type: boolean
          default: false
        status:
          type: integer
          maxLength: 10
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      type: object
    UserCreditScore:
      properties:
        score:
          type: integer
        creditScoreUpdatedAt:
          type: string
          format: date-time
        alert:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      type: object
    RentalPaymentAccount:
      properties:
        stripeAccountId:
          type: string
        isStripeOnboardingFinished:
          type: boolean
          default: false
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      type: object
    UserStripeCustomer:
      properties:
        customerId:
          type: string
        user:
          $ref: '#/components/schemas/User'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      type: object
    AdminLevelCollection:
      properties: []
      type: object
    Coordinates:
      properties:
        latitude:
          type: number
          format: float
        longitude:
          type: number
          format: float
      type: object
    UserAddress:
      required:
      - street
      - houseNumber
      - city
      - zip
      properties:
        street:
          type: string
          maxLength: 255
          minLength: 1
        houseNumber:
          type: string
          maxLength: 255
          minLength: 1
        streetType:
          type:
          - string
          - 'null'
          maxLength: 10
        city:
          type: string
          maxLength: 255
          minLength: 3
        state:
          $ref: '#/components/schemas/State'
        zip:
          type: string
          maxLength: 9
          minLength: 5
      type: object
    Bounds:
      properties:
        northeast:
          $ref: '#/components/schemas/Coordinates'
        southwest:
          $ref: '#/components/schemas/Coordinates'
      type: object
    Company:
      properties:
        id:
          type: integer
        name:
          type: string
          maxLength: 255
          minLength: 1
        phone:
          type: integer
          maxLength: 15
          minLength: 7
        website:
          type: string
          maxLength: 255
          minLength: 1
        logoThumbs:
          type: string
        email:
          type: string
          maxLength: 255
          minLength: 1
        city:
          type: string
          maxLength: 255
          minLength: 1
        countryCode:
          type: string
          maxLength: 2
          minLength: 2
        provider:
          type: string
        externalId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      type: object
    ListingAddress:
      properties:
        latitude:
          type: number
          format: float
          default: 0
        longitude:
          type: number
          format: float
          default: 0
        apartmentNumber:
          type: string
          maxLength: 64
          minLength: 1
        state:
          $ref: '#/components/schemas/State'
        providedBy:
          type: string
        providerId:
          type:
          - string
          - 'null'
          default: null
        adminLevels:
          default: null
          oneOf:
          - $ref: '#/components/schemas/AdminLevelCollection'
        coordinates:
          default: null
          oneOf:
          - $ref: '#/components/schemas/Coordinates'
        bounds:
          default: null
          oneOf:
          - $ref: '#/components/schemas/Bounds'
        streetNumber:
          type:
          - string
          - 'null'
          default: null
          maxLength: 64
          minLength: 1
        streetName:
          type:
          - string
          - 'null'
          default: null
          maxLength: 255
          minLength: 1
        postalCode:
          type:
          - string
          - 'null'
          default: null
        locality:
          type:
          - string
          - 'null'
          default: null
          maxLength: 255
          minLength: 1
        sublocality:
          type:
          - string
          - 'null'
          default: null
          maxLength: 255
          minLength: 1
        country:
          default: null
          oneOf:
          - $ref: '#/components/schemas/Country'
        timezone:
          type:
          - string
          - 'null'
          default: null
        shortAddress:
          type: string
        exposeAddress:
          type: boolean
          default: true
      type: object
    ConversationMessage:
      required:
      - body
      properties:
        id:
          type: integer
        conversationId:
          type: integer
        userId:
          type: integer
        body:
          type: string
          maxLength: 1000
          minLength: 1
        readed:
          type: boolean
          default: false
        viewed:
          type: boolean
          default: false
        notified:
          type: boolean
          default: false
        notifiedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      type: object
    State:
      properties:
        id:
          type: integer
        shortName:
          type:
          - string
          - 'null'
          default: null
          maxLength: 200
          minLength: 1
        name:
          type:
          - string
          - 'null'
          default: null
          maxLength: 255
          minLength: 1
        description:
          type: string
      type: object