API Reference
Create a service account
In order to call the API you will first need to create a service account. Go to your Unthread dashboard and find the Service Accounts tab under Settings. Click “Add service account”, give your service account a name, and click “Submit”.
After creating the new service account, you will see a window displaying the service account’s API key. Copy this key and put it somewhere safe and secret. Once you close the window you will not be able to view the key again.
Calling the API
The URL for calls to the API will have the following form, with $ being replaced by the endpoint you are trying to call:
In order to authenticate, you must send an HTTP header with the key “X-Api-Key” and the value set to the service account key created in the previous section. All request and response bodies will be in JSON.
API Conventions
The Unthread API follows RESTful conventions when possible, with most operations performed via GET
, POST
, PATCH
, and DELETE
requests. Request and response bodies are encoded as JSON.
List Endpoints
All list endpoints follow the same conventions. Requests are made in the following format:
Accepted values for SelectField, OrderByField and WhereField depend on the object. Responses are made in the following format:
Responses are paginated by providing a cursor to the next or previous page. The limit per page is 100. An example list request is provided below:
Create and Update Endpoints
Create and update endpoints can specify a select
query param that takes a comma-separated list of fields to return in the response. Example below:
Objects
Conversation
Message
Customer
Tag
User
User Team
Slack Channel
Autoresponder Options
Support Step
Outbound
Webhook Subscription
Approval Request
Collaborator Type
Endpoints
Create Conversation
This endpoint will create and return a new conversation. Behavior will differ depending on the type
field:
- For
type == "triage"
, the conversation will be for internal discussion only and there will be no way to communicate with the customer. ThetriageChannelId
field is required. - For
type == "email"
, the conversation will be for communication with the customer. Replies in the thread with/unthread send
appended will be sent to the customer via email. TheemailInboxId
field is required. TheonBehalfOf
field is used to specify the email address and name of the end user to communicate with.
If customerId
is provided, the conversation will be linked to the given customer and that customer’s autoresponder and SLA settings will be applied.
Request schema:
Attachments:
Files can be attached to the conversation by making a multipart/form-data request instead of a JSON request. The JSON payload should be included as a form field named json
and the files should be included as additional form fields with the name attachments
and the file as the value. Up to 10 files can be attached to a single conversation and the maximum file size is 20MB. See tho following Javascript example for clarification:
Notes:
- Markdown should follow the Slack formatting guide.
- For more info on multipart/form-data requests, see the IEFT RFC 7578.
Get Conversation by ID
This endpoint will return the given conversation.
Update Conversation
This endpoint will return the updated conversation. Fields that can be updated are status
, priority
, notes
, wakeUpAt
, customerId
, and assignedToUserId
.
List Conversations
This endpoint will return a list of conversations.
List Messages for Conversation
This endpoint will return a list of messages for a given conversation.
Create Message in Conversation
This endpoint will post a new message into a Slack thread for a conversation.
Sample request:
Notes:
- Either
body
,blocks
ormarkdown
must be provided. - If both
blocks
andbody
ormarkdown
are provided, theblocks
will be appended after themarkdown
content - Only pass in
triageThreadTs
if you want the message to be posted to a triage thread for that conversation rather than being sent to the customer. - For email and in-app chat conversations, set
isPrivateNote
totrue
to mark the message as a private note which will post to the Slack thread for the conversation without sending a response back to the customer. - File attachments can also be included. See the section on adding attachments when creating a conversation for more information.
Get Customer by ID
This endpoint will return the given customer.
Update Customer
This endpoint will return the updated customer. Fields that can be updated are: name
, slackChannelId
, autoresponder
, supportSteps
, defaultTriageChannelId
, disableAutomatedTicketing
, primarySupportAssigneeId
, primarySupportAssigneeType
, secondarySupportAssigneeId
, secondarySupportAssigneeType
, replyTimeoutHours
, botHandling
, emailDomains
.
Create Customer
This endpoint will return the newly created customer. Fields that can be updated or set on create are: name
, slackChannelId
, emailDomains
Delete Customer
This endpoint will delete the given customer.
List Customers
This endpoint will return a list of customers.
List Users
This endpoint will return a list of users who are a member of your Slack workspace and have been synced into Unthread.
Get User by ID
This endpoint will return the given user.
Get Tag by ID
This endpoint will return the given tag.
Update Tag
This endpoint will return the updated tag. Fields that can be updated are: name
.
Create Tag
This endpoint will return the newly created tag. Fields that can be updated or set on create are: name
Delete Tag
This endpoint will delete the given tag.
List Tags
This endpoint will return a list of tags.
Add Tag to Customers
This endpoint takes an array of customer IDs and will assign the given tag to all the specified customers.
Sample request body: [ '93ba5298-a23f-413b-94fe-73e0ab26a816', '7ab46970-19ec-492e-90fe-47a8abc93fec' ]
Add Tag to Conversations
This endpoint takes an array of conversation IDs and will assign the given tag to all the specified conversations.
Sample request body: [ 'ad00e2d0-4ea4-45c4-9b5d-8728f93e51a7', 'e82cde04-0d59-4416-b5da-1f405f6d4ddb' ]
Remove Tag from Customers
This endpoint takes an array of customer IDs and will remove the given tag from all the specified customers.
Remove Tag from Conversations
This endpoint takes an array of conversation IDs and will remove the given tag from all the specified conversations.
Create and/or send an outbound message
This endpoint will create an outbound and send it, unless the status is set to “draft”. Drafts can be sent later by updating the status to “scheduled”.
Update and/or send an outbound message
This endpoint will update an outbound. Drafts can be sent by updating the status to “scheduled”.
List outbounds
This endpoint will list all outbounds.
Get outbound by ID
This endpoint will return the given outbound.
Create Webhook Subscription
This endpoint will return the newly created webhook subscription. Fields that can be set on create are: url
and enabled
.
Update Webhook Subscription
This endpoint will return the updated webhook subscription. Fields that can be updated are: url
and enabled
.
Delete Webhook Subscription
This endpoint will delete the given webhook subscription.
List Webhook Subscriptions
This endpoint will return a list of webhook subscriptions.
Create Approval Request for Conversation
This endpoint will return the newly created approval request. Fields that can be set on create are: title
, assignedToUserId
and assignedToGroupId
.
Get Approval Requests for Conversation
This endpoint will return a list of approval requests for the given conversation.
Add Follower to Conversation
This endpoint will add a follower to the given conversation. The request body should contain the entityId
of the follower to add and the entityType
which is either “user” or “group”.
Remove Follower from Conversation
This endpoint will remove a follower from the given conversation. The request body should contain the entityId
of the follower to remove.
Assign Collaborator to Conversation
This endpoint will add a collaborator with the given collaborator type to the given conversation. The request body should contain the entityId
of the collaborator to add and the entityType
which is either “user” or “group”.
List Collaborator Types
This endpoint will return a list of collaborator types.
Reporting
This endpoint will return metrics about your conversations. Requests are made in the following format:
- The
timezone
field is optional and defaults to “UTC”. starDate
andendDate
have the following format: “2022-12-31”. The dates are inclusive.dateDimension
specifies in what time period the data should be grouped by.- All metrics are numbers. Response and resolution times are in seconds.
dimensions
is an array of fields to group the data by in addition to date.filters
allows you to filter the data to specific dimensions. If an array is passed for a given dimension then it is treated as anOR
.
Responses are returned in the following format:
- If there is no data for a particular day then that day will not be included in the
data
object, however it will be included in thedates
array. - If dimensions are included in the request, then the data will be nested for each dimension included. Dimensions are nested in the order they are included in the request. See the example below for clarification.
dates
is an array of the time periods covered by the query. For grouping on weeks, each value in the array is the first day of the week starting on Monday. For grouping on months, each value in the array is the first day of the month.lookups
contains friendly names for the keys contained indata
. For example, if grouping bycustomerId
, the lookups would contain a mapping of the customer ID to the customer name.
An example request and response is included below:
Query Knowledge Base
This endpoint allows you to make a one-off query to the knowledge base. You can optionally pass various context parameters to influnce the query results.
Request schema:
Parameters:
query
(required): The string query to search for in the knowledge base.customerId
(optional): The ID of the customer associated with this query.userId
(optional): The ID of the user making the query.conversationId
(optional): The ID of the conversation context for this query.
Example request:
Create Automation
This endpoint creates a new automation.
Request Body
The request body should be a JSON object with the following structure:
name
(required): The name of the automation.description
(optional): A description of the automation.status
(optional): The status of the automation. Defaults to ‘draft’ if not provided.trigger
(required): The trigger configuration for the automation.steps
(required): An array of steps that define the automation’s actions.conditions
(optional): Conditions that determine when the automation should run.
AutomationTrigger
The trigger
field should be an object with a type
property and a data
property. The structure depends on the trigger type:
AutomationStep
Each step in the steps
array should be an object with a type
property and a data
property:
Response
The response will be a JSON object representing the created automation, including its ID and other details.
Notes
- Automations are only available if custom actions are enabled for the tenant.