From e500d1216b908a6211ff24f2491d790987eeb59b Mon Sep 17 00:00:00 2001 From: Jan-David Date: Wed, 17 Nov 2021 14:25:15 +0100 Subject: [PATCH] Fix: Make swagger doc compliant to OpenAPI (#3394) This fixes issues in the swagger.json file. The motivation to do so is to be able to generate API clients using https://openapi-generator.tech Doing so will require further changes to the api spec, but this seems like a good first step since it is now "valid" according to editor.swagger.io and openapi-generator validate. Fixes #2806 --- .circleci/config.yml | 14 +- .../definitions/request/contact/create.yml | 5 +- .../request/conversation/create_message.yml | 4 +- swagger/definitions/resource/conversation.yml | 4 +- .../definitions/resource/custom_filter.yml | 6 +- .../definitions/resource/integrations/app.yml | 2 + .../resource/public/conversation.yml | 6 +- .../definitions/resource/public/message.yml | 4 +- swagger/index.yml | 2 +- swagger/parameters/account_id.yml | 3 +- swagger/parameters/agent_bot_id.yml | 3 +- swagger/parameters/contact_sort.yml | 21 +- swagger/parameters/conversation_id.yml | 3 +- swagger/parameters/custom_filter_id.yml | 3 +- swagger/parameters/hook_id.yml | 3 +- swagger/parameters/inbox_id.yml | 3 +- swagger/parameters/message_id.yml | 3 +- swagger/parameters/page.yml | 5 +- swagger/parameters/platform_user_id.yml | 3 +- .../parameters/public/contact_identifier.yml | 3 +- .../parameters/public/inbox_identifier.yml | 3 +- swagger/parameters/report_metric.yml | 11 +- swagger/parameters/report_type.yml | 12 +- swagger/parameters/source_id.yml | 5 +- swagger/parameters/team_id.yml | 3 +- .../paths/application/agent_bots/index.yml | 2 +- swagger/paths/application/agents/create.yml | 13 +- swagger/paths/application/agents/delete.yml | 3 +- swagger/paths/application/agents/update.yml | 12 +- .../application/contact_inboxes/create.yml | 6 +- swagger/paths/application/contacts/crud.yml | 29 +- .../paths/application/conversation/create.yml | 41 -- .../paths/application/conversation/filter.yml | 85 ++- .../paths/application/conversation/index.yml | 24 +- .../conversation/labels/create.yml | 2 +- .../messages/create_attachment.yml | 3 +- .../conversation/messages/index.yml | 11 +- .../conversation/toggle_status.yml | 3 +- swagger/paths/application/inboxes/create.yml | 3 +- .../inboxes/inbox_members/create.yml | 9 +- .../inboxes/inbox_members/delete.yml | 9 +- .../inboxes/inbox_members/update.yml | 11 +- .../application/inboxes/set_agent_bot.yml | 3 +- swagger/paths/application/inboxes/update.yml | 7 +- swagger/paths/index.yml | 81 +-- .../paths/platform/account_users/create.yml | 5 +- .../paths/platform/account_users/delete.yml | 3 +- swagger/paths/platform/users/login.yml | 41 +- .../paths/public/inboxes/contacts/create.yml | 3 +- .../paths/public/inboxes/contacts/show.yml | 3 +- .../paths/public/inboxes/contacts/update.yml | 3 +- .../public/inboxes/conversations/create.yml | 3 +- .../paths/public/inboxes/messages/create.yml | 3 +- .../paths/public/inboxes/messages/update.yml | 3 +- swagger/swagger.json | 664 +++++++----------- 55 files changed, 527 insertions(+), 695 deletions(-) delete mode 100644 swagger/paths/application/conversation/create.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index c5a6430a3..5c9b27f03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ defaults: &defaults working_directory: ~/build docker: # specify the version you desire here - - image: cimg/ruby:3.0.2-node + - image: cimg/ruby:3.0.2-browsers # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images @@ -77,6 +77,18 @@ jobs: paths: - cc-test-reporter + # verify swagger specification + - run: + name: Verify swagger API specification + command: | + bundle exec rake swagger:build + if [[ `git status swagger/swagger.json --porcelain` ]] + then + echo "ERROR: The swagger.json file is not in sync with the yaml specification. Run 'rake swagger:build' and commit 'swagger/swagger.json'." + exit 1 + fi + curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.0/openapi-generator-cli-5.3.0.jar > ~/tmp/openapi-generator-cli-5.3.0.jar + java -jar ~/tmp/openapi-generator-cli-5.3.0.jar validate -i swagger/swagger.json # Database setup - run: yarn install --check-files - run: bundle exec rake db:create diff --git a/swagger/definitions/request/contact/create.yml b/swagger/definitions/request/contact/create.yml index c2b010892..068dda9ae 100644 --- a/swagger/definitions/request/contact/create.yml +++ b/swagger/definitions/request/contact/create.yml @@ -1,8 +1,9 @@ type: object +required: + - inbox_id properties: inbox_id: type: number - required: true name: type: string description: name of the contact @@ -12,7 +13,7 @@ properties: phone_number: type: string description: phone number of the contact - identifier: + identifier: type: string description: A unique identifier for the contact in external system custom_attributes: diff --git a/swagger/definitions/request/conversation/create_message.yml b/swagger/definitions/request/conversation/create_message.yml index da3b27a2d..9082f1318 100644 --- a/swagger/definitions/request/conversation/create_message.yml +++ b/swagger/definitions/request/conversation/create_message.yml @@ -1,9 +1,10 @@ type: object +required: + - content properties: content: type: string description: The content of the message - required: true message_type: type: string enum: ['outgoing', 'incoming'] @@ -18,4 +19,3 @@ properties: content_attributes: type: object description: attributes based on your content type - diff --git a/swagger/definitions/resource/conversation.yml b/swagger/definitions/resource/conversation.yml index 9de4dafb8..24c27f681 100644 --- a/swagger/definitions/resource/conversation.yml +++ b/swagger/definitions/resource/conversation.yml @@ -5,6 +5,8 @@ properties: description: ID of the conversation messages: type: array + items: + $ref: '#/definitions/message' account_id: type: number description: Account Id @@ -21,7 +23,7 @@ properties: contact_last_seen_at: type: string agent_last_seen_at: - type: agent_last_seen_at + type: string unread_count: type: number description: The number of unread messages diff --git a/swagger/definitions/resource/custom_filter.yml b/swagger/definitions/resource/custom_filter.yml index 130377d62..6d96c1e84 100644 --- a/swagger/definitions/resource/custom_filter.yml +++ b/swagger/definitions/resource/custom_filter.yml @@ -14,8 +14,10 @@ properties: type: object description: A query that needs to be saved as a custom filter created_at: - type: datetime + type: string + format: date-time description: The time at which the custom filter was created updated_at: - type: datetime + type: string + format: date-time description: The time at which the custom filter was updated diff --git a/swagger/definitions/resource/integrations/app.yml b/swagger/definitions/resource/integrations/app.yml index ce7fb1e75..1136f2aca 100644 --- a/swagger/definitions/resource/integrations/app.yml +++ b/swagger/definitions/resource/integrations/app.yml @@ -20,4 +20,6 @@ properties: description: Whether multiple hooks can be created for the integration hooks: type: array + items: + type: object description: If there are any hooks created for this integration diff --git a/swagger/definitions/resource/public/conversation.yml b/swagger/definitions/resource/public/conversation.yml index 97e4b48eb..a2f797e1b 100644 --- a/swagger/definitions/resource/public/conversation.yml +++ b/swagger/definitions/resource/public/conversation.yml @@ -1,5 +1,5 @@ type: object -properties: +properties: id: type: integer description: Id of the conversation @@ -8,7 +8,9 @@ properties: description: The inbox id of the conversation messages: type: array + items: + $ref: '#/definitions/message' description: Messages in the conversation contact: type: object - description: The contact information associated to the conversation \ No newline at end of file + description: The contact information associated to the conversation diff --git a/swagger/definitions/resource/public/message.yml b/swagger/definitions/resource/public/message.yml index fe2c80a0c..242a4fbf4 100644 --- a/swagger/definitions/resource/public/message.yml +++ b/swagger/definitions/resource/public/message.yml @@ -1,5 +1,5 @@ type: object -properties: +properties: id: type: string description: Id of the message @@ -23,6 +23,8 @@ properties: description: Conversation Id of the message attachments: type: array + items: + type: object description: Attachments if any sender: type: object diff --git a/swagger/index.yml b/swagger/index.yml index 908c27509..2420658e3 100644 --- a/swagger/index.yml +++ b/swagger/index.yml @@ -10,7 +10,7 @@ info: name: MIT License url: https://opensource.org/licenses/MIT host: app.chatwoot.com -basePath: +basePath: / schemes: - https produces: diff --git a/swagger/parameters/account_id.yml b/swagger/parameters/account_id.yml index 133155c21..aa3d48a8a 100644 --- a/swagger/parameters/account_id.yml +++ b/swagger/parameters/account_id.yml @@ -1,6 +1,5 @@ in: path name: account_id -schema: - type: integer +type: integer required: true description: The numeric ID of the account diff --git a/swagger/parameters/agent_bot_id.yml b/swagger/parameters/agent_bot_id.yml index 4d1479cb4..6c94ef5dc 100644 --- a/swagger/parameters/agent_bot_id.yml +++ b/swagger/parameters/agent_bot_id.yml @@ -1,6 +1,5 @@ in: path name: id -schema: - type: integer +type: integer required: true description: The ID of the agentbot to be updated diff --git a/swagger/parameters/contact_sort.yml b/swagger/parameters/contact_sort.yml index f25d07760..6f3da0b1b 100644 --- a/swagger/parameters/contact_sort.yml +++ b/swagger/parameters/contact_sort.yml @@ -1,15 +1,14 @@ in: query name: sort -schema: - type: string - enum: - - name - - email - - phone_number - - last_activity_at - - -name - - -email - - -phone_number - - -last_activity_at +type: string +enum: + - name + - email + - phone_number + - last_activity_at + - -name + - -email + - -phone_number + - -last_activity_at required: false description: The attribute by which list should be sorted diff --git a/swagger/parameters/conversation_id.yml b/swagger/parameters/conversation_id.yml index 4f4cb19ab..d8de755fe 100644 --- a/swagger/parameters/conversation_id.yml +++ b/swagger/parameters/conversation_id.yml @@ -1,6 +1,5 @@ in: path name: conversation_id -schema: - type: integer +type: integer required: true description: The numeric ID of the conversation diff --git a/swagger/parameters/custom_filter_id.yml b/swagger/parameters/custom_filter_id.yml index 46776511f..b19f52f8e 100644 --- a/swagger/parameters/custom_filter_id.yml +++ b/swagger/parameters/custom_filter_id.yml @@ -1,6 +1,5 @@ in: path name: custom_filter_id -schema: - type: integer +type: integer required: true description: The numeric ID of the custom filter diff --git a/swagger/parameters/hook_id.yml b/swagger/parameters/hook_id.yml index f1c50c3d4..c1600def4 100644 --- a/swagger/parameters/hook_id.yml +++ b/swagger/parameters/hook_id.yml @@ -1,6 +1,5 @@ in: path name: hook_id -schema: - type: integer +type: integer required: true description: The numeric ID of the integration hook diff --git a/swagger/parameters/inbox_id.yml b/swagger/parameters/inbox_id.yml index 58640fb08..716d34de6 100644 --- a/swagger/parameters/inbox_id.yml +++ b/swagger/parameters/inbox_id.yml @@ -1,6 +1,5 @@ in: path name: inbox_id -schema: - type: integer +type: integer required: true description: The ID of the Inbox diff --git a/swagger/parameters/message_id.yml b/swagger/parameters/message_id.yml index 3064a31e2..3fc6edfcf 100644 --- a/swagger/parameters/message_id.yml +++ b/swagger/parameters/message_id.yml @@ -1,6 +1,5 @@ in: path name: message_id -schema: - type: integer +type: integer required: true description: The numeric ID of the message diff --git a/swagger/parameters/page.yml b/swagger/parameters/page.yml index 3ef0f55b6..8cdc77b1e 100644 --- a/swagger/parameters/page.yml +++ b/swagger/parameters/page.yml @@ -1,7 +1,6 @@ in: query name: page -schema: - type: integer - default: 1 +type: integer +default: 1 required: false description: The page parameter diff --git a/swagger/parameters/platform_user_id.yml b/swagger/parameters/platform_user_id.yml index 708a0aad9..d31f71878 100644 --- a/swagger/parameters/platform_user_id.yml +++ b/swagger/parameters/platform_user_id.yml @@ -1,6 +1,5 @@ in: path name: id -schema: - type: integer +type: integer required: true description: The numeric ID of the user on the platform diff --git a/swagger/parameters/public/contact_identifier.yml b/swagger/parameters/public/contact_identifier.yml index 3dd2d28c2..6bb522c6b 100644 --- a/swagger/parameters/public/contact_identifier.yml +++ b/swagger/parameters/public/contact_identifier.yml @@ -1,6 +1,5 @@ in: path name: contact_identifier -schema: - type: string +type: string required: true description: The source id of contact obtained on contact create diff --git a/swagger/parameters/public/inbox_identifier.yml b/swagger/parameters/public/inbox_identifier.yml index 35e33e6c2..091c0d73e 100644 --- a/swagger/parameters/public/inbox_identifier.yml +++ b/swagger/parameters/public/inbox_identifier.yml @@ -1,6 +1,5 @@ in: path name: inbox_identifier -schema: - type: string +type: string required: true description: The identifier obtained from API inbox channel diff --git a/swagger/parameters/report_metric.yml b/swagger/parameters/report_metric.yml index d40cadc9c..552b0d310 100644 --- a/swagger/parameters/report_metric.yml +++ b/swagger/parameters/report_metric.yml @@ -1,7 +1,12 @@ in: query name: metric -schema: - type: string - enum: [conversations_count, incoming_messages_count, outgoing_messages_count, avg_first_response_time, avg_resolution_time, resolutions_count] +type: string +enum: + - conversations_count + - incoming_messages_count + - outgoing_messages_count + - avg_first_response_time + - avg_resolution_time + - resolutions_count required: true description: The type of metric diff --git a/swagger/parameters/report_type.yml b/swagger/parameters/report_type.yml index 407478d9d..5def952c6 100644 --- a/swagger/parameters/report_type.yml +++ b/swagger/parameters/report_type.yml @@ -1,7 +1,11 @@ in: query name: report_type -schema: - type: string - enum: [account,agent,inbox,label,team] +type: string +enum: + - account + - agent + - inbox + - label + - team required: true -description: Type of report +description: Type of report diff --git a/swagger/parameters/source_id.yml b/swagger/parameters/source_id.yml index 47536332f..408beed86 100644 --- a/swagger/parameters/source_id.yml +++ b/swagger/parameters/source_id.yml @@ -1,2 +1,5 @@ +in: path +name: source_id +required: true type: string -description: "Id of the session for which the conversation is created.\n\n\n\n Source Ids can be obtained through contactable inboxes API or via generated.

Website: Chatwoot generated string which can be obtained from webhook events.
Phone Channels(Twilio): Phone number in e164 format
Email Channels: Contact Email address
API Channel: Any Random String" \ No newline at end of file +description: "Id of the session for which the conversation is created.\n\n\n\n Source Ids can be obtained through contactable inboxes API or via generated.

Website: Chatwoot generated string which can be obtained from webhook events.
Phone Channels(Twilio): Phone number in e164 format
Email Channels: Contact Email address
API Channel: Any Random String" diff --git a/swagger/parameters/team_id.yml b/swagger/parameters/team_id.yml index e71d32d6e..805c32c2d 100644 --- a/swagger/parameters/team_id.yml +++ b/swagger/parameters/team_id.yml @@ -1,6 +1,5 @@ in: path name: id -schema: - type: integer +type: integer required: true description: The ID of the team to be updated diff --git a/swagger/paths/application/agent_bots/index.yml b/swagger/paths/application/agent_bots/index.yml index 26766f5c8..2c5fe289f 100644 --- a/swagger/paths/application/agent_bots/index.yml +++ b/swagger/paths/application/agent_bots/index.yml @@ -10,7 +10,7 @@ responses: type: array description: 'Array of agent bots' items: - - $ref: '#/definitions/agent_bot' + $ref: '#/definitions/agent_bot' 401: description: Unauthorized diff --git a/swagger/paths/application/agents/create.yml b/swagger/paths/application/agents/create.yml index 01ae1ed42..b206eb306 100644 --- a/swagger/paths/application/agents/create.yml +++ b/swagger/paths/application/agents/create.yml @@ -11,21 +11,22 @@ parameters: required: true schema: type: object + required: + - name + - email + - role properties: - name: + name: type: string description: Full Name of the agent - required: true email: type: string description: Email of the Agent - required: true - role: + role: type: string enum: ['agent', 'administrator'] description: Whether its administrator or agent - required: true - availability_status: + availability_status: type: string enum: ['available', 'busy', 'offline'] description: The availability setting of the agent. diff --git a/swagger/paths/application/agents/delete.yml b/swagger/paths/application/agents/delete.yml index 533d3f1ca..1872fd8ea 100644 --- a/swagger/paths/application/agents/delete.yml +++ b/swagger/paths/application/agents/delete.yml @@ -8,8 +8,7 @@ security: parameters: - in: path name: id - schema: - type: integer + type: integer required: true description: The ID of the agent to be deleted responses: diff --git a/swagger/paths/application/agents/update.yml b/swagger/paths/application/agents/update.yml index bd3b3f2cb..693bef5b2 100644 --- a/swagger/paths/application/agents/update.yml +++ b/swagger/paths/application/agents/update.yml @@ -8,8 +8,7 @@ security: parameters: - in: path name: id - schema: - type: integer + type: integer required: true description: The ID of the agent to be updated. - name: data @@ -17,13 +16,14 @@ parameters: required: true schema: type: object + required: + - role properties: - role: + role: type: string enum: ['agent', 'administrator'] description: Whether its administrator or agent - required: true - availability: + availability: type: string enum: ['available', 'busy', 'offline'] description: The availability setting of the agent. @@ -39,4 +39,4 @@ responses: 404: description: Agent not found 403: - description: Access denied \ No newline at end of file + description: Access denied diff --git a/swagger/paths/application/contact_inboxes/create.yml b/swagger/paths/application/contact_inboxes/create.yml index 210949ebf..2b784b5dd 100644 --- a/swagger/paths/application/contact_inboxes/create.yml +++ b/swagger/paths/application/contact_inboxes/create.yml @@ -16,13 +16,15 @@ post: required: true schema: type: object + required: + - inbox_id properties: inbox_id: type: number description: The ID of the inbox - required: true source_id: - $ref: '#/parameters/source_id' + type: string + description: Contact Inbox Source Id responses: 200: description: Success diff --git a/swagger/paths/application/contacts/crud.yml b/swagger/paths/application/contacts/crud.yml index 7f0089b4b..af9fecff7 100644 --- a/swagger/paths/application/contacts/crud.yml +++ b/swagger/paths/application/contacts/crud.yml @@ -1,16 +1,17 @@ +parameters: + - $ref: '#/parameters/account_id' + - name: id + in: path + type: number + description: ID of the contact + required: true + get: tags: - Contact operationId: contactDetails summary: Show Contact description: Get a contact belonging to the account using ID - parameters: - - $ref: '#/parameters/account_id' - - name: id - in: path - type: number - description: ID of the contact - required: true responses: 200: description: Success @@ -28,12 +29,6 @@ put: summary: Update Contact description: Update a contact belonging to the account using ID parameters: - - $ref: '#/parameters/account_id' - - name: id - in: path - type: number - description: ID of the contact - required: true - name: data in: body required: true @@ -54,16 +49,10 @@ delete: - Contact operationId: contactDelete summary: Delete Contact - parameters: - - name: id - in: path - type: number - description: ID of the contact - required: true responses: 200: description: Success 401: description: Unauthorized 404: - description: Contact not found \ No newline at end of file + description: Contact not found diff --git a/swagger/paths/application/conversation/create.yml b/swagger/paths/application/conversation/create.yml deleted file mode 100644 index 104460bae..000000000 --- a/swagger/paths/application/conversation/create.yml +++ /dev/null @@ -1,41 +0,0 @@ -get: - tags: - - Conversation - operationId: conversationList - description: List all the conversations with pagination - summary: Conversations List - parameters: - - $ref: '#/parameters/account_id' - - name: assignee_type - in: query - type: string - enum: ['me', 'unassigned', 'all', 'assigned'] - required: true - - name: status - in: query - type: string - enum: ['open', 'resolved', 'pending'] - required: true - - name: page - in: query - type: integer - required: true - - name: inbox_id - in: query - type: integer - - name: labels - in: query - type: array - items: - type: string - - responses: - 200: - description: Success - schema: - $ref: '#/definitions/conversation_list' - 400: - description: Bad Request Error - schema: - $ref: '#/definitions/bad_request_error' - description: Access denied \ No newline at end of file diff --git a/swagger/paths/application/conversation/filter.yml b/swagger/paths/application/conversation/filter.yml index 39d8259cf..ce14b7823 100644 --- a/swagger/paths/application/conversation/filter.yml +++ b/swagger/paths/application/conversation/filter.yml @@ -1,44 +1,43 @@ -post: - tags: - - Conversation - operationId: conversationFilter - description: Filter conversations with custom filter options and pagination - summary: Conversations Filter - security: - - userApiKey: [] - - agentBotApiKey: [] - parameters: - - name: page - in: query - type: integer - - name: payload - in: body - required: true - schema: - type: array - items: - type: object - properties: - attribute_key: +tags: + - Conversation +operationId: conversationFilter +description: Filter conversations with custom filter options and pagination +summary: Conversations Filter +security: + - userApiKey: [] + - agentBotApiKey: [] +parameters: + - name: page + in: query + type: integer + - name: payload + in: body + required: true + schema: + type: array + items: + type: object + properties: + attribute_key: + type: string + description: filter attribute name + filter_operator: + type: string + description: filter operator name + values: + type: array + items: type: string - description: filter attribute name - filter_operator: - type: string - description: filter operator name - values: - type: array - description: array of the attribute values to filter - query_operator: - type: string - description: query operator name - - $ref: '#/parameters/account_id' - responses: - 200: - description: Success - schema: - $ref: '#/definitions/conversation_list' - 400: - description: Bad Request Error - schema: - $ref: '#/definitions/bad_request_error' - description: Access denied + description: array of the attribute values to filter + query_operator: + type: string + description: query operator name +responses: + 200: + description: Success + schema: + $ref: '#/definitions/conversation_list' + 400: + description: Bad Request Error + schema: + $ref: '#/definitions/bad_request_error' diff --git a/swagger/paths/application/conversation/index.yml b/swagger/paths/application/conversation/index.yml index 022fe7911..d5f8f9c0c 100644 --- a/swagger/paths/application/conversation/index.yml +++ b/swagger/paths/application/conversation/index.yml @@ -1,24 +1,27 @@ +parameters: + - $ref: '#/parameters/account_id' + get: tags: - Conversation - operationId: conversationSearch - description: Search for conversations containing a messages with the query string - summary: Conversations Search + operationId: conversationList + description: List all the conversations with pagination + summary: Conversations List parameters: - - name: q - in: query - type: string - name: assignee_type in: query type: string enum: ['me', 'unassigned', 'all', 'assigned'] + required: true - name: status in: query type: string - enum: ['open', 'resolved', 'pending', 'all'] + enum: ['open', 'resolved', 'pending'] + required: true - name: page in: query type: integer + required: true - name: inbox_id in: query type: integer @@ -27,7 +30,6 @@ get: type: array items: type: string - - $ref: '#/parameters/account_id' responses: 200: @@ -38,8 +40,6 @@ get: description: Bad Request Error schema: $ref: '#/definitions/bad_request_error' - description: Access denied - post: tags: @@ -51,7 +51,6 @@ post: - userApiKey: [] - agentBotApiKey: [] parameters: - - $ref: '#/parameters/account_id' - name: data in: body required: true @@ -59,7 +58,8 @@ post: type: object properties: source_id: - $ref: '#/parameters/source_id' + type: string + description: Conversation source id inbox_id: type: string description: "Id of inbox in which the conversation is created
Allowed Inbox Types: Website, Phone, Api, Email " diff --git a/swagger/paths/application/conversation/labels/create.yml b/swagger/paths/application/conversation/labels/create.yml index 6082ccae4..0f686ee24 100644 --- a/swagger/paths/application/conversation/labels/create.yml +++ b/swagger/paths/application/conversation/labels/create.yml @@ -13,7 +13,7 @@ parameters: labels: type: array description: Array of labels (comma-separated strings) - properties: + items: type: string responses: 200: diff --git a/swagger/paths/application/conversation/messages/create_attachment.yml b/swagger/paths/application/conversation/messages/create_attachment.yml index 155876e13..594f9a819 100644 --- a/swagger/paths/application/conversation/messages/create_attachment.yml +++ b/swagger/paths/application/conversation/messages/create_attachment.yml @@ -31,7 +31,8 @@ post: type: array description: The files to be uploaded. items: - type: file + type: string + format: binary responses: diff --git a/swagger/paths/application/conversation/messages/index.yml b/swagger/paths/application/conversation/messages/index.yml index 8fe7558ae..d99e8393b 100644 --- a/swagger/paths/application/conversation/messages/index.yml +++ b/swagger/paths/application/conversation/messages/index.yml @@ -6,12 +6,13 @@ description: List all messages of a conversation responses: 200: description: Success - type: array - description: Array of messages schema: - allOf: - - $ref: '#/definitions/generic_id' - - $ref: '#/definitions/message' + type: array + description: Array of messages + items: + allOf: + - $ref: '#/definitions/generic_id' + - $ref: '#/definitions/message' 404: description: Conversation not found 401: diff --git a/swagger/paths/application/conversation/toggle_status.yml b/swagger/paths/application/conversation/toggle_status.yml index a737281a4..14172e27c 100644 --- a/swagger/paths/application/conversation/toggle_status.yml +++ b/swagger/paths/application/conversation/toggle_status.yml @@ -12,11 +12,12 @@ parameters: required: true schema: type: object + required: + - status properties: status: type: string enum: ["open", "resolved", "pending"] - required: true description: The status of the conversation responses: 200: diff --git a/swagger/paths/application/inboxes/create.yml b/swagger/paths/application/inboxes/create.yml index 3cb30689e..2a63775e7 100644 --- a/swagger/paths/application/inboxes/create.yml +++ b/swagger/paths/application/inboxes/create.yml @@ -16,7 +16,8 @@ post: type: string description: The name of the inbox avatar: - type: file + type: string + format: binary description: File for avatar image channel: type: object diff --git a/swagger/paths/application/inboxes/inbox_members/create.yml b/swagger/paths/application/inboxes/inbox_members/create.yml index 6ffd75af5..2cbbb4598 100644 --- a/swagger/paths/application/inboxes/inbox_members/create.yml +++ b/swagger/paths/application/inboxes/inbox_members/create.yml @@ -11,15 +11,18 @@ parameters: required: true schema: type: object + required: + - inbox_id + - user_ids properties: inbox_id: type: string description: The ID of the inbox - required: true - user_ids: + user_ids: type: array + items: + type: integer description: IDs of users to be added to the inbox - required: true responses: 200: description: Success diff --git a/swagger/paths/application/inboxes/inbox_members/delete.yml b/swagger/paths/application/inboxes/inbox_members/delete.yml index a19f1c179..3167b28c6 100644 --- a/swagger/paths/application/inboxes/inbox_members/delete.yml +++ b/swagger/paths/application/inboxes/inbox_members/delete.yml @@ -11,15 +11,18 @@ parameters: required: true schema: type: object + required: + - inbox_id + - user_ids properties: inbox_id: type: string description: The ID of the inbox - required: true - user_ids: + user_ids: type: array + items: + type: integer description: IDs of users to be deleted from the inbox - required: true responses: 200: description: Success diff --git a/swagger/paths/application/inboxes/inbox_members/update.yml b/swagger/paths/application/inboxes/inbox_members/update.yml index 0bcf81747..3a06cef27 100644 --- a/swagger/paths/application/inboxes/inbox_members/update.yml +++ b/swagger/paths/application/inboxes/inbox_members/update.yml @@ -2,7 +2,7 @@ tags: - Inbox operationId: update-agents-in-inbox summary: Update Agents in Inbox -description: All agents execept the one passed in params will be removed +description: All agents except the one passed in params will be removed security: - userApiKey: [] parameters: @@ -11,15 +11,18 @@ parameters: required: true schema: type: object + required: + - inbox_id + - user_ids properties: inbox_id: type: string description: The ID of the inbox - required: true - user_ids: + user_ids: type: array + items: + type: integer description: IDs of users to be added to the inbox - required: true responses: 200: description: Success diff --git a/swagger/paths/application/inboxes/set_agent_bot.yml b/swagger/paths/application/inboxes/set_agent_bot.yml index fbe0c03ab..b37b06915 100644 --- a/swagger/paths/application/inboxes/set_agent_bot.yml +++ b/swagger/paths/application/inboxes/set_agent_bot.yml @@ -16,10 +16,11 @@ post: required: true schema: type: object + required: + - agent_bot properties: agent_bot: type: number - required: true description: 'Agent bot ID' responses: 204: diff --git a/swagger/paths/application/inboxes/update.yml b/swagger/paths/application/inboxes/update.yml index 90a3d13ce..d44822114 100644 --- a/swagger/paths/application/inboxes/update.yml +++ b/swagger/paths/application/inboxes/update.yml @@ -16,17 +16,18 @@ patch: required: true schema: type: object + required: + - enable_auto_assignment properties: name: type: string description: The name of the inbox enable_auto_assignment: type: boolean - required: true description: 'Enable Auto Assignment' avatar: - type: file - required: false + type: string + format: binary description: 'Image file for avatar' channel: type: object diff --git a/swagger/paths/index.yml b/swagger/paths/index.yml index 7f25ec67e..b25d6ff68 100644 --- a/swagger/paths/index.yml +++ b/swagger/paths/index.yml @@ -2,10 +2,10 @@ # Accounts -platform/api/v1/accounts: +/platform/api/v1/accounts: post: $ref: ./platform/accounts/create.yml -platform/api/v1/accounts/{id}: +/platform/api/v1/accounts/{account_id}: parameters: - $ref: '#/parameters/account_id' get: @@ -18,7 +18,7 @@ platform/api/v1/accounts/{id}: # Account Users -platform/api/v1/accounts/{id}/account_users: +/platform/api/v1/accounts/{account_id}/account_users: parameters: - $ref: '#/parameters/account_id' get: @@ -30,12 +30,12 @@ platform/api/v1/accounts/{id}/account_users: # AgentBots -platform/api/v1/agent_bots: +/platform/api/v1/agent_bots: get: $ref: ./platform/agent_bots/index.yml post: $ref: ./platform/agent_bots/create.yml -platform/api/v1/agent_bots/{id}: +/platform/api/v1/agent_bots/{id}: parameters: - $ref: '#/parameters/agent_bot_id' get: @@ -47,10 +47,10 @@ platform/api/v1/agent_bots/{id}: # Users -platform/api/v1/users: +/platform/api/v1/users: post: $ref: ./platform/users/create.yml -platform/api/v1/users/{id}: +/platform/api/v1/users/{id}: parameters: - $ref: '#/parameters/platform_user_id' get: @@ -59,10 +59,11 @@ platform/api/v1/users/{id}: $ref: ./platform/users/update.yml delete: $ref: ./platform/users/delete.yml -platform/api/v1/users/{id}/login: +/platform/api/v1/users/{id}/login: parameters: - $ref: '#/parameters/platform_user_id' - $ref: './platform/users/login.yml' + get: + $ref: './platform/users/login.yml' # ---------------- end of platform path -----------# @@ -71,12 +72,12 @@ platform/api/v1/users/{id}/login: # Contacts -public/api/v1/inboxes/{inbox_identifier}/contacts: +/public/api/v1/inboxes/{inbox_identifier}/contacts: parameters: - $ref: '#/parameters/public_inbox_identifier' post: $ref: ./public/inboxes/contacts/create.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -86,7 +87,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}: $ref: ./public/inboxes/contacts/update.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -95,7 +96,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat get: $ref: ./public/inboxes/conversations/index.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -104,7 +105,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat $ref: ./public/inboxes/messages/create.yml get: $ref: ./public/inboxes/messages/index.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -139,11 +140,15 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat # Agents /api/v1/accounts/{account_id}/agents: + parameters: + - $ref: '#/parameters/account_id' get: $ref: ./application/agents/index.yml post: $ref: ./application/agents/create.yml /api/v1/accounts/{account_id}/agents/{id}: + parameters: + - $ref: '#/parameters/account_id' patch: $ref: ./application/agents/update.yml delete: @@ -167,18 +172,13 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat # Conversations /api/v1/accounts/{account_id}/conversations: - parameters: - - $ref: '#/parameters/account_id' $ref: ./application/conversation/index.yml -/api/v1/accounts/{account_id}/conversations/: - parameters: - - $ref: '#/parameters/account_id' - $ref: ./application/conversation/create.yml /api/v1/accounts/{account_id}/conversations/filter: parameters: - $ref: '#/parameters/account_id' - $ref: ./application/conversation/filter.yml -/api/v1/accounts/{account_id}/conversations/{converstion_id}: + post: + $ref: ./application/conversation/filter.yml +/api/v1/accounts/{account_id}/conversations/{conversation_id}: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/conversation_id' @@ -227,7 +227,10 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat $ref: ./application/inboxes/set_agent_bot.yml # Inbox Members -/api/v1/accounts/{account_id}/inbox_members: +/api/v1/accounts/{account_id}/inbox_members/{inbox_id}: + parameters: + - $ref: '#/parameters/account_id' + - $ref: '#/parameters/inbox_id' get: $ref: ./application/inboxes/inbox_members/show.yml post: @@ -240,9 +243,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat # Messages -/api/v1/accounts/{account_id}/conversations/{id}/messages: - $ref: ./application/conversation/messages/create_attachment.yml -/api/v1/accounts/{account_id}/conversations/{converstion_id}/messages: +/api/v1/accounts/{account_id}/conversations/{conversation_id}/messages: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/conversation_id' @@ -269,6 +270,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat /api/v1/accounts/{account_id}/integrations/hooks: post: $ref: './application/integrations/hooks/create.yml' +/api/v1/accounts/{account_id}/integrations/hooks/{hook_id}: patch: $ref: ./application/integrations/hooks/update.yml delete: @@ -308,9 +310,8 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat - $ref: '#/parameters/account_id' - in: query name: filter_type - schema: - type: string - enum: ['conversation', 'contact', 'report'] + type: string + enum: ['conversation', 'contact', 'report'] required: false description: The type of custom filter get: @@ -331,48 +332,42 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat ### Reports # List -/api/v2/accounts/{id}/reports: +/api/v2/accounts/{account_id}/reports: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/report_metric' - $ref: '#/parameters/report_type' - in: query name: id - schema: - type: string + type: string description: The Id of specific object in case of agent/inbox/label - in: query name: since - schema: - type: string + type: string description: The timestamp from where report should start. - in: query name: until - schema: - type: string + type: string description: The timestamp from where report should stop. get: $ref: './application/reports/index.yml' # Summary -/api/v2/accounts/{id}/reports/summary: +/api/v2/accounts/{account_id}/reports/summary: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/report_type' - in: query name: id - schema: - type: string + type: string description: The Id of specific object in case of agent/inbox/label - in: query name: since - schema: - type: string + type: string description: The timestamp from where report should start. - in: query name: until - schema: - type: string + type: string description: The timestamp from where report should stop. get: $ref: './application/reports/summary.yml' diff --git a/swagger/paths/platform/account_users/create.yml b/swagger/paths/platform/account_users/create.yml index 614efb7a8..97dc7127d 100644 --- a/swagger/paths/platform/account_users/create.yml +++ b/swagger/paths/platform/account_users/create.yml @@ -11,15 +11,16 @@ parameters: required: true schema: type: object + required: + - user_id + - role properties: user_id: type: integer description: The ID of the user - required: true role: type: string description: whether user is an administrator or agent - required: true responses: 200: diff --git a/swagger/paths/platform/account_users/delete.yml b/swagger/paths/platform/account_users/delete.yml index 1ff822a9e..d864619f7 100644 --- a/swagger/paths/platform/account_users/delete.yml +++ b/swagger/paths/platform/account_users/delete.yml @@ -11,11 +11,12 @@ parameters: required: true schema: type: object + required: + - user_id properties: user_id: type: integer description: The ID of the user - required: true responses: 200: diff --git a/swagger/paths/platform/users/login.yml b/swagger/paths/platform/users/login.yml index 3f0b8b4c1..be210c7aa 100644 --- a/swagger/paths/platform/users/login.yml +++ b/swagger/paths/platform/users/login.yml @@ -1,21 +1,20 @@ -get: - tags: - - Users - operationId: get-sso-url-of-a-user - summary: Get User SSO Link - description: Get the sso link of a user - security: - - platformAppApiKey: [] - responses: - 200: - description: Success - schema: - type: object - properties: - url: - type: string - description: SSO url to autenticate the user - 401: - description: Unauthorized - 404: - description: The given user does not exist +tags: + - Users +operationId: get-sso-url-of-a-user +summary: Get User SSO Link +description: Get the sso link of a user +security: + - platformAppApiKey: [] +responses: + 200: + description: Success + schema: + type: object + properties: + url: + type: string + description: SSO url to autenticate the user + 401: + description: Unauthorized + 404: + description: The given user does not exist diff --git a/swagger/paths/public/inboxes/contacts/create.yml b/swagger/paths/public/inboxes/contacts/create.yml index e504ee9e7..51d894f3e 100644 --- a/swagger/paths/public/inboxes/contacts/create.yml +++ b/swagger/paths/public/inboxes/contacts/create.yml @@ -3,8 +3,7 @@ tags: operationId: create-a-contact summary: Create a contact description: Create a contact -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/paths/public/inboxes/contacts/show.yml b/swagger/paths/public/inboxes/contacts/show.yml index a57d3e0b5..a5d8b8fdc 100644 --- a/swagger/paths/public/inboxes/contacts/show.yml +++ b/swagger/paths/public/inboxes/contacts/show.yml @@ -3,8 +3,7 @@ tags: operationId: get-details-of-a-contact summary: Get a contact description: Get the details of a contact -security: - - nil +security: [] responses: 200: description: Success diff --git a/swagger/paths/public/inboxes/contacts/update.yml b/swagger/paths/public/inboxes/contacts/update.yml index 084926134..a413c76b3 100644 --- a/swagger/paths/public/inboxes/contacts/update.yml +++ b/swagger/paths/public/inboxes/contacts/update.yml @@ -3,8 +3,7 @@ tags: operationId: update-a-contact summary: Update a contact description: Update a contact's attributes -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/paths/public/inboxes/conversations/create.yml b/swagger/paths/public/inboxes/conversations/create.yml index 2654685f5..5f694ff34 100644 --- a/swagger/paths/public/inboxes/conversations/create.yml +++ b/swagger/paths/public/inboxes/conversations/create.yml @@ -3,8 +3,7 @@ tags: operationId: create-a-conversation summary: Create a conversation description: Create a conversation -security: - - nil +security: [] responses: 200: description: Success diff --git a/swagger/paths/public/inboxes/messages/create.yml b/swagger/paths/public/inboxes/messages/create.yml index 16e44eb0d..902090952 100644 --- a/swagger/paths/public/inboxes/messages/create.yml +++ b/swagger/paths/public/inboxes/messages/create.yml @@ -3,8 +3,7 @@ tags: operationId: create-a-message summary: Create a message description: Create a message -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/paths/public/inboxes/messages/update.yml b/swagger/paths/public/inboxes/messages/update.yml index 70ffb9d0c..a211f39ca 100644 --- a/swagger/paths/public/inboxes/messages/update.yml +++ b/swagger/paths/public/inboxes/messages/update.yml @@ -3,8 +3,7 @@ tags: operationId: update-a-message summary: Update a message description: Update a message -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/swagger.json b/swagger/swagger.json index fadd07720..d19f43a7f 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -14,7 +14,7 @@ } }, "host": "app.chatwoot.com", - "basePath": null, + "basePath": "/", "schemes": [ "https" ], @@ -52,7 +52,7 @@ } ], "paths": { - "platform/api/v1/accounts": { + "/platform/api/v1/accounts": { "post": { "tags": [ "Accounts" @@ -90,7 +90,7 @@ } } }, - "platform/api/v1/accounts/{id}": { + "/platform/api/v1/accounts/{account_id}": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -188,7 +188,7 @@ } } }, - "platform/api/v1/accounts/{id}/account_users": { + "/platform/api/v1/accounts/{account_id}/account_users": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -259,16 +259,18 @@ "required": true, "schema": { "type": "object", + "required": [ + "user_id", + "role" + ], "properties": { "user_id": { "type": "integer", - "description": "The ID of the user", - "required": true + "description": "The ID of the user" }, "role": { "type": "string", - "description": "whether user is an administrator or agent", - "required": true + "description": "whether user is an administrator or agent" } } } @@ -320,11 +322,13 @@ "required": true, "schema": { "type": "object", + "required": [ + "user_id" + ], "properties": { "user_id": { "type": "integer", - "description": "The ID of the user", - "required": true + "description": "The ID of the user" } } } @@ -343,7 +347,7 @@ } } }, - "platform/api/v1/agent_bots": { + "/platform/api/v1/agent_bots": { "get": { "tags": [ "AgentBots" @@ -411,7 +415,7 @@ } } }, - "platform/api/v1/agent_bots/{id}": { + "/platform/api/v1/agent_bots/{id}": { "parameters": [ { "$ref": "#/parameters/agent_bot_id" @@ -509,7 +513,7 @@ } } }, - "platform/api/v1/users": { + "/platform/api/v1/users": { "post": { "tags": [ "Users" @@ -547,7 +551,7 @@ } } }, - "platform/api/v1/users/{id}": { + "/platform/api/v1/users/{id}": { "parameters": [ { "$ref": "#/parameters/platform_user_id" @@ -645,7 +649,12 @@ } } }, - "platform/api/v1/users/{id}/login": { + "/platform/api/v1/users/{id}/login": { + "parameters": [ + { + "$ref": "#/parameters/platform_user_id" + } + ], "get": { "tags": [ "Users" @@ -682,7 +691,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -696,7 +705,7 @@ "summary": "Create a contact", "description": "Create a contact", "security": [ - "nil" + ], "parameters": [ { @@ -721,7 +730,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -738,7 +747,7 @@ "summary": "Get a contact", "description": "Get the details of a contact", "security": [ - "nil" + ], "responses": { "200": { @@ -763,7 +772,7 @@ "summary": "Update a contact", "description": "Update a contact's attributes", "security": [ - "nil" + ], "parameters": [ { @@ -788,7 +797,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -805,7 +814,7 @@ "summary": "Create a conversation", "description": "Create a conversation", "security": [ - "nil" + ], "responses": { "200": { @@ -843,7 +852,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -863,7 +872,7 @@ "summary": "Create a message", "description": "Create a message", "security": [ - "nil" + ], "parameters": [ { @@ -911,7 +920,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -934,7 +943,7 @@ "summary": "Update a message", "description": "Update a message", "security": [ - "nil" + ], "parameters": [ { @@ -978,11 +987,9 @@ "schema": { "type": "array", "description": "Array of agent bots", - "items": [ - { - "$ref": "#/definitions/agent_bot" - } - ] + "items": { + "$ref": "#/definitions/agent_bot" + } } }, "401": { @@ -1104,6 +1111,11 @@ } }, "/api/v1/accounts/{account_id}/agents": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "get": { "tags": [ "Agent" @@ -1155,16 +1167,19 @@ "required": true, "schema": { "type": "object", + "required": [ + "name", + "email", + "role" + ], "properties": { "name": { "type": "string", - "description": "Full Name of the agent", - "required": true + "description": "Full Name of the agent" }, "email": { "type": "string", - "description": "Email of the Agent", - "required": true + "description": "Email of the Agent" }, "role": { "type": "string", @@ -1172,8 +1187,7 @@ "agent", "administrator" ], - "description": "Whether its administrator or agent", - "required": true + "description": "Whether its administrator or agent" }, "availability_status": { "type": "string", @@ -1206,6 +1220,11 @@ } }, "/api/v1/accounts/{account_id}/agents/{id}": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "patch": { "tags": [ "Agent" @@ -1224,9 +1243,7 @@ { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the agent to be updated." }, @@ -1236,6 +1253,9 @@ "required": true, "schema": { "type": "object", + "required": [ + "role" + ], "properties": { "role": { "type": "string", @@ -1243,8 +1263,7 @@ "agent", "administrator" ], - "description": "Whether its administrator or agent", - "required": true + "description": "Whether its administrator or agent" }, "availability": { "type": "string", @@ -1296,9 +1315,7 @@ { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the agent to be deleted" } @@ -1387,6 +1404,18 @@ } }, "/api/v1/accounts/{account_id}/contacts/{id}": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + }, + { + "name": "id", + "in": "path", + "type": "number", + "description": "ID of the contact", + "required": true + } + ], "get": { "tags": [ "Contact" @@ -1394,18 +1423,6 @@ "operationId": "contactDetails", "summary": "Show Contact", "description": "Get a contact belonging to the account using ID", - "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "name": "id", - "in": "path", - "type": "number", - "description": "ID of the contact", - "required": true - } - ], "responses": { "200": { "description": "Success", @@ -1429,16 +1446,6 @@ "summary": "Update Contact", "description": "Update a contact belonging to the account using ID", "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "name": "id", - "in": "path", - "type": "number", - "description": "ID of the contact", - "required": true - }, { "name": "data", "in": "body", @@ -1469,15 +1476,6 @@ ], "operationId": "contactDelete", "summary": "Delete Contact", - "parameters": [ - { - "name": "id", - "in": "path", - "type": "number", - "description": "ID of the contact", - "required": true - } - ], "responses": { "200": { "description": "Success" @@ -1598,14 +1596,17 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id" + ], "properties": { "inbox_id": { "type": "number", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "source_id": { - "$ref": "#/parameters/source_id" + "type": "string", + "description": "Contact Inbox Source Id" } } } @@ -1670,19 +1671,19 @@ } }, "/api/v1/accounts/{account_id}/conversations": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "get": { "tags": [ "Conversation" ], - "operationId": "conversationSearch", - "description": "Search for conversations containing a messages with the query string", - "summary": "Conversations Search", + "operationId": "conversationList", + "description": "List all the conversations with pagination", + "summary": "Conversations List", "parameters": [ - { - "name": "q", - "in": "query", - "type": "string" - }, { "name": "assignee_type", "in": "query", @@ -1692,7 +1693,8 @@ "unassigned", "all", "assigned" - ] + ], + "required": true }, { "name": "status", @@ -1701,14 +1703,15 @@ "enum": [ "open", "resolved", - "pending", - "all" - ] + "pending" + ], + "required": true }, { "name": "page", "in": "query", - "type": "integer" + "type": "integer", + "required": true }, { "name": "inbox_id", @@ -1722,9 +1725,6 @@ "items": { "type": "string" } - }, - { - "$ref": "#/parameters/account_id" } ], "responses": { @@ -1739,8 +1739,7 @@ "schema": { "$ref": "#/definitions/bad_request_error" } - }, - "description": "Access denied" + } } }, "post": { @@ -1763,9 +1762,6 @@ } ], "parameters": [ - { - "$ref": "#/parameters/account_id" - }, { "name": "data", "in": "body", @@ -1774,7 +1770,8 @@ "type": "object", "properties": { "source_id": { - "$ref": "#/parameters/source_id" + "type": "string", + "description": "Conversation source id" }, "inbox_id": { "type": "string", @@ -1836,79 +1833,12 @@ } } }, - "/api/v1/accounts/{account_id}/conversations/": { - "get": { - "tags": [ - "Conversation" - ], - "operationId": "conversationList", - "description": "List all the conversations with pagination", - "summary": "Conversations List", - "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "name": "assignee_type", - "in": "query", - "type": "string", - "enum": [ - "me", - "unassigned", - "all", - "assigned" - ], - "required": true - }, - { - "name": "status", - "in": "query", - "type": "string", - "enum": [ - "open", - "resolved", - "pending" - ], - "required": true - }, - { - "name": "page", - "in": "query", - "type": "integer", - "required": true - }, - { - "name": "inbox_id", - "in": "query", - "type": "integer" - }, - { - "name": "labels", - "in": "query", - "type": "array", - "items": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/conversation_list" - } - }, - "400": { - "description": "Bad Request Error", - "schema": { - "$ref": "#/definitions/bad_request_error" - } - }, - "description": "Access denied" - } - } - }, "/api/v1/accounts/{account_id}/conversations/filter": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "post": { "tags": [ "Conversation" @@ -1953,6 +1883,9 @@ }, "values": { "type": "array", + "items": { + "type": "string" + }, "description": "array of the attribute values to filter" }, "query_operator": { @@ -1962,9 +1895,6 @@ } } } - }, - { - "$ref": "#/parameters/account_id" } ], "responses": { @@ -1979,12 +1909,11 @@ "schema": { "$ref": "#/definitions/bad_request_error" } - }, - "description": "Access denied" + } } } }, - "/api/v1/accounts/{account_id}/conversations/{converstion_id}": { + "/api/v1/accounts/{account_id}/conversations/{conversation_id}": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -2051,6 +1980,9 @@ "required": true, "schema": { "type": "object", + "required": [ + "status" + ], "properties": { "status": { "type": "string", @@ -2059,7 +1991,6 @@ "resolved", "pending" ], - "required": true, "description": "The status of the conversation" } } @@ -2183,7 +2114,7 @@ "labels": { "type": "array", "description": "Array of labels (comma-separated strings)", - "properties": { + "items": { "type": "string" } } @@ -2300,7 +2231,8 @@ "description": "The name of the inbox" }, "avatar": { - "type": "file", + "type": "string", + "format": "binary", "description": "File for avatar image" }, "channel": { @@ -2379,6 +2311,9 @@ "required": true, "schema": { "type": "object", + "required": [ + "enable_auto_assignment" + ], "properties": { "name": { "type": "string", @@ -2386,12 +2321,11 @@ }, "enable_auto_assignment": { "type": "boolean", - "required": true, "description": "Enable Auto Assignment" }, "avatar": { - "type": "file", - "required": false, + "type": "string", + "format": "binary", "description": "Image file for avatar" }, "channel": { @@ -2500,10 +2434,12 @@ "required": true, "schema": { "type": "object", + "required": [ + "agent_bot" + ], "properties": { "agent_bot": { "type": "number", - "required": true, "description": "Agent bot ID" } } @@ -2523,7 +2459,15 @@ } } }, - "/api/v1/accounts/{account_id}/inbox_members": { + "/api/v1/accounts/{account_id}/inbox_members/{inbox_id}": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + }, + { + "$ref": "#/parameters/inbox_id" + } + ], "get": { "tags": [ "Inbox" @@ -2583,16 +2527,21 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id", + "user_ids" + ], "properties": { "inbox_id": { "type": "string", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "user_ids": { "type": "array", - "description": "IDs of users to be added to the inbox", - "required": true + "items": { + "type": "integer" + }, + "description": "IDs of users to be added to the inbox" } } } @@ -2626,7 +2575,7 @@ ], "operationId": "update-agents-in-inbox", "summary": "Update Agents in Inbox", - "description": "All agents execept the one passed in params will be removed", + "description": "All agents except the one passed in params will be removed", "security": [ { "userApiKey": [ @@ -2641,16 +2590,21 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id", + "user_ids" + ], "properties": { "inbox_id": { "type": "string", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "user_ids": { "type": "array", - "description": "IDs of users to be added to the inbox", - "required": true + "items": { + "type": "integer" + }, + "description": "IDs of users to be added to the inbox" } } } @@ -2699,16 +2653,21 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id", + "user_ids" + ], "properties": { "inbox_id": { "type": "string", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "user_ids": { "type": "array", - "description": "IDs of users to be deleted from the inbox", - "required": true + "items": { + "type": "integer" + }, + "description": "IDs of users to be deleted from the inbox" } } } @@ -2730,92 +2689,7 @@ } } }, - "/api/v1/accounts/{account_id}/conversations/{id}/messages": { - "post": { - "tags": [ - "Messages" - ], - "operationId": "conversationNewMessageAttachment", - "summary": "Create New Message Attachment", - "description": "Create an attachment message. Refer to this discussion if you have any further doubts. https://github.com/chatwoot/chatwoot/discussions/1809#discussioncomment-1211845", - "consumes": [ - "multipart/form-data" - ], - "security": [ - { - "userApiKey": [ - - ] - }, - { - "agentBotApiKey": [ - - ] - } - ], - "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "$ref": "#/parameters/conversation_id" - }, - { - "in": "formData", - "name": "content", - "type": "string", - "description": "The content of the message", - "required": true - }, - { - "in": "formData", - "name": "message_type", - "type": "string", - "enum": [ - "outgoing", - "incoming" - ] - }, - { - "in": "formData", - "name": "private", - "type": "boolean", - "description": "Flag to identify if it is a private note" - }, - { - "in": "formData", - "name": "attachments[]", - "type": "array", - "description": "The files to be uploaded.", - "items": { - "type": "file" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/generic_id" - }, - { - "$ref": "#/definitions/message" - } - ] - } - }, - "404": { - "description": "Conversation not found" - }, - "403": { - "description": "Access denied" - } - } - } - }, - "/api/v1/accounts/{account_id}/conversations/{converstion_id}/messages": { + "/api/v1/accounts/{account_id}/conversations/{conversation_id}/messages": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -2833,17 +2707,20 @@ "description": "List all messages of a conversation", "responses": { "200": { - "description": "Array of messages", - "type": "array", + "description": "Success", "schema": { - "allOf": [ - { - "$ref": "#/definitions/generic_id" - }, - { - "$ref": "#/definitions/message" - } - ] + "type": "array", + "description": "Array of messages", + "items": { + "allOf": [ + { + "$ref": "#/definitions/generic_id" + }, + { + "$ref": "#/definitions/message" + } + ] + } } }, "404": { @@ -3003,7 +2880,9 @@ "description": "Unauthorized" } } - }, + } + }, + "/api/v1/accounts/{account_id}/integrations/hooks/{hook_id}": { "patch": { "tags": [ "Integrations" @@ -3238,14 +3117,12 @@ { "in": "query", "name": "filter_type", - "schema": { - "type": "string", - "enum": [ - "conversation", - "contact", - "report" - ] - }, + "type": "string", + "enum": [ + "conversation", + "contact", + "report" + ], "required": false, "description": "The type of custom filter" } @@ -3386,7 +3263,7 @@ } } }, - "/api/v2/accounts/{id}/reports": { + "/api/v2/accounts/{account_id}/reports": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -3400,25 +3277,19 @@ { "in": "query", "name": "id", - "schema": { - "type": "string" - }, + "type": "string", "description": "The Id of specific object in case of agent/inbox/label" }, { "in": "query", "name": "since", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should start." }, { "in": "query", "name": "until", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should stop." } ], @@ -3449,7 +3320,7 @@ } } }, - "/api/v2/accounts/{id}/reports/summary": { + "/api/v2/accounts/{account_id}/reports/summary": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -3460,25 +3331,19 @@ { "in": "query", "name": "id", - "schema": { - "type": "string" - }, + "type": "string", "description": "The Id of specific object in case of agent/inbox/label" }, { "in": "query", "name": "since", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should start." }, { "in": "query", "name": "until", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should stop." } ], @@ -3587,7 +3452,10 @@ "description": "ID of the conversation" }, "messages": { - "type": "array" + "type": "array", + "items": { + "$ref": "#/definitions/message" + } }, "account_id": { "type": "number", @@ -3614,7 +3482,7 @@ "type": "string" }, "agent_last_seen_at": { - "type": "agent_last_seen_at" + "type": "string" }, "unread_count": { "type": "number", @@ -3909,11 +3777,13 @@ "description": "A query that needs to be saved as a custom filter" }, "created_at": { - "type": "datetime", + "type": "string", + "format": "date-time", "description": "The time at which the custom filter was created" }, "updated_at": { - "type": "datetime", + "type": "string", + "format": "date-time", "description": "The time at which the custom filter was updated" } } @@ -4010,6 +3880,9 @@ }, "hooks": { "type": "array", + "items": { + "type": "object" + }, "description": "If there are any hooks created for this integration" } } @@ -4085,6 +3958,9 @@ }, "messages": { "type": "array", + "items": { + "$ref": "#/definitions/message" + }, "description": "Messages in the conversation" }, "contact": { @@ -4126,6 +4002,9 @@ }, "attachments": { "type": "array", + "items": { + "type": "object" + }, "description": "Attachments if any" }, "sender": { @@ -4183,10 +4062,12 @@ }, "contact_create": { "type": "object", + "required": [ + "inbox_id" + ], "properties": { "inbox_id": { - "type": "number", - "required": true + "type": "number" }, "name": { "type": "string", @@ -4237,11 +4118,13 @@ }, "conversation_message_create": { "type": "object", + "required": [ + "content" + ], "properties": { "content": { "type": "string", - "description": "The content of the message", - "required": true + "description": "The content of the message" }, "message_type": { "type": "string", @@ -4689,165 +4572,138 @@ "account_id": { "in": "path", "name": "account_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the account" }, "agent_bot_id": { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the agentbot to be updated" }, "team_id": { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the team to be updated" }, "inbox_id": { "in": "path", "name": "inbox_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the Inbox" }, "hook_id": { "in": "path", "name": "hook_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the integration hook" }, "source_id": { + "in": "path", + "name": "source_id", + "required": true, "type": "string", "description": "Id of the session for which the conversation is created.\n\n\n\n Source Ids can be obtained through contactable inboxes API or via generated.

Website: Chatwoot generated string which can be obtained from webhook events.
Phone Channels(Twilio): Phone number in e164 format
Email Channels: Contact Email address
API Channel: Any Random String" }, "conversation_id": { "in": "path", "name": "conversation_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the conversation" }, "message_id": { "in": "path", "name": "message_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the message" }, "contact_sort_param": { "in": "query", "name": "sort", - "schema": { - "type": "string", - "enum": [ - "name", - "email", - "phone_number", - "last_activity_at", - "-name", - "-email", - "-phone_number", - "-last_activity_at" - ] - }, + "type": "string", + "enum": [ + "name", + "email", + "phone_number", + "last_activity_at", + "-name", + "-email", + "-phone_number", + "-last_activity_at" + ], "required": false, "description": "The attribute by which list should be sorted" }, "page": { "in": "query", "name": "page", - "schema": { - "type": "integer", - "default": 1 - }, + "type": "integer", + "default": 1, "required": false, "description": "The page parameter" }, "platform_user_id": { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the user on the platform" }, "custom_filter_id": { "in": "path", "name": "custom_filter_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the custom filter" }, "report_type": { "in": "query", "name": "report_type", - "schema": { - "type": "string", - "enum": [ - "account", - "agent", - "inbox", - "label", - "team" - ] - }, + "type": "string", + "enum": [ + "account", + "agent", + "inbox", + "label", + "team" + ], "required": true, "description": "Type of report" }, "report_metric": { "in": "query", "name": "metric", - "schema": { - "type": "string", - "enum": [ - "conversations_count", - "incoming_messages_count", - "outgoing_messages_count", - "avg_first_response_time", - "avg_resolution_time", - "resolutions_count" - ] - }, + "type": "string", + "enum": [ + "conversations_count", + "incoming_messages_count", + "outgoing_messages_count", + "avg_first_response_time", + "avg_resolution_time", + "resolutions_count" + ], "required": true, "description": "The type of metric" }, "public_inbox_identifier": { "in": "path", "name": "inbox_identifier", - "schema": { - "type": "string" - }, + "type": "string", "required": true, "description": "The identifier obtained from API inbox channel" }, "public_contact_identifier": { "in": "path", "name": "contact_identifier", - "schema": { - "type": "string" - }, + "type": "string", "required": true, "description": "The source id of contact obtained on contact create" }