Skip to main content
This page demonstrates the most common API workflow: creating or finding a session, creating a ticket, and adding a comment to that ticket.

Common Flow Example

This example walks through a complete workflow that you’ll use frequently when integrating with the Gleap API.

Step 1: Create or Find a Session

First, create a session to represent a user or contact. If a session with the same userId already exists, you can use that session ID instead. Endpoint: POST /v3/sessions Request:
Response:
Save the _id or id from the response - you’ll need it to create a ticket linked to this session.

Step 2: Create a Ticket

Now create a ticket and link it to the session you just created. The ticket represents a support request, bug report, or feature request. Endpoint: POST /v3/tickets Request:
Response:
Save the _id or id from the ticket response - you’ll need it to add comments to this ticket.

Step 3: Create a Comment

Add a comment to the ticket. Comments can be simple text or rich formatted content. You can also attach files. Endpoint: POST /v3/messages Request (Simple Text Comment):
Request (Rich Formatted Comment with Attachments):
Request (Internal Note):
Response:

Step 4: Create a Customer Comment

You can also create a comment that appears as if it’s from the customer (session) rather than from an agent. This is useful when you want to add a comment on behalf of the customer. Endpoint: POST /v3/messages Request:
Response:
By including the session field in the request, the comment will appear as if it came from the customer (session) rather than from an agent (user). Omit the session field to create an agent comment.