# Conversation API | Sinch Send and receive messages globally over SMS, RCS, WhatsApp, Viber Business, Facebook messenger and other popular channels using the Sinch Conversation API. The Conversation API endpoint uses built-in transcoding to give you the power of conversation across all supported channels and, if required, full control over channel specific features. Version: 1.0 License: MIT ## Servers The {region} variable must be set to us, eu, or br, and it must match the region in which you created your Conversation API app. ``` https://{region}.conversation.api.sinch.com ``` Variables: - `region` Default: "us" Enum: "us", "eu", "br" ## Security ### Basic For more information about basic authentication, see [Basic Authentication](https://developers.sinch.com/docs/conversation/api-reference/#authentication). Type: http Scheme: basic ### oAuth2 The user name and password are your client_id and key_secret from the [Access keys sections](https://dashboard.sinch.com/settings/access-keys) Type: oauth2 ## Download OpenAPI description [Conversation API | Sinch](https://developers.sinch.com/_spec/docs/conversation/api-reference/conversation.yaml) ## Messages To start sending messages you must have a Conversation API [**app**](https://dashboard.sinch.com/convapi/apps). The app holds information about the channel credentials and registered webhooks to which the API delivers callbacks such as message delivery receipts and contact messages. If you don't already have an app please follow the instructions in the getting started guide available in the [Sinch Dashboard](https://dashboard.sinch.com/convapi/getting-started) to create one. ### Send a message - [POST /v1/projects/{project_id}/messages:send](https://developers.sinch.com/docs/conversation/api-reference/conversation/messages/messages_sendmessage.md): You can send a message from a Conversation app to a contact associated with that app. If the recipient is not associated with an existing contact, a new contact will be created. The message is added to the active conversation with the contact if a conversation already exists. If no active conversation exists a new one is started automatically. You can find all of your IDs and authentication credentials on the Sinch Customer Dashboard. ### Update message metadata - [PATCH /v1/projects/{project_id}/messages/{message_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/messages/messages_updatemessagemetadata.md): Update a specific message metadata by its ID. ### Get a message - [GET /v1/projects/{project_id}/messages/{message_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/messages/messages_getmessage.md): Retrieves a specific message by its ID. ### Delete a message - [DELETE /v1/projects/{project_id}/messages/{message_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/messages/messages_deletemessage.md): Delete a specific message by its ID. Note that this operation deletes the message from Conversation API storage; this operation does not affect messages already delivered to recipients' handsets. Also note that removing all messages of a conversation will not automatically delete the conversation. ### List messages - [GET /v1/projects/{project_id}/messages](https://developers.sinch.com/docs/conversation/api-reference/conversation/messages/messages_listmessages.md): This operation lists all messages sent or received via particular Processing Modes. Setting the parameter to allows for querying messages in mode, and setting it to will allow for queries of messages in mode. Combining multiple parameters is supported for more detailed filtering of messages, but some of them are not supported depending on the value specified for . The description for each field will inform if that field may not be supported. The messages are ordered by their property in descending order, where is a timestamp of when the message was enqueued by the Conversation API. This means messages received most recently will be listed first. ## App Apps are created and configured through the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps), are tied to the API user and come with a set of **channel credentials** for each underlying connected channel. The app has a list of **conversations** between itself and different **contacts** which share the same **project**. Webhooks, which the app is attached to, defines the destination for various events coming from the Conversation API. An **app** has the following configurable properties: | Field | Description | | ---------------------------- | ----------------------------------------------------------------------------------------------------------------- | | Display name | The name visible in the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). | | Conversation metadata report | Specifies the amount of **conversation**metadata that's returned as part of each callback. | | Retention Policy | The retention policy specifies how long messages, sent to or from an **app**, are stored by the Conversation API. | ### List all apps for a given project - [GET /v1/projects/{project_id}/apps](https://developers.sinch.com/docs/conversation/api-reference/conversation/app/app_listapps.md): Get a list of all apps in the specified project. ### Create an app - [POST /v1/projects/{project_id}/apps](https://developers.sinch.com/docs/conversation/api-reference/conversation/app/app_createapp.md): You can create a new Conversation API app using the API. You can create an app for one or more channels at once. The ID of the app is generated at creation and will be returned in the response. ### Get an app - [GET /v1/projects/{project_id}/apps/{app_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/app/app_getapp.md): Returns a particular app as specified by the App ID. ### Delete an app - [DELETE /v1/projects/{project_id}/apps/{app_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/app/app_deleteapp.md): Deletes the app specified by the App ID. Note that this operation will not delete contacts (which are stored at the project level) nor any channel-specific resources (for example, WhatsApp Sender Identities will not be deleted). ### Update an app - [PATCH /v1/projects/{project_id}/apps/{app_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/app/app_updateapp.md): Updates a particular app as specified by the App ID. Note that this is a operation, so any specified field values will replace existing values. Therefore, . For example, if you'd like to add new , you can get your existing Conversation API app, extract the existing list, append your new configuration to that list, and include the updated list in this update call. ## Contact A contact is a collection that groups together underlying connected **channel recipient identities**. It's tied to a specific **project** and is therefore considered public to all **apps** sharing the same **project**. Most contact creation and maintenance is handled by the Conversation API's automatic [contact management](https://developers.sinch.com/docs/conversation/contact-management/) processes. However, you can also use API calls to manually manage your contacts. A **contact** has the following configurable properties: | Field | Description | | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | | Channel identities | List of channel identities specifying how the contact is identified on underlying channels | | Channel priority | Specifies the channel priority order used when sending messages to this contact. This can be overridden by message specific channel priority order. | | Display name | Optional display name used in chat windows and other UIs | | Email | Optional Email of the contact | | External id | Optional identifier of the contact in external systems | | Metadata | Optional metadata associated with the contact. | ### List Contacts - [GET /v1/projects/{project_id}/contacts](https://developers.sinch.com/docs/conversation/api-reference/conversation/contact/contact_listcontacts.md): List all contacts in the project. Note that, if a WhatsApp contact is returned, the field of that contact may be populated with the WhatsApp display name (if the name is already stored on the server and the field has not been overwritten by the user). ### Create a Contact - [POST /v1/projects/{project_id}/contacts](https://developers.sinch.com/docs/conversation/api-reference/conversation/contact/contact_createcontact.md): Most Conversation API contacts are created automatically when a message is sent to a new recipient. You can also create a new contact manually using this API call. ### Get a Contact - [GET /v1/projects/{project_id}/contacts/{contact_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/contact/contact_getcontact.md): Returns a specific contact as specified by the contact ID. Note the following: - If a WhatsApp contact is returned, the field of that contact may be populated with the WhatsApp display name (if the name is already stored on the server and the field has not been overwritten by the user). - If you receive an Inbound Message callback for an MO message on the Instagram channel, the corresponding payload will not include the Instagram username. You may use the and values included in the callback to retreive the username (detailed in the field) with this Conversation API operation. ### Delete a Contact - [DELETE /v1/projects/{project_id}/contacts/{contact_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/contact/contact_deletecontact.md): Delete a contact as specified by the contact ID. ### Update a Contact - [PATCH /v1/projects/{project_id}/contacts/{contact_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/contact/contact_updatecontact.md): Updates a contact as specified by the contact ID. ### Merge two Contacts - [POST /v1/projects/{project_id}/contacts/{destination_id}:merge](https://developers.sinch.com/docs/conversation/api-reference/conversation/contact/contact_mergecontact.md): The remaining contact will contain all conversations that the removed contact did. If both contacts had conversations within the same App, messages from the removed contact will be merged into corresponding active conversations in the destination contact. Channel identities will be moved from the source contact to the destination contact only for channels that weren't present there before. Moved channel identities will be placed at the bottom of the channel priority list. Optional fields from the source contact will be copied only if corresponding fields in the destination contact are empty The contact being removed cannot be referenced after this call. ### Get Channel Profile - [POST /v1/projects/{project_id}/contacts:getChannelProfile](https://developers.sinch.com/docs/conversation/api-reference/conversation/contact/contact_getchannelprofile.md): Get user profile from a specific channel. Only supported on , , and channels. Note that, in order to retrieve a WhatsApp display name, you can use the Get a Contact or List Contacts operations, which will populate the field of each returned contact with the WhatsApp display name (if the name is already stored on the server and the field has not been overwritten by the user). ## Conversation Endpoints for working with the conversation log. ### List conversations - [GET /v1/projects/{project_id}/conversations](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_listconversations.md): This operation lists all conversations that are associated with an app and/or a contact. ### Create a conversation - [POST /v1/projects/{project_id}/conversations](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_createconversation.md): Creates a new empty conversation. It is generally not needed to create a conversation explicitly since sending or receiving a message automatically creates a new conversation if it does not already exist between the given app and contact. Creating empty conversation is useful if the metadata of the conversation should be populated when the first message in the conversation is a contact message or the first message in the conversation comes out-of-band and needs to be injected with InjectMessage endpoint. ### Get a conversation - [GET /v1/projects/{project_id}/conversations/{conversation_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_getconversation.md): Retrieves a conversation by id. A conversation has two participating entities, an app and a contact. ### Delete a conversation - [DELETE /v1/projects/{project_id}/conversations/{conversation_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_deleteconversation.md): Deletes a conversation together with all the messages sent as part of the conversation. ### Update a conversation - [PATCH /v1/projects/{project_id}/conversations/{conversation_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_updateconversation.md): This operation updates a conversation which can, for instance, be used to update the metadata associated with a conversation. ### List recent conversations - [GET /v1/projects/{project_id}/conversations:recent](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_listrecentconversations.md): This operation lists conversations and their most recent message, ordered by when the most recent message was sent for that conversation. ### Inject an event - [POST /v1/projects/{project_id}/conversations/{conversation_id}:inject-event](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/events_injectevent.md): This operation injects a conversation event in to a specific conversation. It only supports injecting App events in mode. ### Stop conversation - [POST /v1/projects/{project_id}/conversations/{conversation_id}:stop](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_stopactiveconversation.md): This operation stops the referenced conversation, if the conversation is still active. A new conversation will be created if a new message is exchanged between the app or contact that was part of the stopped conversation. ### Inject a message - [POST /v1/projects/{project_id}/conversations/{conversation_id}:inject-message](https://developers.sinch.com/docs/conversation/api-reference/conversation/conversation/conversation_injectmessage.md): This operation injects a conversation message in to a specific conversation. ## Events Endpoint for sending events. ### Send an event - [POST /v1/projects/{project_id}/events:send](https://developers.sinch.com/docs/conversation/api-reference/conversation/events/events_sendevent.md): Sends an event to the referenced contact from the referenced app. Note that this operation enqueues the event in a queue so a successful response only indicates that the event has been queued. ### Get an event - [GET /v1/projects/{project_id}/events/{event_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/events/events_getevent.md): Get event from ID ### Delete an event - [DELETE /v1/projects/{project_id}/events/{event_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/events/events_deleteevents.md): Delete a specific event by its ID. ### List events - [GET /v1/projects/{project_id}/events](https://developers.sinch.com/docs/conversation/api-reference/conversation/events/events_listevents.md): List all events in a project ## Transcoding Endpoint for transcoding generic message format to channel-specific one. ### Transcode a message - [POST /v1/projects/{project_id}/messages:transcode](https://developers.sinch.com/docs/conversation/api-reference/conversation/transcoding/transcoding_transcodemessage.md): Transcodes the message from the Conversation API format to the channel-specific formats for the requested channels. No message is sent to the contact. ## Capability A capability query checks the options available for reaching the [contact](https://developers.sinch.com/docs/conversation/keyconcepts/#contact) on the channels on which it has a channel identity. Capability queries can only be executed for contacts that already exist in a project and app. For executing the request, either the contact ID or the channel recipient identities of the contact are required. The request is executed asynchronously, therefore the service responds immediately. The result of the capability query is sent to the registered [webhook](https://developers.sinch.com/docs/conversation/keyconcepts/#webhook) for the **CAPABILITY** trigger. ### Capability lookup - [POST /v1/projects/{project_id}/capability:query](https://developers.sinch.com/docs/conversation/api-reference/conversation/capability/capability_querycapability.md): This method is asynchronous - it immediately returns the requested Capability registration. Capability check is then delivered as a callback to registered webhooks with trigger CAPABILITY for every reachable channel. ## Consent Consent queries provide a way to retreive any identities stored within a given consent list. You can also retrieve audit records that provide details for a given identity's journey through [consent management](https://developers.sinch.com/docs/conversation/consent-management/). Note that this feature is currently available for beta testing. To gain access to this functionality, please contact your account manager. ### Get identities from consent list - [GET /v1/projects/{project_id}/apps/{app_id}/consents/{list_type}](https://developers.sinch.com/docs/conversation/api-reference/conversation/consent/consents_getconsents.md): Get all identities contained within a consent list for a given project id, app id, and list type. ### Get audit records from consent lists - [GET /v1/projects/{project_id}/apps/{app_id}/consents/identities/{identity}](https://developers.sinch.com/docs/conversation/api-reference/conversation/consent/consents_getconsentsauditrecords.md): Get all audit records associated with the given identity from the consent lists within the specified project and app. ## Webhooks ### List webhooks - [GET /v1/projects/{project_id}/apps/{app_id}/webhooks](https://developers.sinch.com/docs/conversation/api-reference/conversation/webhooks/webhooks_listwebhooks.md): List all webhooks for a given app as specified by the App ID. ### Create a new webhook - [POST /v1/projects/{project_id}/webhooks](https://developers.sinch.com/docs/conversation/api-reference/conversation/webhooks/webhooks_createwebhook.md): Creates a webhook for receiving callbacks on specific triggers. You can create up to 5 webhooks per app. ### Get a webhook - [GET /v1/projects/{project_id}/webhooks/{webhook_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/webhooks/webhooks_getwebhook.md): Get a webhook as specified by the webhook ID. ### Update an existing webhook - [PATCH /v1/projects/{project_id}/webhooks/{webhook_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/webhooks/webhooks_updatewebhook.md): Updates an existing webhook as specified by the webhook ID. ### Delete an existing webhook - [DELETE /v1/projects/{project_id}/webhooks/{webhook_id}](https://developers.sinch.com/docs/conversation/api-reference/conversation/webhooks/webhooks_deletewebhook.md): Deletes a webhook as specified by the webhook ID.