openapi: 3.0.1 info: title: Gladly Agents Topics API version: '1.0' description: '# Introducing the Gladly API At Gladly, we believe that customer service is best when it''s a conversation. That means more than just helping customers with one-off questions or issues: it''s about making them feel known, valued, and respected for the individuals they are. The Gladly API was built to help facilitate those relationships, providing agents with the rich customer context they need to deliver seamless experiences that make customers feel like they''re more than just a number in a sea of others. # Overview You can integrate easily with Gladly by calling Gladly''s [REST API](#section/Overview/REST-API) and implementing the [Lookup API](#section/Overview/Lookup-API) to provide data from your own services. Some examples of what you do through Gladly APIs include managing customer profile data, interacting with a customer''s timeline, providing the latest information about a customer''s orders, and more. ## REST API Clients can access the **REST API** via HTTPS at your organization''s Gladly domain (e.g. `https://{organization}.gladly.com`). Resources follow REST semantics and utilize industry-standard HTTP verbs, response codes, and authentication schemes. In addition, all responses and payloads are in JSON with consistent error codes and formats. ## Lookup API The Gladly **Lookup API** allows your organization to provide data services to power the agent''s experience with a complete view of your customers'' information, transactions, and activity. You can provide a web service that implements the Lookup API and Gladly will call it when that data is needed. Like the REST API, the Lookup API is specified using REST semantics, and exchanges JSON requests and responses authenticated and signed with secure keys. Gladly will perform lookups when certain activities occur within Gladly, such as when a customer''s profile is loaded. A detailed overview of Lookup Adaptor architecture, requests, resposnes and more can be found [here](https://help.gladly.com/developer/docs/lookup-adapter-introduction). ## Testing Test the myriad possibilities of the Gladly API in a safe, secure space. We''ll enable the Gladly API in a separate sandbox environment, so you can experiment freely without impacting your production environment (or vice versa). Your sandbox environment is accessible at `https://{organization}.gladly.qa`, where `organization` is your company name. For specific API endpoints, see documentation below. # Getting Started Think of this section as getting the keys to unlocking your access to the Gladly APIs. First, you''ll need to set up an account with the necessary API [permissions](#/section/Getting-Started/Permissions). With these permissions, you can then go on to create the [API Token(s)](#section/Getting-Started/Creating-API-Tokens) you need to access Gladly''s API [resources](#section/Overview/Resources). ## Permissions Gladly Administrators can set API permissions on an agent-by-agent basis. We''ll discuss how this maps to API access in the section on [authentication](#section/Authentication) below. To allow a user to create API tokens and access the API: 1. Log in to your Gladly instance. 2. Open the menu on the top left-hand corner of the page. 3. Navigate to **Settings** > **Users* 4. Search and click the user profile you wish to give access to. 5. You''ll see a permission called **API User**. Select it, while making sure to keep the user''s **Agent** role intact. 6. Hit **Save** to give access. ![Agent profile screen](assets/permissions-agent.png) We recommend creating a dedicated user to make API calls, whose account won''t be used for agent and organization management. This will help you with any future audits of API activity vs. agent activity. ## Creating API Tokens You must create an API token to access Gladly API resources (see above [Permissions](#/section/Getting-Started/Permissions)). If your profile already has access to the **API User** permission, you''ll see a menu item titled **More settings**. Click **More settings**: ![API Token Menu](assets/permissions-token-nav.png) Click **API Tokens**, then the **Create Token** button on the upper right-hand corner of the page: ![API Token Add](assets/permissions-token-add.png) A token will be generated and named, by default, **New Token** (though depending on whether you have existing tokens, it may be named New Token 2, or New Token 3, etc.). You can rename the token to something more easily referenceable by clicking the name to edit. This token will be associated with your agent profile, which we refer to as the API User in this document. ![API Token View](assets/permissions-token-view.png) For security purposes, you''ll only see a new token once before you navigate away from the page. ## Replacing/Rotating API Tokens Should you lose this token, or wish to rotate your application keys, you can do the following: 1. Generate a new token. 2. Store the new token in a secure location. 3. Delete the old token. 4. Update your applications/scripts with the new token. # Authentication ' servers: - url: https://{organization}.gladly.com/api/v1 description: Production variables: organization: default: organization description: Your Gladly organization subdomain - url: https://{organization}.gladly.qa/api/v1 description: Sandbox variables: organization: default: organization description: Your Gladly QA organization subdomain security: - basicAuth: [] tags: - name: Topics description: 'A **Topic** is a way of labeling a conversation in Gladly for specific business purposes. For example, an agent may apply the topic "Return" to a conversation where a customer returns merchandise. Topics are used for reporting and to control various workflows. Topics can be configured to have a nested hierarchy. For instance, the topic "Return" could be a parent of "Size" and "Color" child topics. Visit our [Help Pages](https://help.gladly.com/docs/principles-of-hierarchical-topics) to learn more about Hierarchical Topics. ' paths: /api/v1/topics: get: tags: - Topics summary: List Topics description: 'Returns a list of Topics. ' operationId: getTopics responses: '200': description: Topics content: application/json: schema: title: Topics type: array items: $ref: '#/paths/~1api~1v1~1topics~1%7BtopicId%7D/get/responses/200/content/application~1json/schema' example: summary: Topics value: - id: Z_Oto7j-Sy2DlQdnZBDdDw disabled: false name: Order Return - id: 8eiDakrnTgKa3HIxtgV5OA disabled: false name: Damaged Merchandise parentId: Z_Oto7j-Sy2DlQdnZBDdDw - id: WgZnWNicSMmORcNzP8rwGQ disabled: true name: Holiday 2019 parentId: Z_Oto7j-Sy2DlQdnZBDdDw post: tags: - Topics summary: Add Topic description: 'Add a Topic to the list of available Topics. ' operationId: addTopic requestBody: description: Topic to create content: application/json: schema: title: Add Topic Request required: - name properties: id: type: string description: unique Topic id - optional (a new id will be generated if not provided) example: uu4t00vITaKQ3bVjU2UrGQ name: type: string description: Name of the Topic - must be unique example: Order Returns disabled: type: boolean description: If the Topic is not in use - optional, defaults to **false** example: false parentId: type: string description: id of parent Topic, if the Topic is nested under another topic - optional example: ChefeoTHSlaIbKg57H5R9Q responses: '201': description: Topic Created headers: Location: schema: null type: string description: path to the created Topic example: /api/v1/topics/RgEZdEiUSSK9DBjYFQLQyQ '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/NotFoundErrors' examples: id contains unsupported characters: value: errors: - attr: id code: invalid detail: id contains unsupported characters name cannot be blank or missing: value: errors: - attr: name code: blank detail: name cannot be blank '409': description: Topic contains conflicting values content: application/json: schema: $ref: '#/components/schemas/ErrorsWithMeta' examples: topic with specified id already exists: value: errors: - attr: id code: taken detail: the topic with specified id already exists another topic already has this name: value: errors: - attr: name code: taken detail: another topic already has this name meta: id: BgMCrCVbTrGhAeDTwIr44g /api/v1/topics/{topicId}: parameters: - name: topicId in: path description: id of the Topic required: true schema: type: string example: uu4t00vITaKQ3bVjU2UrGQ get: tags: - Topics summary: Get Topic description: 'Get a Topic by its unique id. ' operationId: getTopic responses: '200': description: Topic content: application/json: schema: title: Topic type: object properties: id: type: string description: Id of the Topic example: uu4t00vITaKQ3bVjU2UrGQ name: type: string description: Name of the Topic example: Order Returns disabled: type: boolean description: If the Topic cannot be applied to Conversations, and is no longer in use example: false parentId: type: string description: If the Topic is nested under another topic, parentId is the Id of the parent topic. For more information about topic hierarchy, please visit the [help docs](https://help.gladly.com/docs/en/principles-of-hierarchical-topics) example: ChefeoTHSlaIbKg57H5R9Q '404': description: Given Topic id does not exist content: application/json: schema: $ref: '#/components/schemas/NotFoundErrors' patch: tags: - Topics summary: Update Topic description: 'Update an existing Topic. ' operationId: updateTopic requestBody: content: application/json: schema: title: Update Topic Request required: - name properties: name: type: string description: Name of the Topic example: Order Returns disabled: type: boolean description: If the Topic is not in use example: false parentId: type: string description: id of parent Topic, if the Topic is nested under another topic - optional example: ChefeoTHSlaIbKg57H5R9Q responses: '204': description: Topic updated successfully '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/Errors' examples: name cannot be blank or missing: value: errors: - attr: name code: blank detail: name cannot be blank '404': description: Topic with the specified id does not exist content: application/json: schema: $ref: '#/components/schemas/NotFoundErrors' example: errors: code: not_exist detail: conversation topic [topicId] does not exist '409': description: Topic update contains conflicting values content: application/json: schema: $ref: '#/components/schemas/ErrorsWithMeta' examples: another topic already has this name: value: errors: - attr: name code: taken detail: another topic already has this name meta: id: BgMCrCVbTrGhAeDTwIr44g components: schemas: Errors: type: object properties: errors: type: array items: $ref: '#/components/schemas/Error' example: - attr: content code: blank detail: content cannot be blank ErrorsWithMeta: type: object properties: errors: type: array items: $ref: '#/components/schemas/ErrorWithMeta' example: - attr: name code: taken detail: another entity with this name already exists meta: id: conflicting-id ErrorWithMeta: allOf: - $ref: '#/components/schemas/Error' - type: object properties: meta: type: object additionalProperties: true description: Additional information about the error NotFoundErrors: type: object properties: errors: type: array items: $ref: '#/components/schemas/Error' example: - code: not_exist detail: entity does not exist Error: type: object properties: attr: type: string description: Identifies the field causing the error code: type: string description: Code indicating the error type detail: type: string description: More details describing what went wrong securitySchemes: BasicAuth: type: http scheme: basic description: 'Gladly API uses token-based **Basic Authentication**. API tokens are associated with designated Gladly users. To create and use an API token, your user must have the API User permission. An API token can be used to perform any API request without restriction. | user name | password | | ----------- | --------- | | agent email | API token | The credentials must be passed via an `Authorization` HTTP header. All requests must be made over HTTPS. ```shell curl -u user@organization.com:$GLADLY_API_TOKEN \ https://organization.gladly.com/api/v1/organization ``` ' basicAuth: type: http scheme: basic description: HTTP Basic auth — username is the API user email; password is the API token. Requires the "API User" permission. x-tagGroups: - name: REST API tags: - Agents - Public Answer - Answer Management - Audiences - Business Hours - Communications - Conversations - Customers - Events - Export - Freeform Topics - Inboxes - Organization - Proactive Conversations - Reports - Tasks - Teams - User Identity - Topics - Webhooks - name: Webhooks tags: - Summary - Payloads - name: Lookup API tags: - Customer Lookup - name: Resources tags: - Versioning - Error Handling - Rate Limit - Rich Content - Launching Soon